/* -*-c-*-
*
- * $Id: str.c,v 1.2 1999/05/26 20:52:57 mdw Exp $
+ * $Id: str.c,v 1.3 1999/12/22 15:41:14 mdw Exp $
*
* Functions for hacking with strings
*
/*----- Revision history --------------------------------------------------*
*
* $Log: str.c,v $
+ * Revision 1.3 1999/12/22 15:41:14 mdw
+ * Skip past trailing whitespace in str_getword.
+ *
* Revision 1.2 1999/05/26 20:52:57 mdw
* Add new `rest' argument for `str_split'.
*
for (q = p; *q; q++) {
if (isspace((unsigned char)*q)) {
- *q = 0;
- *pp = q + 1;
+ *q++ = 0;
+ while (*q && isspace((unsigned char)*q))
+ q++;
+ if (!*q)
+ q = 0;
+ *pp = q;
return (p);
}
}
c--;
n++;
}
-
while (c) {
*v++ = 0;
c--;
}
-
- if (rest) {
- if (!p)
- *rest = 0;
- else {
- while (isspace((unsigned char)*p))
- p++;
- if (*p)
- *rest = p;
- else
- *rest = 0;
- }
- }
+ if (rest)
+ *rest = p;
return (n);
}