mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +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>
|
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
|
* strgutil.c (set_native_charset): Allow NULL as argument to use
|
||||||
nl_langinfo for selection. Mapped latin-15 to latin-1.
|
nl_langinfo for selection. Mapped latin-15 to latin-1.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#ifdef USE_SIMPLE_GETTEXT
|
#ifdef USE_SIMPLE_GETTEXT
|
||||||
#if !defined (__MINGW32__) && !defined (__CYGWIN32__)
|
#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
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -247,12 +247,21 @@ set_gettext_file( const char *filename )
|
|||||||
else { /* relative path - append ".mo" and get dir from the environment */
|
else { /* relative path - append ".mo" and get dir from the environment */
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
char *dir;
|
char *dir;
|
||||||
|
char *p;
|
||||||
|
|
||||||
dir = read_w32_registry_string( NULL,
|
dir = read_w32_registry_string( NULL,
|
||||||
"Control Panel\\Mingw32\\NLS",
|
"Control Panel\\Mingw32\\NLS",
|
||||||
"MODir" );
|
"MODir" );
|
||||||
if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) {
|
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 );
|
domain = load_domain( buf );
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
@ -687,18 +687,58 @@ ascii_tolower (int c)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ascii_strcasecmp( const char *a, const char *b )
|
ascii_strcasecmp (const char *a, const char *b)
|
||||||
{
|
{
|
||||||
if (a == b)
|
const unsigned char *p1 = (const unsigned char *)a;
|
||||||
|
const unsigned char *p2 = (const unsigned char *)b;
|
||||||
|
unsigned char c1, c2;
|
||||||
|
|
||||||
|
if (p1 == p2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (; *a && *b; a++, b++) {
|
do
|
||||||
if (*a != *b && ascii_toupper(*a) != ascii_toupper(*b))
|
{
|
||||||
|
c1 = ascii_tolower (*p1);
|
||||||
|
c2 = ascii_tolower (*p2);
|
||||||
|
|
||||||
|
if (c1 == '\0')
|
||||||
break;
|
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
|
int
|
||||||
ascii_memcasecmp( const char *a, const char *b, size_t n )
|
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 *********
|
********** 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
|
* 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
|
* is an alias fro HKEY_CURRENT_USER
|
||||||
* NOTE: The value is allocated with a plain malloc() - use free() and not
|
* NOTE: The value is allocated with a plain malloc() - use free() and not
|
||||||
* the usual m_free()!!!
|
* the usual m_free()!!!
|
||||||
@ -67,7 +67,7 @@ char *
|
|||||||
read_w32_registry_string( const char *root, const char *dir, const char *name )
|
read_w32_registry_string( const char *root, const char *dir, const char *name )
|
||||||
{
|
{
|
||||||
HKEY root_key, key_handle;
|
HKEY root_key, key_handle;
|
||||||
DWORD n1, nbytes;
|
DWORD n1, nbytes, type;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if ( !(root_key = get_root_key(root) ) )
|
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) );
|
result = malloc( (n1=nbytes+1) );
|
||||||
if( !result )
|
if( !result )
|
||||||
goto leave;
|
goto leave;
|
||||||
if( RegQueryValueEx( key_handle, name, 0, NULL, result, &n1 ) ) {
|
if( RegQueryValueEx( key_handle, name, 0, &type, result, &n1 ) ) {
|
||||||
free(result); result = NULL;
|
free(result); result = NULL;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
result[nbytes] = 0; /* make sure it is really a string */
|
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:
|
leave:
|
||||||
RegCloseKey( key_handle );
|
RegCloseKey( key_handle );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user