Commit 80a49e59 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Cast or convert <ctype.h> functions it parameters to unsigned char

parent 487b7594
......@@ -204,11 +204,12 @@ static inline int vlc_UrlIsNotEncoded( const char *psz_url )
for( ptr = psz_url; *ptr; ptr++ )
{
char c = *ptr;
unsigned char c = *ptr;
if( c == '%' )
{
if( !isxdigit( ptr[1] ) || !isxdigit( ptr[2] ) )
if( !isxdigit( (unsigned char)ptr[1] )
|| !isxdigit( (unsigned char)ptr[2] ) )
return 1; /* not encoded */
ptr += 2;
}
......
......@@ -244,7 +244,7 @@ static void *Thread( void *p_data )
HANDLE( MEDIA_NEXT_TRACK );
default:
i_vk = toupper( i_key & ~KEY_MODIFIER );
i_vk = toupper( (uint8_t)(i_key & ~KEY_MODIFIER) );
break;
}
if( !i_vk ) continue;
......
......@@ -77,21 +77,21 @@ static int load_byte( unsigned char encoding_type,
if( encoding_type == 1 )
{
if( isxdigit( **input ) == 0 )
if( isxdigit( (unsigned char)**input ) == 0 )
return -1;
if( isdigit( **input ) == 0 )
*output = (toupper( **input ) - 7) * 16;
if( isdigit( (unsigned char)**input ) == 0 )
*output = (toupper( (unsigned char)**input ) - 7) * 16;
else
*output = **input * 16;
(*input)++;
if( isxdigit( **input ) == 0 )
if( isxdigit( (unsigned char)**input ) == 0 )
return -1;
if( isdigit( **input ) == 0 )
*output |= toupper( **input ) - 0x37;
if( isdigit( (unsigned char)**input ) == 0 )
*output |= toupper( (unsigned char)**input ) - 0x37;
else
*output |= **input - 0x30;
......
......@@ -125,7 +125,7 @@ static int ParseTime(char *s, size_t i_strlen)
s = SkipBlanks(s, i_strlen);
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......@@ -145,7 +145,7 @@ static int ParseTime(char *s, size_t i_strlen)
s = SkipBlanks(s, end-s);
result = result * 60;
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......@@ -165,7 +165,7 @@ static int ParseTime(char *s, size_t i_strlen)
s = SkipBlanks(s, end-s);
result = result * 60;
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......
......@@ -198,7 +198,7 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
goto uri;
#if defined( WIN32 ) || defined( __OS2__ )
/* Drive letter (this assumes URL scheme are not a single character) */
if( isalpha(psz_mrl[0]) && psz_mrl[1] == ':' )
if( isalpha((unsigned char)psz_mrl[0]) && psz_mrl[1] == ':' )
goto uri;
#endif
if( strstr( psz_mrl, "://" ) )
......
......@@ -138,7 +138,7 @@ static int ParseTime( const char *s, size_t i_strlen)
s = SkipBlanks(s, i_strlen);
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......@@ -158,7 +158,7 @@ static int ParseTime( const char *s, size_t i_strlen)
s = SkipBlanks(s, end-s);
result = result * 60;
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......@@ -178,7 +178,7 @@ static int ParseTime( const char *s, size_t i_strlen)
s = SkipBlanks(s, end-s);
result = result * 60;
val = 0;
while( (s < end) && isdigit(*s) )
while( (s < end) && isdigit((unsigned char)*s) )
{
int newval = val*10 + (*s - '0');
if( newval < val )
......
......@@ -1626,10 +1626,10 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
strcpy( psz_text, s );
switch( toupper( psz_text[1] ) )
switch( toupper( (unsigned char)psz_text[1] ) )
{
case 'S':
shift = isalpha( psz_text[2] ) ? 6 : 2 ;
shift = isalpha( (unsigned char)psz_text[2] ) ? 6 : 2 ;
if( sscanf( &psz_text[shift], "%d", &h ) )
{
......@@ -1666,7 +1666,7 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
break;
case 'T':
shift = isalpha( psz_text[2] ) ? 8 : 2 ;
shift = isalpha( (unsigned char)psz_text[2] ) ? 8 : 2 ;
sscanf( &psz_text[shift], "%d", &p_sys->jss.i_time_resolution );
break;
......@@ -1710,7 +1710,7 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
while( *psz_text == ' ' || *psz_text == '\t' ) psz_text++;
/* Parse the directives */
if( isalpha( *psz_text ) || *psz_text == '[' )
if( isalpha( (unsigned char)*psz_text ) || *psz_text == '[' )
{
while( *psz_text != ' ' )
{ psz_text++ ;};
......@@ -1767,8 +1767,8 @@ static int ParseJSS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
psz_text2++;
break;
}
if( ( toupper(*(psz_text + 1 ) ) == 'C' ) ||
( toupper(*(psz_text + 1 ) ) == 'F' ) )
if( ( toupper((unsigned char)*(psz_text + 1 ) ) == 'C' ) ||
( toupper((unsigned char)*(psz_text + 1 ) ) == 'F' ) )
{
psz_text++; psz_text++;
break;
......
......@@ -71,7 +71,7 @@ void IniFile::parseFile()
// Convert to lower case because of some buggy winamp2 skins
for( size_t i = 0; i < name.size(); i++ )
{
name[i] = tolower( name[i] );
name[i] = tolower( (unsigned char)name[i] );
}
// Register the value in the var manager
......
......@@ -191,7 +191,7 @@ bool ThemeLoader::extractFileInZip( unzFile file, const string &rootDir,
// use the wrong case...
if( isWsz )
for( size_t i = 0; i < strlen( filenameInZip ); i++ )
filenameInZip[i] = tolower( filenameInZip[i] );
filenameInZip[i] = tolower( (unsigned char)filenameInZip[i] );
// Allocate the buffer
void *pBuffer = malloc( ZIP_BUFFER_SIZE );
......
......@@ -168,8 +168,8 @@ void ThemeRepository::parseDirectory( const string &rDir_locale )
string shortname = name.substr( 0, name.size() - 4 );
for( string::size_type i = 0; i < shortname.size(); i++ )
shortname[i] = ( i == 0 ) ?
toupper( shortname[i] ) :
tolower( shortname[i] );
toupper( (unsigned char)shortname[i] ) :
tolower( (unsigned char)shortname[i] );
m_skinsMap[shortname] = path;
msg_Dbg( getIntf(), "found skin %s", path.c_str() );
......
......@@ -262,7 +262,7 @@ LRESULT CALLBACK Win32Loop::processEvent( HWND hwnd, UINT msg,
if( !key )
{
// This appears to be a "normal" (ascii) key
key = tolower( MapVirtualKey( wParam, 2 ) );
key = tolower( (unsigned char)MapVirtualKey( wParam, 2 ) );
}
if( key )
......
......@@ -190,7 +190,7 @@ static void SetLanguage( sout_stream_t *p_stream, char *psz_language )
if ( strncmp( p_sys->psz_language, psz_language, 3 ) )
msg_Dbg( p_stream, "changing language to %s", psz_language );
strncpy( p_sys->psz_language, psz_language, 3 );
strncpy( p_sys->psz_language, (const char *)psz_language, 3 );
}
/*****************************************************************************
......
......@@ -887,7 +887,8 @@ char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url )
sdp_AddAttribute( &psz_sdp, "setup", "passive" );
if( p_sys->proto == IPPROTO_DCCP )
sdp_AddAttribute( &psz_sdp, "dccp-service-code",
"SC:RTP%c", toupper( mime_major[0] ) );
"SC:RTP%c",
toupper( (unsigned char)mime_major[0] ) );
}
}
out:
......
......@@ -60,7 +60,7 @@ char *BufferGetToken( buffer_t *p_buffer )
{
char *p_char = p_buffer->p_begin;
while( isspace( p_char[0] ) || p_char[0] == '\0' )
while( isspace( (unsigned char)p_char[0] ) || p_char[0] == '\0' )
{
if( p_char <= (p_buffer->p_begin + p_buffer->i_length) )
p_char++;
......
......@@ -78,7 +78,7 @@ static int skip_space( char **psz_command )
{
char *psz_temp = *psz_command;
while( isspace( *psz_temp ) )
while( isspace( (unsigned char)*psz_temp ) )
{
++psz_temp;
}
......@@ -120,32 +120,32 @@ static int parser_DataSharedMem( char *psz_command,
{
/* Parse: 0 128 128 RGBA 9404459 */
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_width ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_height ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isascii( *psz_command ) )
if( isascii( (unsigned char)*psz_command ) )
{
if( parse_char( &psz_command, &psz_end, 4, (char*)&p_params->fourcc )
== VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_shmid ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -158,7 +158,7 @@ static int parser_Id( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -180,13 +180,13 @@ static int parser_SetAlpha( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_alpha ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -199,19 +199,19 @@ static int parser_SetPosition( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_x ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_y ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -224,13 +224,13 @@ static int parser_SetTextAlpha( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->fontstyle.i_font_alpha ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -245,25 +245,25 @@ static int parser_SetTextColor( char *psz_command, char *psz_end,
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &r ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &g ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &b ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -277,13 +277,13 @@ static int parser_SetTextSize( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->fontstyle.i_font_size ) == VLC_EGENERIC )
return VLC_EGENERIC;
......@@ -296,13 +296,13 @@ static int parser_SetVisibility( char *psz_command, char *psz_end,
{
VLC_UNUSED(psz_end);
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
return VLC_EGENERIC;
}
skip_space( &psz_command );
if( isdigit( *psz_command ) )
if( isdigit( (unsigned char)*psz_command ) )
{
int32_t i_vis = 0;
if( parse_digit( &psz_command, &i_vis ) == VLC_EGENERIC )
......
......@@ -367,7 +367,7 @@ static void *EventThread( void *p_this )
if( !i_key )
{
/* This appears to be a "normal" (ascii) key */
i_key = tolower( MapVirtualKey( msg.wParam, 2 ) );
i_key = tolower( (unsigned char)MapVirtualKey( msg.wParam, 2 ) );
}
if( i_key )
......
......@@ -3115,24 +3115,24 @@ static void MRLSections( input_thread_t *p_input, char *psz_source,
/* Check we are really dealing with a title/chapter section */
psz_check = psz + 1;
if( !*psz_check ) return;
if( isdigit(*psz_check) )
if( isdigit((unsigned char)*psz_check) )
if(!next(&psz_check)) return;
if( *psz_check != ':' && *psz_check != '-' && *psz_check ) return;
if( *psz_check == ':' && ++psz_check )
{
if( isdigit(*psz_check) )
if( isdigit((unsigned char)*psz_check) )
if(!next(&psz_check)) return;
}
if( *psz_check != '-' && *psz_check ) return;
if( *psz_check == '-' && ++psz_check )
{
if( isdigit(*psz_check) )
if( isdigit((unsigned char)*psz_check) )
if(!next(&psz_check)) return;
}
if( *psz_check != ':' && *psz_check ) return;
if( *psz_check == ':' && ++psz_check )
{
if( isdigit(*psz_check) )
if( isdigit((unsigned char)*psz_check) )
if(!next(&psz_check)) return;
}
if( *psz_check ) return;
......
......@@ -66,22 +66,24 @@ static const char const sub_exts[][6] = {
static void strcpy_trim( char *d, const char *s )
{
unsigned char c;
/* skip leading whitespace */
while( *s && !isalnum(*s) )
while( ((c = *s) != '\0') && !isalnum(c) )
{
s++;
}
for(;;)
{
/* copy word */
while( *s && isalnum(*s) )
while( ((c = *s) != '\0') && isalnum(c) )
{
*d = tolower(*s);
*d = tolower(c);
s++; d++;
}
if( *s == 0 ) break;
/* trim excess whitespace */
while( *s && !isalnum(*s) )
while( ((c = *s) != '\0') && !isalnum(c) )
{
s++;
}
......@@ -93,6 +95,8 @@ static void strcpy_trim( char *d, const char *s )
static void strcpy_strip_ext( char *d, const char *s )
{
unsigned char c;
const char *tmp = strrchr(s, '.');
if( !tmp )
{
......@@ -101,9 +105,9 @@ static void strcpy_strip_ext( char *d, const char *s )
}
else
strlcpy(d, s, tmp - s + 1 );
while( *d )
while( (c = *d) != '\0' )
{
*d = tolower(*d);
*d = tolower(c);
d++;
}
}
......@@ -119,9 +123,11 @@ static void strcpy_get_ext( char *d, const char *s )
static int whiteonly( const char *s )
{
while( *s )
unsigned char c;
while( (c = *s) != '\0' )
{
if( isalnum( *s ) )
if( isalnum( c ) )
return 0;
s++;
}
......
......@@ -695,13 +695,15 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
psz_mux = p_cfg->vod.psz_mux;
es_format_t es, *p_es = &es;
union { char text[5]; uint32_t value; } fourcc;
union {
char text[5];
unsigned char utext[5];
uint32_t value;
} fourcc;
sprintf( fourcc.text, "%4.4s", psz_mux );
fourcc.text[0] = tolower(fourcc.text[0]);
fourcc.text[1] = tolower(fourcc.text[1]);
fourcc.text[2] = tolower(fourcc.text[2]);
fourcc.text[3] = tolower(fourcc.text[3]);
for( int i = 0; i < 4; i++ )
fourcc.utext[i] = tolower(fourcc.utext[i]);
item.i_es = 1;
item.es = &p_es;
......
......@@ -80,7 +80,7 @@ static const char quotes[] = "\"'";
*/
static const char *FindCommandEnd( const char *psz_sent )
{
char c, quote = 0;
unsigned char c, quote = 0;
while( (c = *psz_sent) != '\0' )
{
......@@ -127,7 +127,7 @@ static const char *FindCommandEnd( const char *psz_sent )
*/
static int Unescape( char *out, const char *in )
{
char c, quote = 0;
unsigned char c, quote = 0;
bool param = false;
while( (c = *in++) != '\0' )
......@@ -856,7 +856,7 @@ int ExecuteCommand( vlm_t *p_vlm, const char *psz_command,
{
const char *psz_temp;
if(isspace (*psz_command))
if(isspace ((unsigned char)*psz_command))
{
psz_command++;
continue;
......
......@@ -322,7 +322,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
psz_ip = line;
/* skips blanks - cannot overflow given '\0' is not space */
while( isspace( *psz_ip ) )
while( isspace( (unsigned char)*psz_ip ) )
psz_ip++;
if( *psz_ip == '\0' ) /* empty/blank line */
......@@ -351,7 +351,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
}
/* look for first space, CR, LF, etc. or comment character */
for( ptr = psz_ip; ( *ptr!='#' ) && !isspace( *ptr ) && *ptr; ++ptr );
for( ptr = psz_ip; ( *ptr!='#' ) && !isspace( (unsigned char)*ptr ) && *ptr; ++ptr );
*ptr = '\0';
......
......@@ -1079,7 +1079,7 @@ char *make_URI (const char *path, const char *scheme)
char *buf;
#if defined( WIN32 ) || defined( __OS2__ )
/* Drive letter */
if (isalpha (path[0]) && (path[1] == ':'))
if (isalpha ((unsigned char)path[0]) && (path[1] == ':'))
{
if (asprintf (&buf, "%s:///%c:", scheme ? scheme : "file",
path[0]) == -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment