jam: Fix isspace/isalnum/tolower/... usage

The value passed in must be representable as an unsigned char or equal
to the value of the macro EOF. NetBSD 11+ is actually enforcing this.

Change-Id: I9a7eada7c0c1ae206aa6810027a2b02742b72934
Reviewed-on: https://review.haiku-os.org/c/buildtools/+/10127
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Christof Meerwald
2025-12-17 16:39:43 +00:00
committed by Adrien Destugues
parent 7ab022f6e6
commit 13c7a4265a
7 changed files with 16 additions and 15 deletions

View File

@@ -154,12 +154,12 @@ execcmd(
/* Trim leading, ending white space */ /* Trim leading, ending white space */
while( isspace( *string ) ) while( isspace( (unsigned char)*string ) )
++string; ++string;
p = strchr( string, '\n' ); p = strchr( string, '\n' );
while( p && isspace( *p ) ) while( p && isspace( (unsigned char)*p ) )
++p; ++p;
/* If multi line, or too long, or JAMSHELL is set, write to bat file. */ /* If multi line, or too long, or JAMSHELL is set, write to bat file. */

View File

@@ -538,11 +538,11 @@ var_edit_shift(
if( edits->upshift ) if( edits->upshift )
{ {
for( ; *out; ++out ) for( ; *out; ++out )
*out = toupper( *out ); *out = toupper( (unsigned char)*out );
} }
else if( edits->downshift ) else if( edits->downshift )
{ {
for( ; *out; ++out ) for( ; *out; ++out )
*out = tolower( *out ); *out = tolower( (unsigned char)*out );
} }
} }

View File

@@ -35,7 +35,7 @@ getoptions(
{ {
char *arg; char *arg;
if( argv[i][0] != '-' || !isalpha( argv[i][1] ) ) if( argv[i][0] != '-' || !isalpha( (unsigned char)argv[i][1] ) )
break; break;
if( !optc-- ) if( !optc-- )

View File

@@ -917,16 +917,16 @@ regmatch( char *prog )
break; break;
case WORDA: case WORDA:
/* Must be looking at a letter, digit, or _ */ /* Must be looking at a letter, digit, or _ */
if ((!isalnum(*reginput)) && *reginput != '_') if ((!isalnum((unsigned char)*reginput)) && *reginput != '_')
return(0); return(0);
/* Prev must be BOL or nonword */ /* Prev must be BOL or nonword */
if (reginput > regbol && if (reginput > regbol &&
(isalnum(reginput[-1]) || reginput[-1] == '_')) (isalnum((unsigned char)reginput[-1]) || reginput[-1] == '_'))
return(0); return(0);
break; break;
case WORDZ: case WORDZ:
/* Must be looking at non letter, digit, or _ */ /* Must be looking at non letter, digit, or _ */
if (isalnum(*reginput) || *reginput == '_') if (isalnum((unsigned char)*reginput) || *reginput == '_')
return(0); return(0);
/* We don't care what the previous char was */ /* We don't care what the previous char was */
break; break;

View File

@@ -287,7 +287,7 @@ yylex()
{ {
/* Skip past white space */ /* Skip past white space */
while( c != EOF && isspace( c ) ) while( c != EOF && isspace( (unsigned char)c ) )
c = yychar(); c = yychar();
/* Not a comment? Swallow up comment line. */ /* Not a comment? Swallow up comment line. */
@@ -315,7 +315,7 @@ yylex()
while( while(
c != EOF && c != EOF &&
b < buf + sizeof( buf ) && b < buf + sizeof( buf ) &&
( inquote || !isspace( c ) ) ) ( inquote || !isspace( (unsigned char)c ) ) )
{ {
if( c == '"' ) if( c == '"' )
{ {
@@ -369,7 +369,8 @@ yylex()
*b = 0; *b = 0;
yylval.type = ARG; yylval.type = ARG;
if( !notkeyword && !( isalpha( *buf ) && scanmode == SCAN_PUNCT ) ) if( !notkeyword &&
!( isalpha( (unsigned char)*buf ) && scanmode == SCAN_PUNCT ) )
{ {
for( k = keywords; k->word; k++ ) for( k = keywords; k->word; k++ )
if( *buf == *k->word && !strcmp( k->word, buf ) ) if( *buf == *k->word && !strcmp( k->word, buf ) )

View File

@@ -72,7 +72,7 @@ timestamp(
char path[ MAXJPATH ]; char path[ MAXJPATH ];
char *p = path; char *p = path;
do *p++ = tolower( *target ); do *p++ = tolower( (unsigned char)*target );
while( *target++ ); while( *target++ );
target = path; target = path;
@@ -175,7 +175,7 @@ time_enter(
char path[ MAXJPATH ]; char path[ MAXJPATH ];
char *p = path; char *p = path;
do *p++ = tolower( *target ); do *p++ = tolower( (unsigned char)*target );
while( *target++ ); while( *target++ );
target = path; target = path;

View File

@@ -152,7 +152,7 @@ var_string(
/* Copy white space */ /* Copy white space */
while( isspace( *in ) ) while( isspace( (unsigned char)*in ) )
{ {
if( out >= oute ) if( out >= oute )
return -1; return -1;
@@ -164,7 +164,7 @@ var_string(
/* Copy non-white space, watching for variables */ /* Copy non-white space, watching for variables */
while( *in && !isspace( *in ) ) while( *in && !isspace( (unsigned char)*in ) )
{ {
if( out >= oute ) if( out >= oute )
return -1; return -1;