if (!str || len >= sizeof(res))
return 0;
- while (*str && isspace(*str))
- str++;
-
- for (prev = 0, ptr = res; *str; prev = *str, str++)
+ for (prev = ' ', ptr = res; *str; prev = *str, str++)
{
if (isspace(*str))
{
- if (isspace(prev))
- continue;
-
- *ptr++ = ' ';
+ if (!isspace(prev))
+ *ptr++ = ' ';
}
else
{
}
}
- while ((ptr > res) && isspace(*ptr))
+ if ((ptr > res) && isspace(*(ptr-1)))
ptr--;
return sfh_hash(res, ptr - res);