summaryrefslogtreecommitdiff
path: root/lib/libXfont/src/fontfile/dirfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libXfont/src/fontfile/dirfile.c')
-rw-r--r--lib/libXfont/src/fontfile/dirfile.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/libXfont/src/fontfile/dirfile.c b/lib/libXfont/src/fontfile/dirfile.c
index f390391bc..588464ffb 100644
--- a/lib/libXfont/src/fontfile/dirfile.c
+++ b/lib/libXfont/src/fontfile/dirfile.c
@@ -62,10 +62,13 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
char *ptr;
FILE *file;
int count,
- i,
+ num_fonts,
status;
struct stat statb;
static char format[24] = "";
+#if defined(WIN32)
+ int i;
+#endif
FontDirectoryPtr dir = NullFontDirectory;
@@ -73,7 +76,7 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
return BadFontPath;
/* Check for font directory attributes */
-#if !defined(__UNIXOS2__) && !defined(WIN32)
+#if !defined(WIN32)
if ((ptr = strchr(directory, ':'))) {
#else
/* OS/2 and WIN32 path might start with a drive letter, don't clip this */
@@ -90,8 +93,6 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
strcat(dir_file, FontDirFile);
file = fopen(dir_file, "rt");
if (file) {
- Bool found_font = FALSE;
-
#ifndef WIN32
if (fstat (fileno(file), &statb) == -1)
#else
@@ -101,12 +102,12 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
fclose(file);
return BadFontPath;
}
- count = fscanf(file, "%d\n", &i);
+ count = fscanf(file, "%d\n", &num_fonts);
if ((count == EOF) || (count != 1)) {
fclose(file);
return BadFontPath;
}
- dir = FontFileMakeDir(directory, i);
+ dir = FontFileMakeDir(directory, num_fonts);
if (dir == NULL) {
fclose(file);
return BadFontPath;
@@ -117,7 +118,7 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
-#if defined(__UNIXOS2__) || defined(WIN32)
+#if defined(WIN32)
/* strip any existing trailing CR */
for (i=0; i<strlen(font_name); i++) {
if (font_name[i]=='\r') font_name[i] = '\0';
@@ -128,13 +129,13 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
fclose(file);
return BadFontPath;
}
- if (FontFileAddFontFile (dir, font_name, file_name))
- found_font = TRUE;
- }
- if (!found_font) {
- FontFileFreeDir (dir);
- fclose(file);
- return BadFontPath;
+
+ /*
+ * We blindly try to load all the font files specified.
+ * In theory, we might want to warn that some of the fonts
+ * couldn't be loaded.
+ */
+ FontFileAddFontFile (dir, font_name, file_name);
}
fclose(file);
@@ -175,6 +176,9 @@ FontFileDirectoryChanged(FontDirectoryPtr dir)
}
if (dir->dir_mtime != statb.st_mtime)
return TRUE;
+
+ if ((strlen(dir->directory) + sizeof(FontAliasFile)) > sizeof(dir_file))
+ return FALSE;
strcpy (dir_file, dir->directory);
strcat (dir_file, FontAliasFile);
if (stat (dir_file, &statb) == -1)
@@ -374,7 +378,7 @@ lexAlias(FILE *file, char **lexToken)
char *nbuf;
nsize = tokenSize ? (tokenSize << 1) : 64;
- nbuf = (char *) xrealloc(tokenBuf, nsize);
+ nbuf = realloc(tokenBuf, nsize);
if (!nbuf)
return EALLOC;
tokenBuf = nbuf;