diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-10-23 12:02:00 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-10-23 12:02:00 +0000 |
commit | beb46a639c47207c44c19357b515bc9a18c2d150 (patch) | |
tree | be570bd338dd4e39d3069d06b8c1cee95d1e8443 | |
parent | c98e1cc97351759b9a8d21b23c06ad8f99879ea6 (diff) |
Simplify /etc/X11/font-dirs parsing
-rw-r--r-- | hw/xwin/ChangeLog | 5 | ||||
-rw-r--r-- | hw/xwin/winconfig.c | 39 |
2 files changed, 22 insertions, 22 deletions
diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index f91e67307..1f4f455c9 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,8 @@ +2004-10-23 Alexander Gottwald <ago at freedesktop dot org> + + * winconfig (winConfigFiles): + Simplify /etc/X11/font-dirs parsing + 2004-10-20 Alexander Gottwald <ago at freedesktop dot org> * XWin.rc, winresource.h, winwndproc.c: diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index 7f95cf3b1..b8c773268 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -770,22 +770,10 @@ winConfigFiles () str = fgets(buffer, sizeof(buffer), fontdirs); if (str == NULL) /* stop on error or eof */ break; - - /* 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')) - { - if (str[blen-1] == '\n') /* flag that we've read a */ - has_eol = TRUE; /* complete line */ - str[--blen] = 0; - } - + if (strchr(str, '\n') != NULL) + has_eol = TRUE; + /* check if block is continued comment */ if (comment_block) { @@ -804,14 +792,20 @@ winConfigFiles () *hashchar = 0; if (!has_eol) /* mark next block as continued comment */ comment_block = TRUE; - - /* get size, strip whitespaces from end (again) */ - blen = strlen(str); - while (blen > 0 && (str[blen-1] == ' ' || - str[blen-1] == '\t')) - str[--blen] = 0; } } + + /* 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) @@ -849,7 +843,8 @@ winConfigFiles () /* cleanup */ fclose(fontdirs); from = X_CONFIG; - defaultFontPath = fontpath; + defaultFontPath = xstrdup(fontpath); + free(fontpath); } } winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath); |