diff options
Diffstat (limited to 'lib/libpbmfont.c')
-rw-r--r-- | lib/libpbmfont.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/libpbmfont.c b/lib/libpbmfont.c index a23abf9e..793de6c5 100644 --- a/lib/libpbmfont.c +++ b/lib/libpbmfont.c @@ -1106,20 +1106,28 @@ readline(FILE * const ifP, char * const line, const char ** const wordList) { /*---------------------------------------------------------------------------- - Read a line from file *ifP. Return the value of the whole line + Read a nonblank line from file *ifP. Return the value of the whole line in *buf (must be at least 1024 bytes long), and parse it into words in *wordList (must have at least 32 entries). + + If there is no nonblank line before EOF, return rc == -1. -----------------------------------------------------------------------------*/ - int retval; - char * rc; + bool gotLine; + bool error; - rc = fgets(line, 1024, ifP); - if (rc == NULL) - retval = -1; - else - retval = mk_argvn(line, wordList, 32); + for (gotLine = false, error = false; !gotLine && !error; ) { + char * rc; - return retval; + rc = fgets(line, 1024, ifP); + if (rc == NULL) + error = true; + else { + mk_argvn(line, wordList, 32); + if (wordList[0] != NULL) + gotLine = true; + } + } + return error ? -1 : 0; } @@ -1412,12 +1420,14 @@ processBdfFontLine(FILE * const fp, struct font * const fontP, bool * const endOfFontP) { /*---------------------------------------------------------------------------- - Process a line just read from a BDF font file. + Process a nonblank line just read from a BDF font file. This processing may involve reading more lines. -----------------------------------------------------------------------------*/ *endOfFontP = FALSE; /* initial assumption */ + assert(arg[0] != NULL); /* Entry condition */ + if (streq(arg[0], "COMMENT")) { /* ignore */ } else if (streq(arg[0], "SIZE")) { @@ -1441,8 +1451,11 @@ processBdfFontLine(FILE * const fp, fontP->y = atoi(arg[4]); } else if (streq(arg[0], "ENDFONT")) { *endOfFontP = true; - } else if (streq(arg[0], "CHARS")) + } else if (streq(arg[0], "CHARS")) { processChars(fp, arg, fontP); + } else { + /* ignore */ + } } |