util.c | util.c | |||
---|---|---|---|---|
skipping to change at line 124 | skipping to change at line 124 | |||
return strcmp(s1, s2); | return strcmp(s1, s2); | |||
} | } | |||
bool oscap_streq(const char *s1, const char *s2) | bool oscap_streq(const char *s1, const char *s2) | |||
{ | { | |||
return (oscap_strcmp(s1, s2) == 0); | return (oscap_strcmp(s1, s2) == 0); | |||
} | } | |||
char *oscap_trim(char *str) | char *oscap_trim(char *str) | |||
{ | { | |||
int off, i; | int off, i = 0; | |||
if (str == NULL) | ||||
return NULL; | if (str == NULL) | |||
for (i = 0; isspace(str[i]); ++i) ; | return (NULL); | |||
/* left trim */ | ||||
while (isspace(str[i])) ++i; | ||||
off = i; | off = i; | |||
while (str[i]) { | ||||
/* move */ | ||||
while (1) { | ||||
str[i - off] = str[i]; | str[i - off] = str[i]; | |||
++i; | if (str[i] == '\0') | |||
break; | ||||
++i; | ||||
} | } | |||
for (i -= off; isspace(str[--i]) && i >= 0;) ; | ||||
str[++i] = '\0'; | i -= off; | |||
/* right trim */ | ||||
while (i > 0) { | ||||
if (!isspace(str[--i])) { | ||||
str[i + 1] = '\0'; | ||||
break; | ||||
} | ||||
} | ||||
return str; | return str; | |||
} | } | |||
char *oscap_vsprintf(const char *fmt, va_list ap) | char *oscap_vsprintf(const char *fmt, va_list ap) | |||
{ | { | |||
if (fmt == NULL) return NULL; | if (fmt == NULL) return NULL; | |||
char *ret = NULL; | char *ret = NULL; | |||
va_list args; | va_list args; | |||
va_copy(args, ap); | va_copy(args, ap); | |||
skipping to change at line 178 | skipping to change at line 195 | |||
char *oscap_rtrim(char *str, char ch) | char *oscap_rtrim(char *str, char ch) | |||
{ | { | |||
if (str == NULL) return NULL; | if (str == NULL) return NULL; | |||
for (char *pos = str + strlen(str) - 1; pos >= str; --pos) { | for (char *pos = str + strlen(str) - 1; pos >= str; --pos) { | |||
if (*pos == ch) *pos = '\0'; | if (*pos == ch) *pos = '\0'; | |||
else break; | else break; | |||
} | } | |||
return str; | return str; | |||
} | } | |||
void oscap_strtoupper(char *str) | ||||
{ | ||||
if (!str) return; | ||||
for (; *str; ++str) *str = toupper(*str); | ||||
} | ||||
End of changes. 5 change blocks. | ||||
8 lines changed or deleted | 25 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |