Commit Diff


commit - a42736003129d28186aa3c4ef74ed13a32297deb
commit + ef33a69e821d4cd948c47dae32edc968e3d22a6f
blob - e758a0161e77fe2c84a350e2f2e41b72aa591d74
blob + 83368aa9f3d72c311e6cfd8123de38ac0860e872
--- np.y
+++ np.y
@@ -26,7 +26,9 @@
 #include "compat.h"
 
 #include <ctype.h>
+#include <errno.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -548,21 +550,24 @@ yylex(void)
 				yyerror("string too long");
 				return findeol();
 			}
-		} while ((c = lgetc(0)) != EOF && isdigit(c));
+		} while ((c = lgetc(0)) != EOF && (isdigit(c) || c == 'x'));
 		lungetc(c);
 		if (p == buf + 1 && buf[0] == '-')
 			goto nodigits;
 		if (c == EOF || allowed_to_end_number(c)) {
-			const char *errstr = NULL;
+			char *ep;
 
 			*p = '\0';
-			yylval.v.num = strtonum(buf, INT64_MIN, INT64_MAX,
-			    &errstr);
-			if (errstr) {
-				yyerror("\"%s\" invalid number: %s",
-				    buf, errstr);
+			errno = 0;
+			yylval.v.num = strtoll(buf, &ep, 0);
+			if (*ep != '\0' || errno == ERANGE &&
+			    (yylval.v.num == LONG_MAX ||
+			    yylval.v.num == LONG_MIN)) {
+				yyerror("\"%s\" invalid number or out of range",
+				    buf);
 				return findeol();
 			}
+
 			return NUMBER;
 		} else {
 nodigits: