]> granicus.if.org Git - python/commitdiff
split_whitespace(): Make sure delimiter is stripped from the beginning
authorBarry Warsaw <barry@python.org>
Tue, 2 Dec 1997 00:29:30 +0000 (00:29 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 2 Dec 1997 00:29:30 +0000 (00:29 +0000)
of the remainder item (last item in list) when maxsplit is < the
number of occurrences.

Modules/stropmodule.c

index 9fc4b9b281d79bd5e3536fd7e7e0df918fabfcb2..6de624e7094f69151e35d315e628b09e7beaa495 100644 (file)
@@ -85,7 +85,10 @@ split_whitespace(s, len, maxsplit)
                                goto finally;
 
                        countsplit++;
-                       if (maxsplit && (countsplit >= maxsplit)) {
+                       while (i < len && isspace(Py_CHARMASK(s[i]))) {
+                               i = i+1;
+                       }
+                       if (maxsplit && (countsplit >= maxsplit) && i < len) {
                                item = PyString_FromStringAndSize(
                                         s+i, (int)(len - i));
                                if (item == NULL)