summaryrefslogtreecommitdiff
path: root/3rdparty/libconfig/extra/gen/scanner.l
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/libconfig/extra/gen/scanner.l')
-rw-r--r--3rdparty/libconfig/extra/gen/scanner.l47
1 files changed, 28 insertions, 19 deletions
diff --git a/3rdparty/libconfig/extra/gen/scanner.l b/3rdparty/libconfig/extra/gen/scanner.l
index 6bcce8116..f717ac273 100644
--- a/3rdparty/libconfig/extra/gen/scanner.l
+++ b/3rdparty/libconfig/extra/gen/scanner.l
@@ -1,8 +1,8 @@
/* -*- mode: C -*- */
/* --------------------------------------------------------------------------
libconfig - A library for processing structured configuration files
- Copyright (C) 2013-2015 Hercules Dev Team
- Copyright (C) 2005-2010 Mark A Lindner
+ Copyright (C) 2013-2016 Hercules Dev Team
+ Copyright (C) 2005-2014 Mark A Lindner
This file is part of libconfig.
@@ -23,33 +23,30 @@
*/
%option nounistd
+%option never-interactive
%option reentrant
%option noyywrap
%option yylineno
%option nounput
%option bison-bridge
-%option never-interactive
%option header-file="scanner.h"
%option outfile="lex.yy.c"
%option extra-type="struct scan_context *"
-%top{
-#include "scanctx.h"
-}
-
%{
+
#ifdef _MSC_VER
#pragma warning (disable: 4996)
-/* disable MSVC warning "signed/unsigned mismatch" associated with code generated by flex versions such as 2.5.35. */
-#pragma warning (disable:4018)
#endif
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include <limits.h>
+#include "parsectx.h"
+#include "scanctx.h"
#include "grammar.h"
#include "wincompat.h"
-#include "parsectx.h"
#define YY_NO_INPUT // Suppress generation of useless input() function
@@ -87,13 +84,6 @@ static unsigned long long fromhex(const char *s)
#endif /* __MINGW32__ */
}
-static int fromihex(const char *s) {
- unsigned long l = strtoul(s, NULL, 16);
- if (l > INT32_MAX)
- l &= INT32_MAX;
- return (int)l;
-}
-
%}
true [Tt][Rr][Uu][Ee]
@@ -183,9 +173,28 @@ include_open ^[ \t]*@include[ \t]+\"
{true} { yylval->ival = 1; return(TOK_BOOLEAN); }
{false} { yylval->ival = 0; return(TOK_BOOLEAN); }
{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
-{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+{integer} {
+ long long llval;
+ llval = atoll(yytext);
+ if((llval < INT_MIN) || (llval > INT_MAX))
+ {
+ yylval->llval = llval;
+ return(TOK_INTEGER64);
+ }
+ else
+ {
+ yylval->ival = (int)llval;
+ return(TOK_INTEGER);
+ }
+ }
{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
-{hex} { yylval->ival = fromihex(yytext); return(TOK_HEX); }
+{hex} {
+ unsigned long ulval = strtoul(yytext, NULL, 16);
+ if (ulval > INT32_MAX)
+ ulval &= INT32_MAX;
+ yylval->ival = (int)ulval;
+ return(TOK_HEX);
+ }
{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
{name} { yylval->sval = yytext; return(TOK_NAME); }
\[ { return(TOK_ARRAY_START); }