chiark
/
gitweb
/
~mdw
/
mLib
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c53c8c8
)
Skip past trailing whitespace in str_getword.
author
mdw
<mdw>
Wed, 22 Dec 1999 15:41:14 +0000
(15:41 +0000)
committer
mdw
<mdw>
Wed, 22 Dec 1999 15:41:14 +0000
(15:41 +0000)
str.c
patch
|
blob
|
blame
|
history
diff --git
a/str.c
b/str.c
index b6e481309ab8ff31b6c03d9946b41a8ca67f3241..0defaa762aa2d50dc63e305924137fb8c022fe5a 100644
(file)
--- a/
str.c
+++ b/
str.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-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
*
*
* Functions for hacking with strings
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: str.c,v $
/*----- 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'.
*
* Revision 1.2 1999/05/26 20:52:57 mdw
* Add new `rest' argument for `str_split'.
*
@@
-71,8
+74,12
@@
char *str_getword(char **pp)
for (q = p; *q; q++) {
if (isspace((unsigned char)*q)) {
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);
}
}
return (p);
}
}
@@
-111,24
+118,12
@@
size_t str_split(char *p, char *v[], size_t c, char **rest)
c--;
n++;
}
c--;
n++;
}
-
while (c) {
*v++ = 0;
c--;
}
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);
}
return (n);
}