diff options
author | Guido van Rossum <guido@python.org> | 1996-10-04 13:39:37 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-10-04 13:39:37 (GMT) |
commit | a0ca4c402d1e19cbc9b317632deab0d7c2492987 (patch) | |
tree | b090fb45440bf9b4d69b2d5402bb721abd8dfc2f /Modules | |
parent | fe779a1dc8065dc175cb4ff454ed6d3a1944adf0 (diff) | |
download | cpython-a0ca4c402d1e19cbc9b317632deab0d7c2492987.zip cpython-a0ca4c402d1e19cbc9b317632deab0d7c2492987.tar.gz cpython-a0ca4c402d1e19cbc9b317632deab0d7c2492987.tar.bz2 |
Replace all uses of strncmp (in split, find, rfind) with memcmp, so
embedded \0 in the delimiter is handled properly. Thanks to Sjoerd
for suggesting this.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/stropmodule.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index a70df8c..324859e 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -132,7 +132,7 @@ strop_splitfields(self, args) i = j = 0; while (i+n <= len) { - if (s[i] == sub[0] && (n == 1 || strncmp(s+i, sub, n) == 0)) { + if (s[i] == sub[0] && (n == 1 || memcmp(s+i, sub, n) == 0)) { item = newsizedstringobject(s+j, (int)(i-j)); if (item == NULL) goto fail; @@ -261,7 +261,7 @@ strop_find(self, args) len -= n; for (; i <= len; ++i) if (s[i] == sub[0] && - (n == 1 || strncmp(&s[i+1], &sub[1], n-1) == 0)) + (n == 1 || memcmp(&s[i+1], &sub[1], n-1) == 0)) return newintobject((long)i); return newintobject(-1L); @@ -294,7 +294,7 @@ strop_rfind(self, args) for (j = len-n; j >= i; --j) if (s[j] == sub[0] && - (n == 1 || strncmp(&s[j+1], &sub[1], n-1) == 0)) + (n == 1 || memcmp(&s[j+1], &sub[1], n-1) == 0)) return newintobject((long)j); return newintobject(-1L); |