Hello,
I was running my application which uses SQLite in debug mode, and I noticed some very bizarre behaviour in this function:
 

static void upperFunc(sqlite_func *context, int argc, const char **argv){

char *z;

int i;

if( argc<1 || argv[0]==0 ) return;

z = sqlite_set_result_string(context, argv[0], -1);

if( z==0 ) return;

for(i=0; z[i]; i++){

if( islower(z[i]) ) z[i] = toupper(z[i]);

}

}

The character in question was the pound sign ('£') whose value the debugger said was -93 (the watch window however said 163).  It seems that inside my implementation of islower, it does the following assertion:
 
_ASSERTE((unsigned)(c + 1) <= 256);
 
Now as the character is passed in as an integer, this gets converted from -93 to 4 million something, and fails.  Is this expected / acceptable?  It blows up my application!
 
As an aside, it is more performant to call islower() and then decide whether to call toupper()?  Surely this results in n calls to islower() and some calls to toupper(), whereas simply calling toupper() would result in n calls, and it obviously does the same checking inside this function?
 
Regards,
Steve

 

Reply via email to