Rev 4197 | Rev 4743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4197 | Rev 4332 | ||
|---|---|---|---|
| Line 79... | Line 79... | ||
| 79 | int index; |
79 | int index; |
| 80 | 80 | ||
| 81 | for( index = 0; index < map->next; ++ index ){ |
81 | for( index = 0; index < map->next; ++ index ){ |
| 82 | if( map->items[ index ]->c == * identifier ){ |
82 | if( map->items[ index ]->c == * identifier ){ |
| 83 | ++ identifier; |
83 | ++ identifier; |
| 84 | if( length ) -- length; |
- | |
| 85 | if( length || ( * identifier )){ |
84 | if(( length > 1 ) || (( length == 0 ) && ( * identifier ))){ |
| 86 | return char_map_add( map->items[ index ], identifier, length, value ); |
85 | return char_map_add( map->items[ index ], identifier, length ? length - 1 : 0, value ); |
| 87 | }else{ |
86 | }else{ |
| 88 | if( map->items[ index ]->value != CHAR_MAP_NULL ) return EEXISTS; |
87 | if( map->items[ index ]->value != CHAR_MAP_NULL ) return EEXISTS; |
| 89 | map->items[ index ]->value = value; |
88 | map->items[ index ]->value = value; |
| 90 | return EOK; |
89 | return EOK; |
| 91 | } |
90 | } |
| Line 112... | Line 111... | ||
| 112 | map->items[ map->next ] = NULL; |
111 | map->items[ map->next ] = NULL; |
| 113 | return ENOMEM; |
112 | return ENOMEM; |
| 114 | } |
113 | } |
| 115 | map->items[ map->next ]->c = * identifier; |
114 | map->items[ map->next ]->c = * identifier; |
| 116 | ++ identifier; |
115 | ++ identifier; |
| 117 | if( length ) -- length; |
- | |
| 118 | ++ map->next; |
116 | ++ map->next; |
| 119 | if( length || ( * identifier )){ |
117 | if(( length > 1 ) || (( length == 0 ) && ( * identifier ))){ |
| 120 | map->items[ map->next - 1 ]->value = CHAR_MAP_NULL; |
118 | map->items[ map->next - 1 ]->value = CHAR_MAP_NULL; |
| 121 | return char_map_add_item( map->items[ map->next - 1 ], identifier, length, value ); |
119 | return char_map_add_item( map->items[ map->next - 1 ], identifier, length ? length - 1 : 0, value ); |
| 122 | }else{ |
120 | }else{ |
| 123 | map->items[ map->next - 1 ]->value = value; |
121 | map->items[ map->next - 1 ]->value = value; |
| 124 | } |
122 | } |
| 125 | return EOK; |
123 | return EOK; |
| 126 | } |
124 | } |
| Line 159... | Line 157... | ||
| 159 | return node ? node->value : CHAR_MAP_NULL; |
157 | return node ? node->value : CHAR_MAP_NULL; |
| 160 | } |
158 | } |
| 161 | 159 | ||
| 162 | char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, size_t length ){ |
160 | char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, size_t length ){ |
| 163 | if( ! char_map_is_valid( map )) return NULL; |
161 | if( ! char_map_is_valid( map )) return NULL; |
| 164 | if( length ) -- length; |
- | |
| 165 | if( length || ( * identifier )){ |
162 | if( length || ( * identifier )){ |
| 166 | int index; |
163 | int index; |
| 167 | 164 | ||
| 168 | for( index = 0; index < map->next; ++ index ){ |
165 | for( index = 0; index < map->next; ++ index ){ |
| 169 | if( map->items[ index ]->c == * identifier ){ |
166 | if( map->items[ index ]->c == * identifier ){ |
| 170 | ++ identifier; |
167 | ++ identifier; |
| - | 168 | if( length == 1 ) return map->items[ index ]; |
|
| 171 | return char_map_find_node( map->items[ index ], identifier, length ); |
169 | return char_map_find_node( map->items[ index ], identifier, length ? length - 1 : 0 ); |
| 172 | } |
170 | } |
| 173 | } |
171 | } |
| 174 | return NULL; |
172 | return NULL; |
| 175 | } |
173 | } |
| 176 | return map; |
174 | return map; |