mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
* w32reg.c (read_w32_registry_string): Handle REG_EXPAND_SZ.
Suggested by Ryan Malayter. * strgutil.c (ascii_strcasecmp): Replaced by code from gnulib. (ascii_strncasecmp): New.
This commit is contained in:
parent
e892058dba
commit
075f862277
@ -1,5 +1,16 @@
|
||||
2002-09-09 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* w32reg.c (read_w32_registry_string): Handle REG_EXPAND_SZ.
|
||||
Suggested by Ryan Malayter.
|
||||
|
||||
* strgutil.c (ascii_strcasecmp): Replaced by code from gnulib.
|
||||
(ascii_strncasecmp): New.
|
||||
|
||||
2002-09-02 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* simple-gettext.c (set_gettext_file): Make sure that we only use
|
||||
backslashes.
|
||||
|
||||
* strgutil.c (set_native_charset): Allow NULL as argument to use
|
||||
nl_langinfo for selection. Mapped latin-15 to latin-1.
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <config.h>
|
||||
#ifdef USE_SIMPLE_GETTEXT
|
||||
#if !defined (__MINGW32__) && !defined (__CYGWIN32__)
|
||||
#error This file can only be used with MingW32 or Cygwin32
|
||||
#error This file can only be used with MingW32 or Cygwin32
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
@ -247,12 +247,21 @@ set_gettext_file( const char *filename )
|
||||
else { /* relative path - append ".mo" and get dir from the environment */
|
||||
char *buf = NULL;
|
||||
char *dir;
|
||||
char *p;
|
||||
|
||||
dir = read_w32_registry_string( NULL,
|
||||
"Control Panel\\Mingw32\\NLS",
|
||||
"MODir" );
|
||||
if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
|
||||
strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"/"), filename),".mo");
|
||||
strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"\\"), filename),".mo");
|
||||
/* Better make sure that we don't mix forward and
|
||||
backward slashes. It seems that some Windoze
|
||||
versions don't accept this. */
|
||||
for (p=buf; *p; p++)
|
||||
{
|
||||
if (*p == '/')
|
||||
*p = '\\';
|
||||
}
|
||||
domain = load_domain( buf );
|
||||
free(buf);
|
||||
}
|
||||
|
@ -687,18 +687,58 @@ ascii_tolower (int c)
|
||||
|
||||
|
||||
int
|
||||
ascii_strcasecmp( const char *a, const char *b )
|
||||
ascii_strcasecmp (const char *a, const char *b)
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
const unsigned char *p1 = (const unsigned char *)a;
|
||||
const unsigned char *p2 = (const unsigned char *)b;
|
||||
unsigned char c1, c2;
|
||||
|
||||
for (; *a && *b; a++, b++) {
|
||||
if (*a != *b && ascii_toupper(*a) != ascii_toupper(*b))
|
||||
break;
|
||||
if (p1 == p2)
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = ascii_tolower (*p1);
|
||||
c2 = ascii_tolower (*p2);
|
||||
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
int
|
||||
ascii_strncasecmp (const char *a, const char *b, size_t n)
|
||||
{
|
||||
const unsigned char *p1 = (const unsigned char *)a;
|
||||
const unsigned char *p2 = (const unsigned char *)b;
|
||||
unsigned char c1, c2;
|
||||
|
||||
if (p1 == p2 || !n )
|
||||
return 0;
|
||||
|
||||
do
|
||||
{
|
||||
c1 = ascii_tolower (*p1);
|
||||
c2 = ascii_tolower (*p2);
|
||||
|
||||
if ( !--n || c1 == '\0')
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
}
|
||||
while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ascii_memcasecmp( const char *a, const char *b, size_t n )
|
||||
{
|
||||
@ -712,6 +752,7 @@ ascii_memcasecmp( const char *a, const char *b, size_t n )
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************
|
||||
********** missing string functions *********
|
||||
*********************************************/
|
||||
|
@ -58,7 +58,7 @@ get_root_key(const char *root)
|
||||
|
||||
/****************
|
||||
* Return a string from the Win32 Registry or NULL in case of
|
||||
* error. Caller must release the return value. A NUKK for root
|
||||
* error. Caller must release the return value. A NULL for root
|
||||
* is an alias fro HKEY_CURRENT_USER
|
||||
* NOTE: The value is allocated with a plain malloc() - use free() and not
|
||||
* the usual m_free()!!!
|
||||
@ -67,7 +67,7 @@ char *
|
||||
read_w32_registry_string( const char *root, const char *dir, const char *name )
|
||||
{
|
||||
HKEY root_key, key_handle;
|
||||
DWORD n1, nbytes;
|
||||
DWORD n1, nbytes, type;
|
||||
char *result = NULL;
|
||||
|
||||
if ( !(root_key = get_root_key(root) ) )
|
||||
@ -82,11 +82,48 @@ read_w32_registry_string( const char *root, const char *dir, const char *name )
|
||||
result = malloc( (n1=nbytes+1) );
|
||||
if( !result )
|
||||
goto leave;
|
||||
if( RegQueryValueEx( key_handle, name, 0, NULL, result, &n1 ) ) {
|
||||
if( RegQueryValueEx( key_handle, name, 0, &type, result, &n1 ) ) {
|
||||
free(result); result = NULL;
|
||||
goto leave;
|
||||
}
|
||||
result[nbytes] = 0; /* make sure it is really a string */
|
||||
if (type == REG_EXPAND_SZ && strchr (result, '%')) {
|
||||
char *tmp;
|
||||
|
||||
n1 += 1000;
|
||||
tmp = malloc (n1+1);
|
||||
if (!tmp)
|
||||
goto leave;
|
||||
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
|
||||
if (nbytes && nbytes > n1) {
|
||||
free (tmp);
|
||||
tmp = malloc (n1 + 1);
|
||||
if (!tmp)
|
||||
goto leave;
|
||||
nbytes = ExpandEnvironmentStrings (result, tmp, n1);
|
||||
if (nbytes && nbytes > n1) {
|
||||
free (tmp); /* oops - truncated, better don't expand at all */
|
||||
goto leave;
|
||||
}
|
||||
tmp[nbytes] = 0;
|
||||
free (result);
|
||||
result = tmp;
|
||||
}
|
||||
else if (nbytes) { /* okay, reduce the length */
|
||||
tmp[nbytes] = 0;
|
||||
free (result);
|
||||
result = malloc (strlen (tmp)+1);
|
||||
if (!result)
|
||||
result = tmp;
|
||||
else {
|
||||
strcpy (result, tmp);
|
||||
free (tmp);
|
||||
}
|
||||
}
|
||||
else { /* error - don't expand */
|
||||
free (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
leave:
|
||||
RegCloseKey( key_handle );
|
||||
|
Loading…
x
Reference in New Issue
Block a user