summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2002-07-08 07:10:08 +0000
committerMichi Henning <michi@zeroc.com>2002-07-08 07:10:08 +0000
commit744e044abfaad2976a27fe1d45c528fb86dd661a (patch)
tree0017f272583b8d5dd8935e67f343d35d6d9d43b2 /cpp/src
parentFinal tidy-up of stringToInt64(). (diff)
downloadice-744e044abfaad2976a27fe1d45c528fb86dd661a.tar.bz2
ice-744e044abfaad2976a27fe1d45c528fb86dd661a.tar.xz
ice-744e044abfaad2976a27fe1d45c528fb86dd661a.zip
Changed parser to use new strToInt64() function. Makes for much cleaner
code.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/GrammarUtil.h2
-rw-r--r--cpp/src/Slice/Parser.cpp12
-rw-r--r--cpp/src/Slice/Scanner.l23
3 files changed, 11 insertions, 26 deletions
diff --git a/cpp/src/Slice/GrammarUtil.h b/cpp/src/Slice/GrammarUtil.h
index a3fc29b74d2..e3204a85047 100644
--- a/cpp/src/Slice/GrammarUtil.h
+++ b/cpp/src/Slice/GrammarUtil.h
@@ -98,7 +98,7 @@ class SLICE_API IntegerTok : public GrammarBase
public:
IntegerTok() { }
- Long v;
+ IceUtil::Int64 v;
};
// ----------------------------------------------------------------------
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 0b5393ea03d..206a2c0b486 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -1594,8 +1594,8 @@ Slice::Container::checkRange(const string& name, const TypePtr& constType, const
{
case Builtin::KindByte:
{
- Long l = STRTOLL(value.c_str(), 0, 0);
- if(l < BYTE_MIN || l > BYTE_MAX)
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < BYTEMIN || l > BYTEMAX)
{
string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type byte";
_unit->error(msg);
@@ -1605,8 +1605,8 @@ Slice::Container::checkRange(const string& name, const TypePtr& constType, const
}
case Builtin::KindShort:
{
- Long l = STRTOLL(value.c_str(), 0, 0);
- if(l < INT16_MIN || l > INT16_MAX)
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < INT16MIN || l > INT16MAX)
{
string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type short";
_unit->error(msg);
@@ -1616,8 +1616,8 @@ Slice::Container::checkRange(const string& name, const TypePtr& constType, const
}
case Builtin::KindInt:
{
- Long l = STRTOLL(value.c_str(), 0, 0);
- if(l < INT32_MIN || l > INT32_MAX)
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < INT32MIN || l > INT32MAX)
{
string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type int";
_unit->error(msg);
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index ea280da5d96..c92ea37b5ec 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -12,6 +12,7 @@
#include <Slice/GrammarUtil.h> // Before Grammer.h, so that YYSTYPE is defined
#include <Slice/Grammar.h>
+#include <IceUtil/InputUtil.h>
#include <stdlib.h>
#include <math.h>
@@ -257,7 +258,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{exponent
}
case 'x':
{
- Long ull = 0;
+ IceUtil::Int64 ull = 0;
while(isxdigit(next = static_cast<char>(yyinput())))
{
ull *= 16;
@@ -301,30 +302,14 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{exponent
IntegerTokPtr itp = new IntegerTok;
*yylvalp = itp;
errno = 0;
-#if defined(_WIN32)
- itp->v = _atoi64(yytext);
- if(itp->v == 0) // Poor error reporting for _atoi64(), so we have to do it the hard way...
- {
- errno = 0;
- long l = strtol(yytext, 0, 0);
- if(l != 0 || errno != 0) // _atoi64() returned zero even though yytext wasn't all zeros
- {
- string msg = "integer constant `";
- msg += yytext;
- msg += "' out of range";
- unit->error(msg);
- }
- }
-#else
- itp->v = strtoll(yytext, 0, 0);
- if(errno == ERANGE && (itp->v == INT64_MIN || itp->v == INT64_MAX))
+ itp->v = IceUtil::strToInt64(yytext, 0, 0);
+ if(errno == ERANGE && (itp->v == IceUtil::INT64MIN || itp->v == IceUtil::INT64MAX))
{
string msg = "integer constant `";
msg += yytext;
msg += "' out of range";
unit->error(msg);
}
-#endif
return ICE_INTEGER_LITERAL;
}