diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-10-28 14:23:08 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-10-28 14:23:08 +0000 |
commit | 9d4823adc8319a20d2ace3d0944ca32e300f6eeb (patch) | |
tree | 66a10f48e62f2e8281af56877105d97f1c34f6d9 /hw/xwin/winconfig.c | |
parent | db65fce04ddec1dac0d92ad3abc95ab4996bd206 (diff) |
Import recent changes from CYGWIN branch
Diffstat (limited to 'hw/xwin/winconfig.c')
-rw-r--r-- | hw/xwin/winconfig.c | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index 8660c5ab9..b8c773268 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -730,6 +730,127 @@ winConfigFiles () return TRUE; } +#else +Bool +winConfigFiles () +{ + MessageType from; + + /* Fontpath */ + from = X_DEFAULT; + + if (g_cmdline.fontPath) + { + from = X_CMDLINE; + defaultFontPath = g_cmdline.fontPath; + } + else + { + /* Open fontpath configuration file */ + FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt"); + if (fontdirs != NULL) + { + char buffer[256]; + int needs_sep = TRUE; + int comment_block = FALSE; + + /* get defautl fontpath */ + char *fontpath = xstrdup(defaultFontPath); + size_t size = strlen(fontpath); + + /* read all lines */ + while (!feof(fontdirs)) + { + size_t blen; + char *hashchar; + char *str; + int has_eol = FALSE; + + /* read one line */ + str = fgets(buffer, sizeof(buffer), fontdirs); + if (str == NULL) /* stop on error or eof */ + break; + + if (strchr(str, '\n') != NULL) + has_eol = TRUE; + + /* check if block is continued comment */ + if (comment_block) + { + /* ignore all input */ + *str = 0; + blen = 0; + if (has_eol) /* check if line ended in this block */ + comment_block = FALSE; + } + else + { + /* find comment character. ignore all trailing input */ + hashchar = strchr(str, '#'); + if (hashchar != NULL) + { + *hashchar = 0; + if (!has_eol) /* mark next block as continued comment */ + comment_block = TRUE; + } + } + + /* strip whitespaces from beginning */ + while (*str == ' ' || *str == '\t') + str++; + + /* get size, strip whitespaces from end */ + blen = strlen(str); + while (blen > 0 && (str[blen-1] == ' ' || + str[blen-1] == '\t' || str[blen-1] == '\n')) + { + str[--blen] = 0; + } + + /* still something left to add? */ + if (blen > 0) + { + size_t newsize = size + blen; + /* reserve one character more for ',' */ + if (needs_sep) + newsize++; + + /* allocate memory */ + if (fontpath == NULL) + fontpath = malloc(newsize+1); + else + fontpath = realloc(fontpath, newsize+1); + + /* add separator */ + if (needs_sep) + { + fontpath[size] = ','; + size++; + needs_sep = FALSE; + } + + /* mark next line as new entry */ + if (has_eol) + needs_sep = TRUE; + + /* add block */ + strncpy(fontpath + size, str, blen); + fontpath[newsize] = 0; + size = newsize; + } + } + + /* cleanup */ + fclose(fontdirs); + from = X_CONFIG; + defaultFontPath = xstrdup(fontpath); + free(fontpath); + } + } + winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath); + + return TRUE; +} #endif |