getword(), cleanup

This commit is contained in:
rlar 2016-05-06 19:42:35 +02:00
parent 52ec0a262c
commit d3d966b027
1 changed files with 6 additions and 9 deletions

View File

@ -1320,24 +1320,21 @@ static void
getword(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi) getword(const char * const s, SPICE_DSTRINGPTR tstr_p, const char **pi)
/* isolate a word from s after position "after". return i= last read+1 */ /* isolate a word from s after position "after". return i= last read+1 */
{ {
const char *iptr; const char *iptr = *pi;
iptr = *pi; const char * const ls_ptr = s + (int) strlen(s);
const char *ls_ptr;
ls_ptr = s + (int) strlen(s);
do do
iptr++; iptr++;
while (((iptr - s) < (ls_ptr - s)) && !alfa(s[(iptr - s) - 1])); while ((iptr < ls_ptr) && !alfa(iptr[-1]));
spice_dstring_reinit(tstr_p); spice_dstring_reinit(tstr_p);
while (((iptr - s) <= (ls_ptr - s)) && (alfa(s[(iptr - s) - 1]) || isdigit_c(s[(iptr - s) - 1]))) { while ((iptr <= ls_ptr) && (alfa(iptr[-1]) || isdigit_c(iptr[-1]))) {
cadd(tstr_p, toupper_c(s[(iptr - s) - 1])); cadd(tstr_p, toupper_c(iptr[-1]));
iptr++; iptr++;
} }
*pi = s + (iptr - s); *pi = iptr;
} }