\lcont and \quote were being confused by whitespace (in particular,
[sgt/halibut] / input.c
diff --git a/input.c b/input.c
index 95a7709..429b4d5 100644 (file)
--- a/input.c
+++ b/input.c
@@ -592,14 +592,17 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
                     */
                    dtor(t), t = get_token(in);
                }
-               if (t.type == tok_eop || t.type == tok_eof)
+               if (t.type == tok_eop || t.type == tok_eof ||
+                   t.type == tok_rbrace) { /* might be } terminating \lcont */
+                   if (t.type == tok_rbrace)
+                       already = TRUE;
                    break;
-               else if (t.type == tok_cmd && t.cmd == c_c)
+               } else if (t.type == tok_cmd && t.cmd == c_c) {
                    wtype = word_WeakCode;
-               else if (t.type == tok_cmd && t.cmd == c_e &&
-                        wtype == word_WeakCode)
+               else if (t.type == tok_cmd && t.cmd == c_e &&
+                          wtype == word_WeakCode) {
                    wtype = word_Emph;
-               else {
+               else {
                    error(err_brokencodepara, &t.pos);
                    prev_para_type = par.type;
                    addpara(par, ret);
@@ -633,6 +636,16 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
                continue;
            }
 
+           /*
+            * Also expect, and swallow, any whitespace after that
+            * (a newline before a code paragraph wouldn't be
+            * surprising).
+            */
+           do {
+               dtor(t), t = get_token(in);
+           } while (t.type == tok_white);
+           already = TRUE;
+
            if (cmd == c_lcont) {
                /*
                 * \lcont causes a continuation of a list item into
@@ -999,8 +1012,16 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx) {
                    }
                    if (sitem->type & stack_idx) {
                        indexword->text = ustrdup(indexstr.text);
-                       if (index_downcase)
+                       if (index_downcase) {
+                           word *w;
+
                            ustrlow(indexword->text);
+                           ustrlow(indexstr.text);
+
+                           for (w = idxwordlist; w; w = w->next)
+                               if (w->text)
+                                   ustrlow(w->text);
+                       }
                        indexing = FALSE;
                        rdadd(&indexstr, L'\0');
                        index_merge(idx, FALSE, indexstr.text, idxwordlist);