summaryrefslogtreecommitdiffstats
path: root/Modules/structmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-12-31 02:10:45 (GMT)
committerGuido van Rossum <guido@python.org>1996-12-31 02:10:45 (GMT)
commit3aa27fd315342c94a0e6a5b6237612726abfb3a3 (patch)
tree2093e3788305bb353b61575093783f6501755eea /Modules/structmodule.c
parentf7e6b4b38872fb848b7c834010ec23ec59826e43 (diff)
downloadcpython-3aa27fd315342c94a0e6a5b6237612726abfb3a3.zip
cpython-3aa27fd315342c94a0e6a5b6237612726abfb3a3.tar.gz
cpython-3aa27fd315342c94a0e6a5b6237612726abfb3a3.tar.bz2
Fix the first bugs... treatment of 0 count was wrong, and memchr()
should be memset().
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r--Modules/structmodule.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index cfbd2a6..a96606b 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -668,8 +668,6 @@ struct_pack(self, args)
num = num*10 + (c - '0');
if (c == '\0')
break;
- if (num == 0 && c != 's')
- continue;
}
else
num = 1;
@@ -678,10 +676,12 @@ struct_pack(self, args)
if (e == NULL)
goto fail;
res = restart + align((int)(res-restart), c, e);
+ if (num == 0 && c != 's')
+ continue;
do {
if (c == 'x') {
/* doesn't consume arguments */
- memchr(res, '\0', num);
+ memset(res, '\0', num);
res += num;
break;
}
@@ -707,7 +707,7 @@ struct_pack(self, args)
if (n > 0)
memcpy(res, PyString_AsString(v), n);
if (n < num)
- memchr(res+n, '\0', num-n);
+ memset(res+n, '\0', num-n);
res += num;
break;
}
@@ -769,8 +769,6 @@ struct_unpack(self, args)
num = num*10 + (c - '0');
if (c == '\0')
break;
- if (num == 0 && c != 's')
- break;
}
else
num = 1;
@@ -779,6 +777,8 @@ struct_unpack(self, args)
if (e == NULL)
goto fail;
str = start + align((int)(str-start), c, e);
+ if (num == 0 && c != 's')
+ continue;
do {
if (c == 'x') {