use ctype.h {is,to}{lower,upper} functions

This commit is contained in:
Gwenhael Le Moine 2023-05-04 13:28:44 +02:00
parent 5322be982b
commit 22ea5373b5
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
3 changed files with 11 additions and 24 deletions

View file

@ -2,6 +2,7 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include "resources.h"
#include "disasm.h"
@ -98,7 +99,7 @@ int get_mnemonic_resource( char* name, char* class ) {
if ( !s )
return CLASS_MNEMONICS;
for ( tmp = buf; *s; s++ )
*tmp++ = isupper( *s ) ? _tolower( *s ) : *s;
*tmp++ = isupper( *s ) ? tolower( *s ) : *s;
*tmp = 0;
free( os );
@ -118,7 +119,7 @@ int get_boolean_resource( char* name, char* class ) {
if ( !s )
return 0;
for ( tmp = buf; *s; s++ )
*tmp++ = isupper( *s ) ? _tolower( *s ) : *s;
*tmp++ = isupper( *s ) ? tolower( *s ) : *s;
*tmp = 0;
free( os );
@ -225,7 +226,7 @@ Visual* get_visual_resource( Display* dpy, char* name, char* class,
if ( s )
for ( tmp = s; *tmp; tmp++ )
if ( isupper( *tmp ) )
*tmp = _tolower( *tmp );
*tmp = tolower( *tmp );
if ( !s || !strcmp( s, "default" ) )
vclass = -1;

View file

@ -47,23 +47,8 @@ extern Visual* get_visual_resource( Display* dpy, char* name, char* class,
unsigned int* depth );
extern XFontStruct* get_font_resource( Display* dpy, char* res_name,
char* res_class );
#ifndef isupper
#define isupper( c ) ( ( c ) >= 'A' && ( c ) <= 'Z' )
#endif
#ifndef islower
#define islower( c ) ( ( c ) >= 'a' && ( c ) <= 'z' )
#endif
#ifndef _tolower
#define _tolower( c ) ( ( c ) - 'A' + 'a' )
#endif
#ifndef _toupper
#define _toupper( c ) ( ( c ) - 'a' + 'A' )
#endif
#endif
#if defined( GUI_IS_SDL1 )
void get_resources( void );
#elif defined( GUI_IS_SDL1 )
extern void get_resources( void );
#endif
#endif /* !_RESOURCES_H */

View file

@ -3,9 +3,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/utsname.h>
#if defined( GUI_IS_X11 )
@ -1380,7 +1381,7 @@ int InitDisplay( int argc, char** argv ) {
res_name = progname;
res_class = strdup( res_name );
*res_class = islower( *res_class ) ? _toupper( *res_class ) : *res_class;
*res_class = islower( *res_class ) ? toupper( *res_class ) : *res_class;
/*
* look for argument -name
@ -1393,12 +1394,12 @@ int InitDisplay( int argc, char** argv ) {
}
for ( s = res_name; *s; s++ )
*s = isupper( *s ) ? _tolower( *s ) : *s;
*s = isupper( *s ) ? tolower( *s ) : *s;
free( res_class );
res_class = strdup( res_name );
*res_class =
islower( *res_class ) ? _toupper( *res_class ) : *res_class;
islower( *res_class ) ? toupper( *res_class ) : *res_class;
argc = saved_argc;
argv = ( char** )malloc( ( argc + 1 ) * sizeof( char* ) );