Changeset 3377
- Timestamp:
- 12/26/05 20:27:38 (3 years ago)
- Files:
-
- libwired/trunk/libwired/data/wi-string.c (modified) (3 diffs)
- libwired/trunk/libwired/data/wi-string.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/data/wi-string.c
r3355 r3377 812 812 void wi_string_delete_characters_in_range(wi_string_t *string, wi_range_t range) { 813 813 _WI_STRING_INDEX_ASSERT(string, range.location + range.length); 814 814 815 815 memmove(string->string + range.location, 816 816 string->string + range.location + range.length, … … 989 989 990 990 991 unsigned int wi_string_index_of_char(wi_string_t *string, char ch, wi_string_options_t options) { 992 char *p; 993 994 p = (options & WI_STRING_BACKWARDS) 995 ? strrchr(string->string, ch) 996 : strchr(string->string, ch); 997 998 if(!p) 999 return WI_NOT_FOUND; 1000 1001 return p - string->string; 1002 } 1003 1004 991 unsigned int wi_string_index_of_char(wi_string_t *string, int ch, wi_string_options_t options) { 992 unsigned int i, index = WI_NOT_FOUND; 993 char *p; 994 int c; 995 wi_boolean_t insensitive = false; 996 997 if((options & WI_STRING_CASE_INSENSITIVE) || 998 (options & WI_STRING_SMART_CASE_INSENSITIVE && isupper(ch))) { 999 insensitive = true; 1000 ch = tolower((unsigned char) ch); 1001 } 1002 1003 p = string->string; 1004 1005 for(i = 0; *p; p++, i++) { 1006 c = insensitive ? tolower((unsigned char) *p) : *p; 1007 1008 if(c == ch) { 1009 index = i; 1010 1011 if(!(options & WI_STRING_BACKWARDS)) 1012 break; 1013 } 1014 } 1015 1016 return index; 1017 } 1018 1019 1005 1020 1006 1021 wi_boolean_t wi_string_contains_string(wi_string_t *string, wi_string_t *otherstring, wi_string_options_t options) { … … 1311 1326 unsigned int index; 1312 1327 1313 index = wi_string_index_of_ string(path, WI_STR("."), WI_STRING_BACKWARDS);1314 1328 index = wi_string_index_of_char(path, '.', WI_STRING_BACKWARDS); 1329 1315 1330 if(index != WI_NOT_FOUND) 1316 1331 wi_string_delete_characters_from_index(path, index); libwired/trunk/libwired/data/wi-string.h
r3321 r3377 104 104 WI_EXPORT wi_range_t wi_string_range_of_string(wi_string_t *, wi_string_t *, wi_string_options_t); 105 105 WI_EXPORT unsigned int wi_string_index_of_string(wi_string_t *, wi_string_t *, wi_string_options_t); 106 WI_EXPORT unsigned int wi_string_index_of_char(wi_string_t *, char, wi_string_options_t);106 WI_EXPORT unsigned int wi_string_index_of_char(wi_string_t *, int, wi_string_options_t); 107 107 WI_EXPORT wi_boolean_t wi_string_contains_string(wi_string_t *, wi_string_t *, wi_string_options_t); 108 108 WI_EXPORT wi_boolean_t wi_string_has_prefix(wi_string_t *, wi_string_t *);
