Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4351f88

Browse files
committed
Fix portability bugs: char values passed to <ctype.h> functions must
be cast to unsigned char. We have learned this the hard way before.
1 parent558ed5a commit4351f88

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎src/interfaces/ecpg/compatlib/informix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ rstrdate(char *str, date * d)
464464
for (i=0,j=0;i<10;i++ )
465465
{
466466
/* ignore non-digits */
467-
if (isdigit(str[i]) )
467+
if (isdigit((unsignedchar)str[i]) )
468468
{
469469

470470
/* j only increments if it is a digit */
@@ -910,8 +910,8 @@ void
910910
rupshift(char*str)
911911
{
912912
for (;*str!='\0';str++)
913-
if (islower(*str))
914-
*str=toupper(*str);
913+
if (islower((unsignedchar)*str))
914+
*str=toupper((unsignedchar)*str);
915915
return;
916916
}
917917

‎src/interfaces/ecpg/pgtypeslib/datetime.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
405405
reading_digit=1;
406406
for (i=0;str[i];i++)
407407
{
408-
if (!isdigit(str[i]))
408+
if (!isdigit((unsignedchar)str[i]))
409409
{
410410
reading_digit=0;
411411
break;
@@ -495,22 +495,22 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
495495

496496
/* convert the whole string to lower case */
497497
for (i=0;str_copy[i];i++)
498-
str_copy[i]= (char)tolower(str_copy[i]);
498+
str_copy[i]= (char)tolower((unsignedchar)str_copy[i]);
499499
}
500500

501501
/* look for numerical tokens */
502502
reading_digit=0;
503503
token_count=0;
504504
for (i=0;i<strlen(str_copy);i++)
505505
{
506-
if (!isdigit(str_copy[i])&&reading_digit)
506+
if (!isdigit((unsignedchar)str_copy[i])&&reading_digit)
507507
{
508508
/* the token is finished */
509509
token[token_count][1]=i-1;
510510
reading_digit=0;
511511
token_count++;
512512
}
513-
elseif (isdigit(str_copy[i])&& !reading_digit)
513+
elseif (isdigit((unsignedchar)str_copy[i])&& !reading_digit)
514514
{
515515
/* we have found a token */
516516
token[token_count][0]=i;
@@ -565,7 +565,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
565565
{
566566
for (j=0;j<PGTYPES_DATE_MONTH_MAXLENGTH;j++)
567567
{
568-
month_lower_tmp[j]= (char)tolower(list[i][j]);
568+
month_lower_tmp[j]= (char)tolower((unsignedchar)list[i][j]);
569569
if (!month_lower_tmp[j])
570570
{
571571
/* properly terminated */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp