diff options
author | Bernard Normier <bernard@zeroc.com> | 2005-06-20 16:21:03 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2005-06-20 16:21:03 +0000 |
commit | f0b637b46a2aa6f81d610618dd9543001d25eead (patch) | |
tree | e39088b8b026afbee659fc546157040f70dabe4a /cpp/src/IceUtil/InputUtil.cpp | |
parent | Readded toString() (diff) | |
download | ice-f0b637b46a2aa6f81d610618dd9543001d25eead.tar.bz2 ice-f0b637b46a2aa6f81d610618dd9543001d25eead.tar.xz ice-f0b637b46a2aa6f81d610618dd9543001d25eead.zip |
Bug fix for bug #377
Diffstat (limited to 'cpp/src/IceUtil/InputUtil.cpp')
-rw-r--r-- | cpp/src/IceUtil/InputUtil.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp index 71829afc1f4..39de0ac168e 100644 --- a/cpp/src/IceUtil/InputUtil.cpp +++ b/cpp/src/IceUtil/InputUtil.cpp @@ -43,20 +43,19 @@ static IceUtil::Int64 strToInt64Impl(const char* s, char** endptr, int base) { // - // Skip leading whitespace + // Assume nothing will be there to convert for now // - const char* start = s.c_str(); - while(*start && isspace(*start)) + if(endptr) { - ++start; + *endptr = const_cast<char *>(s); } // - // Assume nothing will be there to convert for now + // Skip leading whitespace // - if(endptr) + while(*s && isspace(*s)) { - *endptr = const_cast<char *>(s); + ++s; } // @@ -81,7 +80,20 @@ strToInt64Impl(const char* s, char** endptr, int base) if(*s == '0') { base = 8; - if(*++s == 'x' || *s == 'X') + ++s; + + if(*s == '\0') + { + // + // Just '0' + // + if(endptr) + { + *endptr = const_cast<char *>(s); + } + return 0; + } + else if(*s == 'x' || *s == 'X') { base = 16; ++s; @@ -103,10 +115,9 @@ strToInt64Impl(const char* s, char** endptr, int base) // if(*s == '\0') { - if(endptr) - { - *endptr = const_cast<char*>(s); - } + // + // We did not read any digit so we don't update endptr + // return 0; } @@ -153,7 +164,7 @@ strToInt64Impl(const char* s, char** endptr, int base) { *endptr = const_cast<char *>(s); } - + return result; } @@ -181,15 +192,7 @@ strToInt64(const char* s, char** endptr, int base) bool stringToInt64(const string& s, Int64& result) { - // - // Skip leading whitespace - // const char* start = s.c_str(); - while(*start && isspace(*start)) - { - ++start; - } - char* end = 0; errno = 0; result = strToInt64(start, &end, 0); |