Paging through the newly compressed PDF manual to make sure it
[sgt/halibut] / input.c
diff --git a/input.c b/input.c
index a616ac9..d1b529d 100644 (file)
--- a/input.c
+++ b/input.c
@@ -426,6 +426,7 @@ token get_token(input *in) {
            c == '#' || c == '{' || c == '}' || c == '.') {
            /* single-char command */
            rdadd(&rs, c);
+           prevpos = rsc.pos;
        } else if (c == 'u') {
            int len = 0;
            do {
@@ -609,7 +610,7 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx,
            stack_style = 2,           /* \e, \c, \cw */
            stack_idx = 4,             /* \I, \i, \ii */
            stack_hyper = 8,           /* \W */
-           stack_quote = 16,          /* \q */
+           stack_quote = 16           /* \q */
        } type;
        word **whptr;                  /* to restore from \u alternatives */
        word **idximplicit;            /* to restore from \u alternatives */
@@ -1528,7 +1529,17 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx,
        }
        stk_free(parsestk);
        prev_para_type = par.type;
-       addpara(par, ret);
+       /*
+        * Before we add the paragraph to the output list, we
+        * should check that there was any text in it at all; there
+        * might not be if (for example) the paragraph contained
+        * nothing but an unrecognised command sequence, and if we
+        * put an empty paragraph on the list it may confuse the
+        * back ends later on.
+        */
+       if (par.words) {
+           addpara(par, ret);
+       }
        if (t.type == tok_eof)
            already = TRUE;
     }
@@ -1565,7 +1576,14 @@ paragraph *read_input(input *in, indexdata *idx) {
            in->csstate = charset_init_state;
            in->wcpos = in->nwc = 0;
            in->pushback_chars = NULL;
-           read_file(&hptr, in, idx, macros);
+           if (strcmp(in->filenames[in->currindex] +
+                      strlen(in->filenames[in->currindex]) - 4, ".afm") == 0)
+               read_afm_file(in);
+           else if (strcmp(in->filenames[in->currindex] +
+                      strlen(in->filenames[in->currindex]) - 4, ".pfa") == 0)
+               read_pfa_file(in);
+           else
+               read_file(&hptr, in, idx, macros);
        }
        in->currindex++;
     }