File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ \section{Built-in Module \sectcode{struct}}
6161A format character may be preceded by an integral repeat count; e.g.\
6262the format string \code {'4h'} means exactly the same as \code {'hhhh'}.
6363
64+ Whitespace characters between formats are ignored; a count and its
65+ format must not contain whitespace though.
66+
6467For the \code {'s'} format character, the count is interpreted as the
6568size of the string, not a repeat count like for the other format
6669characters; e.g. \code {'10s'} means a single 10-byte string, while
Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ \section{Built-in Module \sectcode{struct}}
6161A format character may be preceded by an integral repeat count; e.g.\
6262the format string \code {'4h'} means exactly the same as \code {'hhhh'}.
6363
64+ Whitespace characters between formats are ignored; a count and its
65+ format must not contain whitespace though.
66+
6467For the \code {'s'} format character, the count is interpreted as the
6568size of the string, not a repeat count like for the other format
6669characters; e.g. \code {'10s'} means a single 10-byte string, while
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ PERFORMANCE OF THIS SOFTWARE.
3838#include "mymath.h"
3939
4040#include <limits.h>
41+ #include <ctype.h>
4142
4243
4344/* Exception */
@@ -981,6 +982,8 @@ calcsize(fmt, f)
981982 s = fmt ;
982983 size = 0 ;
983984 while ((c = * s ++ ) != '\0' ) {
985+ if (isspace (c ))
986+ continue ;
984987 if ('0' <= c && c <= '9' ) {
985988 num = c - '0' ;
986989 while ('0' <= (c = * s ++ ) && c <= '9' ) {
@@ -1075,6 +1078,8 @@ struct_pack(self, args)
10751078 res = restart = PyString_AsString (result );
10761079
10771080 while ((c = * s ++ ) != '\0' ) {
1081+ if (isspace (c ))
1082+ continue ;
10781083 if ('0' <= c && c <= '9' ) {
10791084 num = c - '0' ;
10801085 while ('0' <= (c = * s ++ ) && c <= '9' )
@@ -1179,6 +1184,8 @@ struct_unpack(self, args)
11791184 str = start ;
11801185 s = fmt ;
11811186 while ((c = * s ++ ) != '\0' ) {
1187+ if (isspace (c ))
1188+ continue ;
11821189 if ('0' <= c && c <= '9' ) {
11831190 num = c - '0' ;
11841191 while ('0' <= (c = * s ++ ) && c <= '9' )
You can’t perform that action at this time.
0 commit comments