Commit 14366a92 authored by Jeremy White's avatar Jeremy White Committed by Alexandre Julliard

Normalize the display name used to build the cached metric filename so

that ':0', ':0.0', and 'unix:0.0' all resolve to the same file.
parent 4736cc8c
......@@ -68,7 +68,7 @@ static UINT XTextCaps = (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE | TC_CR_A
TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE);
/* X11R6 adds TC_SF_X_YINDEP, maybe more... */
static const char* INIFontMetrics = "/cachedmetrics.";
static const char* INIFontMetrics = "cachedmetrics.";
static const char* INIFontSection = "Software\\Wine\\Wine\\Config\\fonts";
static const char* INIAliasSection = "Alias";
static const char* INIIgnoreSection = "Ignore";
......@@ -1818,7 +1818,19 @@ static char* XFONT_UserMetricsCache( char* buffer, int* buf_size )
{
const char *confdir = get_config_dir();
const char *display_name = XDisplayName(NULL);
int len = strlen(confdir) + strlen(INIFontMetrics) + strlen(display_name) + 2;
int len = strlen(confdir) + strlen(INIFontMetrics) + strlen(display_name) + 8;
int display = 0;
int screen = 0;
char *p, *ext;
/*
** Normalize the display name, since on Red Hat systems, DISPLAY
** is commonly set to one of either 'unix:0.0' or ':0' or ':0.0'.
** after this code, all of the above will resolve to ':0.0'.
*/
if (!strncmp( display_name, "unix:", 5 )) display_name += 4;
p = strchr(display_name, ':');
if (p) sscanf(p + 1, "%d.%d", &display, &screen);
if ((len > *buf_size) &&
!(buffer = HeapReAlloc( GetProcessHeap(), 0, buffer, *buf_size = len )))
......@@ -1826,8 +1838,13 @@ static char* XFONT_UserMetricsCache( char* buffer, int* buf_size )
ERR("out of memory\n");
ExitProcess(1);
}
sprintf( buffer, "%s/%s", confdir, INIFontMetrics );
ext = buffer + strlen(buffer);
strcpy( ext, display_name );
sprintf( buffer, "%s/%s%s", confdir, INIFontMetrics, display_name );
if (!(p = strchr( ext, ':' ))) p = ext + strlen(ext);
sprintf( p, ":%d.%d", display, screen );
return buffer;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment