Fix harmless compiler warning in the totype extension. Include all standard whitespace characters in totypeIsspace. Minor adjustments to style and comments.

FossilOrigin-Name: 73238f655a58c810876f46cc04eab1ac2d5b8ef7
This commit is contained in:
mistachkin 2013-10-14 22:35:40 +00:00
parent 5f8cdac620
commit 0593516fcc
3 changed files with 27 additions and 23 deletions

View File

@ -43,12 +43,12 @@ SQLITE_EXTENSION_INIT1
*/
#if defined(i386) || defined(__i386__) || defined(_M_IX86)\
|| defined(__x86_64) || defined(__x86_64__)
# define SQLITE_BIGENDIAN 0
# define SQLITE_LITTLEENDIAN 1
# define TOTYPE_BIGENDIAN 0
# define TOTYPE_LITTLEENDIAN 1
#else
const int totype_one = 1;
# define SQLITE_BIGENDIAN (*(char *)(&totype_one)==0)
# define SQLITE_LITTLEENDIAN (*(char *)(&totype_one)==1)
# define TOTYPE_BIGENDIAN (*(char *)(&totype_one)==0)
# define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1)
#endif
/*
@ -63,7 +63,7 @@ SQLITE_EXTENSION_INIT1
** Return TRUE if character c is a whitespace character
*/
static int totypeIsspace(unsigned char c){
return c==' ' || c=='\t' || c=='\n' || c=='\r';
return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f' || c=='\r';
}
/*
@ -83,7 +83,7 @@ static int totypeIsdigit(unsigned char c){
** in the values of the last digit if the only difference is in the
** last digit. So, for example,
**
** totypeCompare2pow63("9223372036854775800", 1)
** totypeCompare2pow63("9223372036854775800")
**
** will return -8.
*/
@ -104,16 +104,18 @@ static int totypeCompare2pow63(const char *zNum){
/*
** Convert zNum to a 64-bit signed integer.
**
** If the zNum value is representable as a 64-bit twos-complement
** If the zNum value is representable as a 64-bit twos-complement
** integer, then write that value into *pNum and return 0.
**
** If zNum is exactly 9223372036854665808, return 2. This special
** case is broken out because while 9223372036854665808 cannot be a
** case is broken out because while 9223372036854665808 cannot be a
** signed 64-bit integer, its negative -9223372036854665808 can be.
**
** If zNum is too big for a 64-bit integer and is not
** 9223372036854665808 or if zNum contains any non-numeric text,
** then return 1.
**
** The string is not necessarily zero-terminated.
*/
static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){
sqlite3_uint64 u = 0;
@ -172,12 +174,12 @@ static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){
}
}
}
/*
** The string z[] is an text representation of a real number.
** Convert this string to a double and write it into *pResult.
**
** The string z[] is length bytes in length (bytes, not characters) and
** uses the encoding enc. The string is not necessarily zero-terminated.
** The string is not necessarily zero-terminated.
**
** Return TRUE if the result is a valid real number (or integer) and FALSE
** if the string is empty or contains extraneous text. Valid numbers
@ -321,7 +323,7 @@ totype_atof_calc:
result = 1e308*1e308*s; /* Infinity */
}
}else{
/* 1.0e+22 is the largest power of 10 than can be
/* 1.0e+22 is the largest power of 10 than can be
** represented exactly. */
while( e%22 ) { scale *= 1.0e+1; e -= 1; }
while( e>0 ) { scale *= 1.0e+22; e -= 22; }
@ -374,7 +376,7 @@ static void tointegerFunc(
int nBlob = sqlite3_value_bytes(argv[0]);
if( nBlob==sizeof(sqlite3_int64) ){
sqlite3_int64 iVal;
if( SQLITE_BIGENDIAN ){
if( TOTYPE_BIGENDIAN ){
int i;
unsigned char zBlobRev[sizeof(sqlite3_int64)];
for(i=0; i<sizeof(sqlite3_int64); i++){
@ -415,6 +417,7 @@ static void tointegerFunc(
** real number. Otherwise return NULL.
*/
#if defined(_MSC_VER)
#pragma warning(disable: 4748)
#pragma optimize("", off)
#endif
static void torealFunc(
@ -443,7 +446,7 @@ static void torealFunc(
int nBlob = sqlite3_value_bytes(argv[0]);
if( nBlob==sizeof(double) ){
double rVal;
if( SQLITE_LITTLEENDIAN ){
if( TOTYPE_LITTLEENDIAN ){
int i;
unsigned char zBlobRev[sizeof(double)];
for(i=0; i<sizeof(double); i++){
@ -480,14 +483,15 @@ static void torealFunc(
}
#if defined(_MSC_VER)
#pragma optimize("", on)
#pragma warning(default: 4748)
#endif
#ifdef _WIN32
__declspec(dllexport)
#endif
int sqlite3_totype_init(
sqlite3 *db,
char **pzErrMsg,
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
int rc = SQLITE_OK;

View File

@ -1,5 +1,5 @@
C Move\sthe\stointeger()\sand\storeal()\sfunctions\sout\sof\score\sand\smake\sthem\sinto\na\srun-time\sloadable\sextension.
D 2013-10-14T21:14:42.543
C Fix\sharmless\scompiler\swarning\sin\sthe\stotype\sextension.\s\sInclude\sall\sstandard\swhitespace\scharacters\sin\stotypeIsspace.\s\sMinor\sadjustments\sto\sstyle\sand\scomments.
D 2013-10-14T22:35:40.075
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -115,7 +115,7 @@ F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
F ext/misc/spellfix.c 5e1d547e9a2aed13897fa91bac924333f62fd2d9
F ext/misc/totype.c 368c089adfeabfe3de5fd4b8c581df53743cf6c0
F ext/misc/totype.c 86eeb8efb5c0e1a09d713e4183ff1eda95c8f342
F ext/misc/vfslog.c 1abb192d8d4bd323adbddec0c024580496b51b7a
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
@ -1125,7 +1125,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 0bf438fc30582a08fddfc3cec49366ee17ae2abe
R ade7979aa97b3511bc21cfd9a8979ec2
U drh
Z 602799c8fb404ec8c5a4601c8b4e8f8d
P 9f66dd7e3790c04f0ab724419f5381bd21f9ebad
R f21c7b96aefc2201770b50ac2899ad7e
U mistachkin
Z 42e92dc11d48272f024e4ddd08e08231

View File

@ -1 +1 @@
9f66dd7e3790c04f0ab724419f5381bd21f9ebad
73238f655a58c810876f46cc04eab1ac2d5b8ef7