diff options
author | Guido van Rossum <guido@python.org> | 1993-07-08 11:12:36 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-07-08 11:12:36 (GMT) |
commit | d05eb8b0fc24c518abcd582e875393886f37689b (patch) | |
tree | 7bc07edaa9633db336b5e6525f169da38f7cba85 /Modules | |
parent | df5638662d95c08d48da0ac236dec4e44e93874e (diff) | |
download | cpython-d05eb8b0fc24c518abcd582e875393886f37689b.zip cpython-d05eb8b0fc24c518abcd582e875393886f37689b.tar.gz cpython-d05eb8b0fc24c518abcd582e875393886f37689b.tar.bz2 |
stropmodule.c: use C isspace(c) to test for whitespace; add
whitespace variable to module dict.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/stropmodule.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 6157442..6fc2719 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -27,6 +27,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "allobjects.h" #include "modsupport.h" +#include <ctype.h> + static object * strop_split(self, args) @@ -47,12 +49,12 @@ strop_split(self, args) i = 0; while (i < len) { while (i < len && - ((c = s[i]) == ' ' || c == '\t' || c == '\n')) { + ((c = s[i]), isspace(c))) { i = i+1; } j = i; while (i < len && - !((c = s[i]) == ' ' || c == '\t' || c == '\n')) { + !((c = s[i]), isspace(c))) { i = i+1; } if (j < i) { @@ -226,14 +228,14 @@ strop_strip(self, args) return NULL; i = 0; - while (i < len && ((c = s[i]) == ' ' || c == '\t' || c == '\n')) { + while (i < len && ((c = s[i]), isspace(c))) { i++; } j = len; do { j--; - } while (j >= i && ((c = s[j]) == ' ' || c == '\t' || c == '\n')); + } while (j >= i && ((c = s[j]), isspace(c))); j++; if (i == 0 && j == len) { @@ -245,8 +247,6 @@ strop_strip(self, args) } -#include <ctype.h> - static object * strop_lower(self, args) object *self; /* Not used */ @@ -370,5 +370,17 @@ static struct methodlist strop_methods[] = { void initstrop() { - initmodule("strop", strop_methods); + object *m, *d, *s; + char buf[256]; + int c, n; + m = initmodule("strop", strop_methods); + d = getmoduledict(m); + n = 0; + for (c = 1; c < 256; c++) { + if (isspace(c)) + buf[n++] = c; + } + s = newsizedstringobject(buf, n); + dictinsert(d, "whitespace", s); + DECREF(s); } |