Fix sqlite3Atoi64 to return true if handed a number of all zeros. The

failure to do this is benign as sqlite3Atoi64() is current used, but that
might change in the future so it is good to go ahead and fix the function
to return the correct result. (CVS 5142)

FossilOrigin-Name: bc90787583dd2dadff72d516de9720d4a36e7fd2
This commit is contained in:
drh 2008-05-19 15:54:59 +00:00
parent 9a855cf852
commit 4b81592a28
3 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C In\sthe\sCLI,\shandle\sthe\scompilation\soption\s-DOS_OS2=0\scorrectly.\s(CVS\s5141)
D 2008-05-19T15:53:35
C Fix\ssqlite3Atoi64\sto\sreturn\strue\sif\shanded\sa\snumber\sof\sall\szeros.\s\sThe\nfailure\sto\sdo\sthis\sis\sbenign\sas\ssqlite3Atoi64()\sis\scurrent\sused,\sbut\sthat\nmight\schange\sin\sthe\sfuture\sso\sit\sis\sgood\sto\sgo\sahead\sand\sfix\sthe\sfunction\nto\sreturn\sthe\scorrect\sresult.\s(CVS\s5142)
D 2008-05-19T15:54:59
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 79aeba12300a54903f1b1257c1e7c190234045dd
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -165,7 +165,7 @@ F src/tokenize.c 8d77af8584cf027dc21375f0efa5818cb303c995
F src/trigger.c 1e751f8d5ceeb328d26bf1ccfb2de50653670d49
F src/update.c 2d7143b9014e955509cc4f323f9a9584fb898f34
F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c 28fb90e03f83b95f6e8b1978fb60953e6cef9e3a
F src/util.c 43277088f8fea4109a640aa46731b8752c3fb4a7
F src/vacuum.c c3b2b70677f874102b8753bf494c232e777f3998
F src/vdbe.c 25a362a4fdd5ff2797db0e20a9cf4300e053891e
F src/vdbe.h f4bb70962d9c13e0f65b215c90e8acea1ae6e8ee
@ -636,7 +636,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 97ed2dd1dc9d8e8f837914277c080160d319591b
R 22a96c9f6a9a05eec3ea2d9122c497a4
P 70793be63c0c6dab42d48c096e0e051e37d7e788
R 8b6a62c0e12ab6eb68cfbdd48cce346b
U drh
Z 1ef1d4005a15344dec819eb5379b60a1
Z 91f6e64dddd67b37f9decbab5419e693

View File

@ -1 +1 @@
70793be63c0c6dab42d48c096e0e051e37d7e788
bc90787583dd2dadff72d516de9720d4a36e7fd2

View File

@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.229 2008/05/13 16:41:50 drh Exp $
** $Id: util.c,v 1.230 2008/05/19 15:54:59 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@ -366,6 +366,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum){
i64 v = 0;
int neg;
int i, c;
const char *zStart;
while( isspace(*(u8*)zNum) ) zNum++;
if( *zNum=='-' ){
neg = 1;
@ -376,12 +377,13 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum){
}else{
neg = 0;
}
zStart = zNum;
while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */
for(i=0; (c=zNum[i])>='0' && c<='9'; i++){
v = v*10 + c - '0';
}
*pNum = neg ? -v : v;
if( c!=0 || i==0 || i>19 ){
if( c!=0 || (i==0 && zStart==zNum) || i>19 ){
/* zNum is empty or contains non-numeric text or is longer
** than 19 digits (thus guaranting that it is too large) */
return 0;