Index: xc/lib/font/bitmap/bitmapfunc.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/bitmap/bitmapfunc.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 bitmapfunc.c --- xc/lib/font/bitmap/bitmapfunc.c 23 Apr 2004 18:44:20 -0000 1.2 +++ xc/lib/font/bitmap/bitmapfunc.c 13 Oct 2004 02:57:22 -0000 @@ -21,40 +21,43 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ /* $XFree86: xc/lib/font/bitmap/bitmapfunc.c,v 3.17 2002/09/19 13:21:58 tsi Exp $ */ /* * Author: Keith Packard, MIT X Consortium */ #include "fntfilst.h" #include "bitmap.h" #include "fontutil.h" #include "bdfint.h" #include "pcf.h" #include "snfstr.h" +#include + +extern void ErrorF(const char *f, ...); typedef struct _BitmapFileFunctions { int (*ReadFont) (FontPtr /* pFont */, FontFilePtr /* file */, int /* bit */, int /* byte */, int /* glyph */, int /* scan */); int (*ReadInfo) ( FontInfoPtr /* pFontInfo */, FontFilePtr /* file */ ); } BitmapFileFunctionsRec, *BitmapFileFunctionsPtr; /* * the readers[] and renderers[] arrays must be in the same order, * and also in the same order as scale[] and find_scale[] in bitscale.c * */ static BitmapFileFunctionsRec readers[] = { #ifdef PCFFORMAT { pcfReadFont, pcfReadFontInfo} , { pcfReadFont, pcfReadFontInfo} , #ifdef X_GZIP_FONT_COMPRESSION @@ -132,44 +135,47 @@ }; int BitmapOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags, FontEntryPtr entry, char *fileName, fsBitmapFormat format, fsBitmapFormatMask fmask, FontPtr non_cachable_font) /* We don't do licensing */ { FontFilePtr file; FontPtr pFont; int i; int ret; int bit, byte, glyph, scan, image; i = BitmapGetRenderIndex(entry->u.bitmap.renderer); file = FontFileOpen (fileName); - if (!file) + if (!file) { + ErrorF("Error: BitmapOpenBitmap() can't open fileName='%s', errno=%d\n", + fileName, (int)errno); return BadFontName; + } if (!(pFont = CreateFontRec())) { - fprintf(stderr, "Error: Couldn't allocate pFont (%ld)\n", + ErrorF("Error: Couldn't allocate pFont (%ld)\n", (unsigned long)sizeof(FontRec)); FontFileClose (file); return AllocError; } /* set up default values */ FontDefaultFormat(&bit, &byte, &glyph, &scan); /* get any changes made from above */ ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image); /* Fill in font record. Data format filled in by reader. */ pFont->refcnt = 0; ret = (*readers[i].ReadFont) (pFont, file, bit, byte, glyph, scan); FontFileClose (file); if (ret != Successful) { xfree(pFont); } else { *ppFont = pFont; } Index: xc/lib/font/fontfile/dirfile.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/fontfile/dirfile.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 dirfile.c --- xc/lib/font/fontfile/dirfile.c 23 Apr 2004 18:44:21 -0000 1.2 +++ xc/lib/font/fontfile/dirfile.c 13 Oct 2004 02:57:22 -0000 @@ -26,40 +26,42 @@ */ /* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.17 2004/02/08 01:52:27 dawes Exp $ */ /* * Author: Keith Packard, MIT X Consortium */ /* * dirfile.c * * Read fonts.dir and fonts.alias files */ #include "fntfilst.h" #include #include #include #include +extern void ErrorF(const char *f, ...); + static Bool AddFileNameAliases ( FontDirectoryPtr dir ); static int ReadFontAlias ( char *directory, Bool isFile, FontDirectoryPtr *pdir ); static int lexAlias ( FILE *file, char **lexToken ); static int lexc ( FILE *file ); int FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir) { char file_name[MAXFONTFILENAMELEN]; char font_name[MAXFONTNAMELEN]; char dir_file[MAXFONTFILENAMELEN]; #ifdef FONTDIRATTRIB char dir_path[MAXFONTFILENAMELEN]; char *ptr; #endif FILE *file; int count, i, status; @@ -117,42 +119,46 @@ /* strip any existing trailing CR */ for (i=0; i= sizeof(alias_file)) return BadFontPath; dir = *pdir; strcpy(alias_file, directory); if (!isFile) { if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file)) return BadFontPath; if (directory[strlen(directory) - 1] != '/') strcat(alias_file, "/"); strcat(alias_file, FontAliasFile); } file = fopen(alias_file, "r"); - if (!file) - return ((errno == ENOENT) ? Successful : BadFontPath); + if (!file) { + if (errno == ENOENT) { + return Successful; + } + else { + ErrorF("Warning: ReadFontAlias() can't open alias_file='%s', errno=%d\n", + alias_file, (int)errno); + return BadFontPath; + } + } if (!dir) *pdir = dir = FontFileMakeDir(directory, 10); if (!dir) { fclose (file); return AllocError; } if (fstat (fileno (file), &statb) == -1) { fclose (file); return BadFontPath; } dir->alias_mtime = statb.st_mtime; while (status == Successful) { token = lexAlias(file, &lexToken); switch (token) { case NEWLINE: break; case DONE: fclose(file); Index: xc/lib/font/fontfile/encparse.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/fontfile/encparse.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 encparse.c --- xc/lib/font/fontfile/encparse.c 23 Apr 2004 18:44:21 -0000 1.2 +++ xc/lib/font/fontfile/encparse.c 13 Oct 2004 02:57:22 -0000 @@ -14,40 +14,41 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */ /* Parser for encoding files */ /* This code assumes that we are using ASCII. We don't use the ctype functions, as they depend on the current locale. On the other hand, we do use strcasecmp, but only on strings that we've checked to be pure ASCII. Bloody ``Code Set Independence''. */ #include #include +#include #ifdef SCO325 #include #endif #ifndef FONTENC_NO_LIBFONT #include "fntfilio.h" #include "fntfilst.h" #else #include #define xalloc(n) malloc(n) #define xrealloc(p, n) realloc(p, n) #define xfree(p) free(p) #include "zlib.h" typedef gzFile FontFilePtr; #define FontFileGetc(f) gzgetc(f) @@ -69,40 +70,42 @@ #define EOL_TOKEN 0 #define NUMBER_TOKEN 1 #define KEYWORD_TOKEN 2 #define EOF_LINE -1 #define ERROR_LINE -2 #define STARTENCODING_LINE 1 #define STARTMAPPING_LINE 2 #define ENDMAPPING_LINE 3 #define CODE_LINE 4 #define CODE_RANGE_LINE 5 #define CODE_UNDEFINE_LINE 6 #define NAME_LINE 7 #define SIZE_LINE 8 #define ALIAS_LINE 9 #define FIRSTINDEX_LINE 10 /* Return from lexer */ #define MAXKEYWORDLEN 100 +extern void ErrorF(const char *f, ...); + static long number_value; static char keyword_value[MAXKEYWORDLEN+1]; static long value1, value2, value3; /* Lexer code */ /* Skip to the beginning of new line */ static void skipEndOfLine(FontFilePtr f, int c) { if(c == 0) c = FontFileGetc(f); for(;;) if(c <= 0 || c == '\n') return; else c = FontFileGetc(f); } @@ -826,74 +829,78 @@ strcat(buf, "encodings.dir"); } } static FontEncPtr FontEncReallyReallyLoad(const char *charset, const char *dirname, const char *dir) { FontFilePtr f; FILE *file; FontEncPtr encoding; char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN], buf[MAXFONTFILENAMELEN]; int count, n; static char format[24] = ""; /* As we don't really expect to open encodings that often, we don't take the trouble of caching encodings directories. */ if((file = fopen(dirname, "r")) == NULL) { + ErrorF("Warning: FontEncReallyReallyLoad() can't open dirname='%s', errno=%d\n", + dirname, (int)errno); return NULL; } count = fscanf(file, "%d\n", &n); if(count == EOF || count != 1) { fclose(file); return NULL; } encoding = NULL; if (!format[0]) { sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1, (int)sizeof(file_name) - 1); } for(;;) { count = fscanf(file, format, encoding_name, file_name); if(count == EOF) break; if(count != 2) break; if(!strcasecmp(encoding_name, charset)) { /* Found it */ if(file_name[0] != '/') { if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) return NULL; strcpy(buf, dir); strcat(buf, file_name); } else { strcpy(buf , file_name); } f = FontFileOpen(buf); if(f == NULL) { + ErrorF("Warning: FontEncReallyReallyLoad() can't open buf='%s', errno=%d\n", + buf, (int)errno); return NULL; } encoding = parseEncodingFile(f, 0); FontFileClose(f); break; } } fclose(file); return encoding; } /* Parser ntrypoint -- used by FontEncLoad */ FontEncPtr FontEncReallyLoad(const char *charset, const char *fontFileName) { FontEncPtr encoding; char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN]; char *d; @@ -911,40 +918,42 @@ encoding = FontEncReallyReallyLoad(charset, d, dir); return encoding; } return NULL; } /* Return a NULL-terminated array of encoding names. Note that this * function has incestuous knowledge of the allocations done by * parseEncodingFile. */ char ** FontEncIdentify(const char *fileName) { FontFilePtr f; FontEncPtr encoding; char **names, **name, **alias; int numaliases; if((f = FontFileOpen(fileName))==NULL) { + ErrorF("Warning: FontEncIdentify() can't open fileName='%s', errno=%d\n", + fileName, (int)errno); return NULL; } encoding = parseEncodingFile(f, 1); FontFileClose(f); if(!encoding) return NULL; numaliases = 0; if(encoding->aliases) for(alias = encoding->aliases; *alias; alias++) numaliases++; names = (char**)xalloc((numaliases+2)*sizeof(char*)); if(names == NULL) { if(encoding->aliases) xfree(encoding->aliases); xfree(encoding); return NULL; }