aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/stdlib/strtol.c2
-rw-r--r--libc/stdlib/strtoul.c2
-rw-r--r--libc/test/run-stdlib.c7
3 files changed, 3 insertions, 8 deletions
diff --git a/libc/stdlib/strtol.c b/libc/stdlib/strtol.c
index 474597a..e6d4da3 100644
--- a/libc/stdlib/strtol.c
+++ b/libc/stdlib/strtol.c
@@ -53,8 +53,6 @@ long int strtol(const char *S, char **PTR,int BASE)
if ((**PTR == '0') && (*((*PTR)+1) == 'x'))
{
BASE = 16;
- (*PTR)++;
- (*PTR)++;
}
else
{
diff --git a/libc/stdlib/strtoul.c b/libc/stdlib/strtoul.c
index 754e7db..8472668 100644
--- a/libc/stdlib/strtoul.c
+++ b/libc/stdlib/strtoul.c
@@ -46,8 +46,6 @@ unsigned long int strtoul(const char *S, char **PTR,int BASE)
if ((**PTR == '0') && (*((*PTR)+1) == 'x'))
{
BASE = 16;
- (*PTR)++;
- (*PTR)++;
}
else
{
diff --git a/libc/test/run-stdlib.c b/libc/test/run-stdlib.c
index bb64790..98c79b7 100644
--- a/libc/test/run-stdlib.c
+++ b/libc/test/run-stdlib.c
@@ -41,8 +41,8 @@ int main(void)
/* our atoi recognises hex! */
assert(atoi("0x800") == 0x800);
- /* Really weird hex! */
- assert(atoi("0x0x800") == 0x800);
+ /* But not with a duplicate prefix */
+ assert(atoi("0x0x800") == 0);
/* atol - ensure it recognises longs */
assert(atol("2147483648") == 2147483648);
@@ -73,8 +73,7 @@ int main(void)
/* strtoul - autodetection of base */
assert(strtoul(" 123456", NULL, 0) == 123456);
assert(strtoul("0x800", NULL, 0) == 0x800);
- /* Again, really weird hex */
- assert(strtoul("0x0x800", NULL, 0) == 0x800);
+ assert(strtoul("0x0x800", NULL, 0) == 0);
/* strtoul - weird/invalid bases */
assert(strtoul("z", NULL, -1) == 0);