1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-21 15:01:41 +02:00

Fix for toupper('I') != 'i'

This commit is contained in:
Werner Koch 2001-06-12 18:42:40 +00:00
parent ff170c94f1
commit 01fe1dd2a9
22 changed files with 156 additions and 47 deletions

View File

@ -1,3 +1,8 @@
2001-06-08 Werner Koch <wk@gnupg.org>
* configure.in (DYNLINK_MOD_CFLAGS): Use -shared with dec-osf.
Reported by Chris Adams. Merged some cases.
2001-05-29 Werner Koch <wk@gnupg.org>
Released version 1.0.6.

1
THANKS
View File

@ -21,6 +21,7 @@ Caskey L. Dickson caskey@technocage.com
Cees van de Griend cees-list@griend.xs4all.nl
Charles Levert charles@comm.polymtl.ca
Chip Salzenberg chip@valinux.com
Chris Adams cmadams@hiwaay.net
Christian Kurz shorty@debian.org
Christian von Roques roques@pond.sub.org
Christopher Oliver oliver@fritz.traverse.net

2
TODO
View File

@ -1,4 +1,6 @@
* replace all isfoo() by ascii_usfoo() ?
* set default charset from nl_langinfo.
* check all mpi_read() for error returns.

View File

@ -1,3 +1,11 @@
2001-06-12 Werner Koch <wk@gnupg.org>
* rndw32.c (slow_gatherer_windowsNT): Ditto. Not really needed here but anyway.
* cipher.c (string_to_cipher_algo): Use ascii_strcasecmp().
* md.c (string_to_digest_algo): Ditto.
* pubkey.c (string_to_pubkey_algo): Ditto.
2001-04-29 Werner Koch <wk@gnupg.org>
* random.c (fast_random_poll): Do not check the return code of

View File

@ -258,7 +258,7 @@ string_to_cipher_algo( const char *string )
do {
for(i=0; (s=cipher_table[i].name); i++ )
if( !stricmp( s, string ) )
if( !ascii_strcasecmp( s, string ) )
return cipher_table[i].algo;
} while( load_cipher_modules() );
return 0;

View File

@ -152,7 +152,7 @@ string_to_digest_algo( const char *string )
do {
for(r = digest_list; r; r = r->next )
if( !stricmp( r->name, string ) )
if( !ascii_strcasecmp( r->name, string ) )
return r->algo;
} while( !r && load_digest_module(-1) );
return 0;

View File

@ -296,7 +296,7 @@ string_to_pubkey_algo( const char *string )
do {
for(i=0; (s=pubkey_table[i].name); i++ )
if( !stricmp( s, string ) )
if( !ascii_strcasecmp( s, string ) )
return pubkey_table[i].algo;
} while( load_pubkey_modules() );
return 0;

View File

@ -561,7 +561,8 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester )
log_debug ("rndw32#slow_gatherer_nt: check product options\n" );
status = RegQueryValueEx (hKey, "ProductType", 0, NULL,
szValue, &dwSize);
if (status == ERROR_SUCCESS && stricmp (szValue, "WinNT")) {
if (status == ERROR_SUCCESS
&& ascii_strcasecmp (szValue, "WinNT")) {
/* Note: There are (at least) three cases for ProductType:
* WinNT = NT Workstation, ServerNT = NT Server, LanmanNT =
* NT Server acting as a Domain Controller */

View File

@ -256,25 +256,13 @@ AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME")
dnl Fixme: Are these the best flags for OpenBSD????
case "${target}" in
*-openbsd*)
*-openbsd* | *-netbsd*)
NAME_OF_DEV_RANDOM="/dev/srandom"
NAME_OF_DEV_URANDOM="/dev/urandom"
DYNLINK_MOD_CFLAGS="-shared -rdynamic $CFLAGS_PIC -Wl,-Bshareable -Wl,-x"
;;
*-netbsd*)
NAME_OF_DEV_RANDOM="/dev/random"
NAME_OF_DEV_URANDOM="/dev/urandom"
DYNLINK_MOD_CFLAGS="-shared -rdynamic $CFLAGS_PIC -Wl,-Bshareable -Wl,-x"
;;
*-solaris*)
NAME_OF_DEV_RANDOM="/dev/random"
NAME_OF_DEV_URANDOM="/dev/random"
DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"
;;
*-irix*)
*-solaris* | *-irix* | *-dec-osf* )
NAME_OF_DEV_RANDOM="/dev/random"
NAME_OF_DEV_URANDOM="/dev/urandom"
DYNLINK_MOD_CFLAGS="-shared $CFLAGS_PIC"

