summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-11-19 06:42:22 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-11-19 06:42:22 +0000
commitcfd3e6cc939d8bde13484fe44765049dcaa49dc2 (patch)
tree1b3d87730118630502a5e7ba95045e4401b25fb3 /util.c
parentb76347f2eb34c85a0a38543b2f57ca474fedab4d (diff)
downloadperl-cfd3e6cc939d8bde13484fe44765049dcaa49dc2.tar.gz
Make hex scanning warn on "\x{x}" and "\xx".
"\x" and and hex("x") are still valid. p4raw-id: //depot/perl@7746
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/util.c b/util.c
index 2168d55ee6..02d0ed52f5 100644
--- a/util.c
+++ b/util.c
@@ -3094,10 +3094,20 @@ Perl_scan_hex(pTHX_ char *start, STRLEN len, STRLEN *retlen)
register char *s = start;
register NV rnv = 0.0;
register UV ruv = 0;
- register bool seenx = FALSE;
register bool overflowed = FALSE;
char *hexdigit;
+ if (len > 2) {
+ if (s[0] == 'x') {
+ s++;
+ len--;
+ }
+ else if (len > 3 && s[0] == '0' && s[1] == 'x') {
+ s+=2;
+ len-=2;
+ }
+ }
+
for (; len-- && *s; s++) {
hexdigit = strchr((char *) PL_hexdigit, *s);
if (!hexdigit) {
@@ -3107,11 +3117,6 @@ Perl_scan_hex(pTHX_ char *start, STRLEN len, STRLEN *retlen)
--len;
++s;
}
- else if (seenx == FALSE && *s == 'x' && ruv == 0) {
- /* Disallow 0xxx0x0xxx... */
- seenx = TRUE;
- continue;
- }
else {
dTHR;
if (ckWARN(WARN_DIGIT))