about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-08-29T11·30+0200
committerGitHub <noreply@github.com>2018-08-29T11·30+0200
commit20d74a3257c89ab9d5c1cac15fbe2b2aa4d73450 (patch)
treef588d38ae1367f17aae1fcc29b384288d7d51026
parent54df4bb0b5d45a17945d8c4b0e38cd4ae167a732 (diff)
parent0ad643ed5c9642738a8e8b37b7e4b1835f160bc8 (diff)
Merge pull request #2378 from aszlig/int64
libexpr: Use int64_t for NixInt
-rw-r--r--src/libexpr/lexer.l8
-rw-r--r--src/libexpr/value.hh2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 29ca327c1e4e..a052447d3dce 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -12,6 +12,8 @@
 
 
 %{
+#include <boost/lexical_cast.hpp>
+
 #include "nixexpr.hh"
 #include "parser-tab.hh"
 
@@ -124,9 +126,11 @@ or          { return OR_KW; }
 
 {ID}        { yylval->id = strdup(yytext); return ID; }
 {INT}       { errno = 0;
-              yylval->n = strtol(yytext, 0, 10);
-              if (errno != 0)
+              try {
+                  yylval->n = boost::lexical_cast<int64_t>(yytext);
+              } catch (const boost::bad_lexical_cast &) {
                   throw ParseError(format("invalid integer '%1%'") % yytext);
+              }
               return INT;
             }
 {FLOAT}     { errno = 0;
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 809772f7c084..e1ec87d3b84c 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -43,7 +43,7 @@ class XMLWriter;
 class JSONPlaceholder;
 
 
-typedef long NixInt;
+typedef int64_t NixInt;
 typedef double NixFloat;
 
 /* External values must descend from ExternalValueBase, so that