about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-03-21 21:58:15 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-03-21 21:58:15 +0000
commit0efebc6bd2e8d12529d063dd5f80b2549af1324b (patch)
tree97e80d5b2f8200a3aa7eeea77ed00c55ba50cc5a /lib
parentc738d9d9549e3c8093ce4a6ebd2e63d13c9ca1bc (diff)
downloadnetpbm-mirror-0efebc6bd2e8d12529d063dd5f80b2549af1324b.tar.gz
netpbm-mirror-0efebc6bd2e8d12529d063dd5f80b2549af1324b.tar.xz
netpbm-mirror-0efebc6bd2e8d12529d063dd5f80b2549af1324b.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1154 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r--lib/libpbmfont.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/libpbmfont.c b/lib/libpbmfont.c
index 902eaf0d..4e582c29 100644
--- a/lib/libpbmfont.c
+++ b/lib/libpbmfont.c
@@ -1102,18 +1102,22 @@ mk_argvn(char *        const s,
 
 
 static int
-readline(FILE *        const fp,
-         char *        const buf,
-         const char ** const arg) {
-
+readline(FILE *        const ifP,
+         char *        const line,
+         const char ** const wordList) {
+/*----------------------------------------------------------------------------
+   Read a 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).
+-----------------------------------------------------------------------------*/
     int retval;
     char * rc;
 
-    rc = fgets(buf, 1024, fp);
+    rc = fgets(line, 1024, ifP);
     if (rc == NULL)
         retval = -1;
     else
-        retval = mk_argvn(buf, arg, 32);
+        retval = mk_argvn(line, wordList, 32);
 
     return retval;
 }
@@ -1389,11 +1393,11 @@ processCharsLine(FILE *        const fp,
 
 
 static void
-processFontLine(FILE *        const fp,
-                const char *  const line,
-                const char ** const arg,
-                struct font * const fontP,
-                bool *        const endOfFontP) {
+processBdfFontLine(FILE *        const fp,
+                   const char *  const line,
+                   const char ** const arg,
+                   struct font * const fontP,
+                   bool *        const endOfFontP) {
 
     *endOfFontP = FALSE;  /* initial assumption */
 
@@ -1402,6 +1406,7 @@ processFontLine(FILE *        const fp,
     } else if (streq(arg[0], "SIZE")) {
         /* ignore */
     } else if (streq(arg[0], "STARTPROPERTIES")) {
+        /* Read off the properties and ignore them all */
         unsigned int const propCount = atoi(arg[1]);
         unsigned int i;
         for (i = 0; i < propCount; ++i) {
@@ -1419,7 +1424,7 @@ processFontLine(FILE *        const fp,
         fontP->y         = atoi(arg[4]);
     } else if (streq(arg[0], "ENDFONT")) {
         *endOfFontP = true;
-    } else if (!strcmp(arg[0], "CHARS"))
+    } else if (streq(arg[0], "CHARS"))
         processCharsLine(fp, arg, fontP);
 }
 
@@ -1428,18 +1433,17 @@ processFontLine(FILE *        const fp,
 struct font *
 pbm_loadbdffont(const char * const name) {
 
-    FILE * fp;
-    char line[1024];
-    const char * arg[32];
+    FILE * ifP;
     struct font * fontP;
+    const char * wordList[32];
     bool endOfFont;
 
-    fp = fopen(name, "rb");
-    if (!fp)
+    ifP = fopen(name, "rb");
+    if (!ifP)
         pm_error("Unable to open BDF font file name '%s'.  errno=%d (%s)",
                  name, errno, strerror(errno));
 
-    expect(fp, "STARTFONT", arg);
+    expect(ifP, "STARTFONT", wordList);
 
     MALLOCVAR(fontP);
     if (fontP == NULL)
@@ -1459,12 +1463,14 @@ pbm_loadbdffont(const char * const name) {
     endOfFont = FALSE;
 
     while (!endOfFont) {
+        char line[1024];
+        const char * wordList[32];
         int rc;
-        rc = readline(fp, line, arg);
+        rc = readline(ifP, line, wordList);
         if (rc < 0)
             pm_error("End of file before ENDFONT statement in BDF font file");
 
-        processFontLine(fp, line, arg, fontP, &endOfFont);
+        processBdfFontLine(ifP, line, wordList, fontP, &endOfFont);
     }
     return fontP;
 }