static char *strip_spaces(char *pval)
{
    char *p, *start;

    for (start = pval; isspace(*start); )
        start++;
    if (*start == '\0')
        return start;

    for (p = start + strlen(start); --p >= start && isspace(*p); )
        *p = '\0';
    return start;
}