Add ETCX11DIR to DEFINES

Add entries from /etc/X11/font-dirs to default fontpath
This commit is contained in:
Alexander Gottwald 2004-10-20 19:29:13 +00:00
parent 6a35e5c3f1
commit a19580051c
3 changed files with 135 additions and 2 deletions

View file

@ -1,3 +1,11 @@
2004-10-20 Alexander Gottwald <ago at freedesktop dot org>
* Imakefile:
Add ETCX11DIR to DEFINES
* InitOutput.c (InitOutput):
* winconfig.c (winConfigFiles) :
Add entries from /etc/X11/font-dirs to default fontpath
2004-10-16 Alexander Gottwald <ago at freedesktop dot org>
* winprocarg.c (winInitializeDefaultScreens, ddxProcessArgument):

View file

@ -30,9 +30,7 @@ from The Open Group.
#include "win.h"
#include "winmsg.h"
#ifdef XWIN_XF86CONFIG
#include "winconfig.h"
#endif
#include "winprefs.h"
#include "X11/Xlocale.h"
#include <mntent.h>
@ -635,6 +633,7 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
winMsg(X_INFO, "XF86Config is not supported\n");
winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html "
"for more information\n");
winConfigFiles ();
#endif
/* Load preferences from XWinrc file */

View file

@ -730,6 +730,132 @@ 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;
/* 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;
}
/* 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;
/* get size, strip whitespaces from end (again) */
blen = strlen(str);
while (blen > 0 && (str[blen-1] == ' ' ||
str[blen-1] == '\t'))
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 = fontpath;
}
}
winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath);
return TRUE;
}
#endif