]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Ignore whitespace between formats (not internal to a count+format).
authorGuido van Rossum <guido@python.org>
Tue, 26 Aug 1997 20:39:54 +0000 (20:39 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 26 Aug 1997 20:39:54 +0000 (20:39 +0000)
Doc/lib/libstruct.tex
Doc/libstruct.tex
Modules/structmodule.c

index d57a2b790a4a91a39831b8aa085e219d6ad38a84..af2e6d2837ebc4c1e9632567739d72caec9eb443 100644 (file)
@@ -61,6 +61,9 @@ and Python values should be obvious given their types:
 A format character may be preceded by an integral repeat count; e.g.\
 the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
 
+Whitespace characters between formats are ignored; a count and its
+format must not contain whitespace though.
+
 For the \code{'s'} format character, the count is interpreted as the
 size of the string, not a repeat count like for the other format
 characters; e.g. \code{'10s'} means a single 10-byte string, while
index d57a2b790a4a91a39831b8aa085e219d6ad38a84..af2e6d2837ebc4c1e9632567739d72caec9eb443 100644 (file)
@@ -61,6 +61,9 @@ and Python values should be obvious given their types:
 A format character may be preceded by an integral repeat count; e.g.\
 the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
 
+Whitespace characters between formats are ignored; a count and its
+format must not contain whitespace though.
+
 For the \code{'s'} format character, the count is interpreted as the
 size of the string, not a repeat count like for the other format
 characters; e.g. \code{'10s'} means a single 10-byte string, while
index dbba9b48f20eb44c99ac266b88a43b643aa280c4..54ca63166eefb971182b0d67f1144239da5e5874 100644 (file)
@@ -38,6 +38,7 @@ PERFORMANCE OF THIS SOFTWARE.
 #include "mymath.h"
 
 #include <limits.h>
+#include <ctype.h>
 
 
 /* Exception */
@@ -981,6 +982,8 @@ calcsize(fmt, f)
        s = fmt;
        size = 0;
        while ((c = *s++) != '\0') {
+               if (isspace(c))
+                       continue;
                if ('0' <= c && c <= '9') {
                        num = c - '0';
                        while ('0' <= (c = *s++) && c <= '9') {
@@ -1075,6 +1078,8 @@ struct_pack(self, args)
        res = restart = PyString_AsString(result);
 
        while ((c = *s++) != '\0') {
+               if (isspace(c))
+                       continue;
                if ('0' <= c && c <= '9') {
                        num = c - '0';
                        while ('0' <= (c = *s++) && c <= '9')
@@ -1179,6 +1184,8 @@ struct_unpack(self, args)
        str = start;
        s = fmt;
        while ((c = *s++) != '\0') {
+               if (isspace(c))
+                       continue;
                if ('0' <= c && c <= '9') {
                        num = c - '0';
                        while ('0' <= (c = *s++) && c <= '9')