View File

@ -1,3 +1,13 @@
2001-06-12 Werner Koch <wk@gnupg.org>
* getkey.c (compare_name): Use ascii_memistr(), ascii_memcasecmp()
* keyedit.c (keyedit_menu): Use ascii_strcasecmp().
* armor.c (radix64_read): Use ascii_toupper().
* ringedit.c (do_bm_search): Ditto.
* keygen.c (read_parameter_file): Ditto.
* openfile.c (CMP_FILENAME): Ditto.
* g10.c (i18n_init): We can now use just LC_ALL.
2001-05-29 Werner Koch <wk@gnupg.org>
* keygen.c (generate_subkeypair): Print a warning if a subkey is

View File

@ -649,9 +649,9 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
if( isxdigit(cc1) && isxdigit(cc2)
&& strchr( "=\n\r\t ", cc3 )) {
/* well it seems to be the case - adjust */
c = isdigit(cc1)? (cc1 - '0'): (toupper(cc1)-'A'+10);
c = isdigit(cc1)? (cc1 - '0'): (ascii_toupper(cc1)-'A'+10);
c <<= 4;
c |= isdigit(cc2)? (cc2 - '0'): (toupper(cc2)-'A'+10);
c |= isdigit(cc2)? (cc2 - '0'): (ascii_toupper(cc2)-'A'+10);
afx->buffer_pos += 2;
afx->qp_detected = 1;
goto again;

View File

@ -513,12 +513,7 @@ i18n_init(void)
set_gettext_file( PACKAGE );
#else
#ifdef ENABLE_NLS
#ifdef HAVE_LC_MESSAGES
setlocale( LC_TIME, "" );
setlocale( LC_MESSAGES, "" );
#else
setlocale( LC_ALL, "" );
#endif
bindtextdomain( PACKAGE, G10_LOCALEDIR );
textdomain( PACKAGE );
#endif

View File

@ -1273,7 +1273,7 @@ compare_name( const char *uid, size_t uidlen, const char *name, int mode )
return 0; /* found */
}
else if( mode == 2 ) { /* case insensitive substring */
if( memistr( uid, uidlen, name ) )
if( ascii_memistr( uid, uidlen, name ) )
return 0;
}
else if( mode >= 3 && mode <= 5 ) { /* look at the email address */
@ -1287,11 +1287,12 @@ compare_name( const char *uid, size_t uidlen, const char *name, int mode )
if( i < uidlen ) {
i = se - s;
if( mode == 3 ) { /* exact email address */
if( strlen(name)-2 == i && !memicmp( s, name+1, i) )
if( strlen(name)-2 == i
&& !ascii_memcasecmp( s, name+1, i) )
return 0;
}
else if( mode == 4 ) { /* email substring */
if( memistr( s, i, name ) )
if( ascii_memistr( s, i, name ) )
return 0;
}
else { /* email from end */

View File

@ -721,7 +721,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands,
}
for(i=0; cmds[i].name; i++ ) {
if( !stricmp( answer, cmds[i].name ) )
if( !ascii_strcasecmp( answer, cmds[i].name ) )
break;
}
if( sign_mode && !cmds[i].signmode )

View File

@ -1292,17 +1292,17 @@ read_parameter_file( const char *fname )
;
value = p;
trim_trailing_ws( value, strlen(value) );
if( !stricmp( keyword, "%echo" ) )
if( !ascii_strcasecmp( keyword, "%echo" ) )
log_info("%s\n", value );
else if( !stricmp( keyword, "%dry-run" ) )
else if( !ascii_strcasecmp( keyword, "%dry-run" ) )
outctrl.dryrun = 1;
else if( !stricmp( keyword, "%commit" ) ) {
else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
outctrl.lnr = lnr;
proc_parameter_file( para, fname, &outctrl );
release_parameter_list( para );
para = NULL;
}
else if( !stricmp( keyword, "%pubring" ) ) {
else if( !ascii_strcasecmp( keyword, "%pubring" ) ) {
if( outctrl.pub.fname && !strcmp( outctrl.pub.fname, value ) )
; /* still the same file - ignore it */
else {
@ -1311,7 +1311,7 @@ read_parameter_file( const char *fname )
outctrl.use_files = 1;
}
}
else if( !stricmp( keyword, "%secring" ) ) {
else if( !ascii_strcasecmp( keyword, "%secring" ) ) {
if( outctrl.sec.fname && !strcmp( outctrl.sec.fname, value ) )
; /* still the same file - ignore it */
else {
@ -1344,7 +1344,7 @@ read_parameter_file( const char *fname )
trim_trailing_ws( value, strlen(value) );
for(i=0; keywords[i].name; i++ ) {
if( !stricmp( keywords[i].name, keyword ) )
if( !ascii_strcasecmp( keywords[i].name, keyword ) )
break;
}
if( !keywords[i].name ) {

View File

@ -43,7 +43,7 @@
#endif
#ifdef HAVE_DRIVE_LETTERS
#define CMP_FILENAME(a,b) stricmp( (a), (b) )
#define CMP_FILENAME(a,b) ascii_strcasecmp( (a), (b) )
#else
#define CMP_FILENAME(a,b) strcmp( (a), (b) )
#endif

View File

@ -1000,8 +1000,8 @@ do_bm_search( const byte *buf, size_t buflen,
int c, c1;
for( i = --patlen; i < buflen; i += dist[c1] )
for( j=patlen, k=i, c1=c=toupper(buf[k]); c == pat[j];
j--, k--, c=toupper(buf[k]) ) {
for( j=patlen, k=i, c1=c=ascii_toupper(buf[k]); c == pat[j];
j--, k--, c=ascii_toupper(buf[k]) ) {
if( !j )
return buf+k;
}

View File

@ -170,6 +170,7 @@ STRLIST append_to_strlist2( STRLIST *list, const char *string, int is_utf8 );
STRLIST strlist_prev( STRLIST head, STRLIST node );
STRLIST strlist_last( STRLIST node );
const char *memistr( const char *buf, size_t buflen, const char *sub );
const char *ascii_memistr( const char *buf, size_t buflen, const char *sub );
char *mem2str( char *, const void *, size_t);
char *trim_spaces( char *string );
unsigned int trim_trailing_chars( byte *line, unsigned int len,
@ -185,6 +186,13 @@ char *native_to_utf8( const char *string );
char *utf8_to_native( const char *string, size_t length );
int check_utf8_string( const char *string );
int ascii_isupper (int c);
int ascii_islower (int c);
int ascii_toupper (int c);
int ascii_tolower (int c);
int ascii_strcasecmp( const char *a, const char *b );
int ascii_memcasecmp( const char *a, const char *b, size_t n );
#ifndef HAVE_MEMICMP
int memicmp( const char *a, const char *b, size_t n );
#endif

View File

@ -1,3 +1,12 @@
2001-06-12 Werner Koch <wk@gnupg.org>
* strgutil.c (ascii_memistr,ascii_isupper,ascii_islower,
ascii_toupper,ascii_tolower, ascii_strcasecmp, ascii_memcasecmp): New.
(set_native_charset): Use ascii_strcasecmp()
* fileutil.c (compare_filenames): Ditto
* miscutil.c (answer_is_yes): Ditto.
(answer_is_yes_no_quit): Ditto.
2001-06-06 Werner Koch <wk@gnupg.org>
* strgutil.c (vasprintf) [__MINGW32__]: New. Taken from libiberty.

View File

@ -127,7 +127,7 @@ compare_filenames( const char *a, const char *b )
* resolve symlinks?
*/
#ifdef HAVE_DRIVE_LETTERS
return stricmp(a,b);
return ascii_strcasecmp(a,b);
#else
return strcmp(a,b);
#endif

View File

@ -289,6 +289,7 @@ answer_is_yes( const char *s )
const char *long_no = _("no");
const char *short_no = _("nN");
/* Note: we have to use the local dependent strcasecmp here */
if( !stricmp(s, long_yes ) )
return 1;
if( *s && strchr( short_yes, *s ) && !s[1] )
@ -299,7 +300,7 @@ answer_is_yes( const char *s )
if( *s && strchr( short_no, *s ) && !s[1] )
return 0;
/* test for the english version (for those who are used to type yes) */
if( !stricmp(s, "yes" ) )
if( !ascii_strcasecmp(s, "yes" ) )
return 1;
if( *s && strchr( "yY", *s ) && !s[1] )
return 1;
@ -320,6 +321,7 @@ answer_is_yes_no_quit( const char *s )
const char *short_no = _("nN");
const char *short_quit = _("qQ");
/* Note: We have to use the locale dependent strcasecmp */
if( !stricmp(s, long_no ) )
return 0;
if( !stricmp(s, long_yes ) )
@ -332,9 +334,10 @@ answer_is_yes_no_quit( const char *s )
return 1;
if( *s && strchr( short_quit, *s ) && !s[1] )
return -1;
if( !stricmp(s, "yes" ) )
/* but not here */
if( !ascii_strcasecmp(s, "yes" ) )
return 1;
if( !stricmp(s, "quit" ) )
if( !ascii_strcasecmp(s, "quit" ) )
return -1;
if( *s && strchr( "yY", *s ) && !s[1] )
return 1;

View File

@ -65,6 +65,7 @@ static ushort latin2_unicode[128] = {
0x0159,0x016F,0x00FA,0x0171,0x00FC,0x00FD,0x0163,0x02D9
};
static const char *active_charset_name = "iso-8859-1";
static ushort *active_charset = NULL;
static int no_translation = 0;
@ -193,6 +194,25 @@ memistr( const char *buf, size_t buflen, const char *sub )
return NULL ;
}
const char *
ascii_memistr( const char *buf, size_t buflen, const char *sub )
{
const byte *t, *s ;
size_t n;
for( t=buf, n=buflen, s=sub ; n ; t++, n-- )
if( ascii_toupper(*t) == ascii_toupper(*s) ) {
for( buf=t++, buflen = n--, s++;
n && ascii_toupper(*t) == ascii_toupper(*s); t++, s++, n-- )
;
if( !*s )
return buf;
t = buf; n = buflen; s = sub ;
}
return NULL ;
}
/****************
* Wie strncpy(), aber es werden maximal n-1 zeichen kopiert und ein
* '\0' angehängt. Ist n = 0, so geschieht nichts, ist Destination
@ -325,22 +345,23 @@ string_count_chr( const char *string, int c )
int
set_native_charset( const char *newset )
{
if( !stricmp( newset, "iso-8859-1" ) ) {
if( !ascii_strcasecmp( newset, "iso-8859-1" ) ) {
active_charset_name = "iso-8859-1";
no_translation = 0;
active_charset = NULL;
}
else if( !stricmp( newset, "iso-8859-2" ) ) {
else if( !ascii_strcasecmp( newset, "iso-8859-2" ) ) {
active_charset_name = "iso-8859-2";
no_translation = 0;
active_charset = latin2_unicode;
}
else if( !stricmp( newset, "koi8-r" ) ) {
else if( !ascii_strcasecmp( newset, "koi8-r" ) ) {
active_charset_name = "koi8-r";
no_translation = 0;
active_charset = koi8_unicode;
}
else if( !stricmp (newset, "utf8" ) || !stricmp(newset, "utf-8") ) {
else if( !ascii_strcasecmp (newset, "utf8" )
|| !ascii_strcasecmp(newset, "utf-8") ) {
active_charset_name = "utf-8";
no_translation = 1;
active_charset = NULL;
@ -582,6 +603,63 @@ utf8_to_native( const char *string, size_t length )
}
}
/****************************************************
******** locale insensitive ctype functions ********
****************************************************/
/* FIXME: replace them by a table lookup and macros */
int
ascii_isupper (int c)
{
return c >= 'A' && c <= 'Z';
}
int
ascii_islower (int c)
{
return c >= 'a' && c <= 'z';
}
int
ascii_toupper (int c)
{
if (c >= 'a' && c <= 'z')
c &= ~0x20;
return c;
}
int
ascii_tolower (int c)
{
if (c >= 'A' && c <= 'Z')
c |= 0x20;
return c;
}
int
ascii_strcasecmp( const char *a, const char *b )
{
if (a == b)
return 0;
for (; *a && *b; a++, b++) {
if (*a != *b && ascii_toupper(*a) != ascii_toupper(*b))
break;
}
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
}
int
ascii_memcasecmp( const char *a, const char *b, size_t n )
{
if (a == b)
return 0;
for ( ; n; n--, a++, b++ ) {
if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) )
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
}
return 0;
}
/*********************************************