mirror of
https://github.com/reactos/reactos.git
synced 2024-07-05 12:15:46 +00:00
sync userenv winetest with wine 1.1.28
svn path=/trunk/; revision=42858
This commit is contained in:
parent
9ed4628b97
commit
c7b2857e8e
|
@ -39,90 +39,6 @@ struct profile_item
|
||||||
const int todo[4];
|
const int todo[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Debugging functions from wine/libs/wine/debug.c, slightly modified */
|
|
||||||
|
|
||||||
/* allocate some tmp string space */
|
|
||||||
/* FIXME: this is not 100% thread-safe */
|
|
||||||
static char *get_tmp_space( int size )
|
|
||||||
{
|
|
||||||
static char *list[32];
|
|
||||||
static long pos;
|
|
||||||
char *ret;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
idx = ++pos % (sizeof(list)/sizeof(list[0]));
|
|
||||||
if ((ret = realloc( list[idx], size ))) list[idx] = ret;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* default implementation of wine_dbgstr_wn */
|
|
||||||
static const char *default_dbgstr_wn( const WCHAR *str, int n, BOOL quotes )
|
|
||||||
{
|
|
||||||
char *dst, *res;
|
|
||||||
|
|
||||||
if (!HIWORD(str))
|
|
||||||
{
|
|
||||||
if (!str) return "(null)";
|
|
||||||
res = get_tmp_space( 6 );
|
|
||||||
sprintf( res, "#%04x", LOWORD(str) );
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
if (n == -1) n = lstrlenW(str);
|
|
||||||
if (n < 0) n = 0;
|
|
||||||
else if (n > 200) n = 200;
|
|
||||||
dst = res = get_tmp_space( n * 5 + 7 );
|
|
||||||
if (quotes)
|
|
||||||
{
|
|
||||||
*dst++ = 'L';
|
|
||||||
*dst++ = '"';
|
|
||||||
}
|
|
||||||
while (n-- > 0)
|
|
||||||
{
|
|
||||||
WCHAR c = *str++;
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
|
|
||||||
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
|
|
||||||
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
|
|
||||||
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
|
||||||
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
|
||||||
default:
|
|
||||||
if (c >= ' ' && c <= 126)
|
|
||||||
*dst++ = (char)c;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*dst++ = '\\';
|
|
||||||
sprintf(dst,"%04x",c);
|
|
||||||
dst+=4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quotes) *dst++ = '"';
|
|
||||||
if (*str)
|
|
||||||
{
|
|
||||||
*dst++ = '.';
|
|
||||||
*dst++ = '.';
|
|
||||||
*dst++ = '.';
|
|
||||||
}
|
|
||||||
*dst = 0;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *wine_dbgstr_wn( const WCHAR *s, int n )
|
|
||||||
{
|
|
||||||
return default_dbgstr_wn(s, n, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *wine_dbgstr_w( const WCHAR *s )
|
|
||||||
{
|
|
||||||
return default_dbgstr_wn( s, -1, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *userenv_dbgstr_w( const WCHAR *s )
|
|
||||||
{
|
|
||||||
return default_dbgstr_wn( s, -1, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Helper function for retrieving environment variables */
|
/* Helper function for retrieving environment variables */
|
||||||
static BOOL get_env(const WCHAR * env, const char * var, char ** result)
|
static BOOL get_env(const WCHAR * env, const char * var, char ** result)
|
||||||
{
|
{
|
||||||
|
@ -135,8 +51,8 @@ static BOOL get_env(const WCHAR * env, const char * var, char ** result)
|
||||||
varlen = strlen(var);
|
varlen = strlen(var);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
envlen = lstrlenW(p);
|
if (!WideCharToMultiByte( CP_ACP, 0, p, -1, buf, sizeof(buf), NULL, NULL )) buf[sizeof(buf)-1] = 0;
|
||||||
sprintf(buf, "%s", userenv_dbgstr_w(p));
|
envlen = strlen(buf);
|
||||||
if (CompareStringA(GetThreadLocale(), NORM_IGNORECASE|LOCALE_USE_CP_ACP, buf, min(envlen, varlen), var, varlen) == CSTR_EQUAL)
|
if (CompareStringA(GetThreadLocale(), NORM_IGNORECASE|LOCALE_USE_CP_ACP, buf, min(envlen, varlen), var, varlen) == CSTR_EQUAL)
|
||||||
{
|
{
|
||||||
if (buf[varlen] == '=')
|
if (buf[varlen] == '=')
|
||||||
|
@ -148,7 +64,8 @@ static BOOL get_env(const WCHAR * env, const char * var, char ** result)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = p + envlen + 1;
|
while (*p) p++;
|
||||||
|
p++;
|
||||||
} while (*p);
|
} while (*p);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue