summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2009-11-23 15:46:24 -0800
committerKaz Kylheku <kaz@kylheku.com>2009-11-23 15:46:24 -0800
commitb6f5aadfccea8bccadd6c56b57fe6f6b80cfc213 (patch)
treecd71b8fefd57c2c1d4d6e9f7f3a633575f26b03b /parser.l
parent4a1556a848c5bfb527cecb2b823a750ba63e6f80 (diff)
downloadtxr-b6f5aadfccea8bccadd6c56b57fe6f6b80cfc213.tar.gz
txr-b6f5aadfccea8bccadd6c56b57fe6f6b80cfc213.tar.bz2
txr-b6f5aadfccea8bccadd6c56b57fe6f6b80cfc213.zip
Improving portability. It is no longer assumed that pointers
can be converted to a type long and vice versa. The configure script tries to detect the appropriate type to use. Also, some run-time checking is performed in the streams module to detect which conversions specifier strings to use for printing numbers.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l10
1 files changed, 7 insertions, 3 deletions
diff --git a/parser.l b/parser.l
index 564f9730..433c0489 100644
--- a/parser.l
+++ b/parser.l
@@ -34,8 +34,9 @@
#include <errno.h>
#include <dirent.h>
#include <wchar.h>
-#include "y.tab.h"
+#include "config.h"
#include "lib.h"
+#include "y.tab.h"
#include "gc.h"
#include "stream.h"
#include "utf8.h"
@@ -58,7 +59,7 @@
val yyin_stream;
-long lineno = 1;
+cnum lineno = 1;
int opt_loglevel = 1; /* 0 - quiet; 1 - normal; 2 - verbose */
int opt_nobindings = 0;
int opt_arraydims = 1;
@@ -190,7 +191,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
%%
<SPECIAL,NESTED>{TOK} {
- long val;
+ cnum val;
char *errp;
@@ -217,6 +218,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
&& errno == ERANGE)
yyerror("numeric overflow in token");
+ if (val < NUM_MIN || val > NUM_MAX)
+ yyerror("numeric overflow in token");
+
yylval.num = val;
return NUMBER;
}