Instead of traversing a list of paragraphs, mark_attr_ends() now
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 22 Apr 2004 18:01:31 +0000 (18:01 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 22 Apr 2004 18:01:31 +0000 (18:01 +0000)
merely traverses a list of words, and main() takes responsibility
for applying it to each paragraph in the document. This is so that
it can _also_ be applied to the display form of each index entry,
which Jacob spotted wasn't previously being done.

git-svn-id: svn://svn.tartarus.org/sgt/halibut@4117 cda61777-01e9-0310-a592-d414129be87e

halibut.h
inputs/test.but
main.c
misc.c

index 26f2e4f..f3de665 100644 (file)
--- a/halibut.h
+++ b/halibut.h
@@ -348,7 +348,7 @@ char *rdtrimc(rdstringc *rs);
 
 int compare_wordlists(word *a, word *b);
 
 
 int compare_wordlists(word *a, word *b);
 
-void mark_attr_ends(paragraph *sourceform);
+void mark_attr_ends(word *words);
 
 typedef struct tagWrappedLine wrappedline;
 struct tagWrappedLine {
 
 typedef struct tagWrappedLine wrappedline;
 struct tagWrappedLine {
index abdafcd..cd08ef6 100644 (file)
@@ -32,7 +32,7 @@ a bit]
 
 \define{eur} \u20AC{EUR }
 
 
 \define{eur} \u20AC{EUR }
 
-\versionid $Id: test.but,v 1.29 2004/04/20 19:20:55 simon Exp $
+\versionid $Id: test.but,v 1.30 2004/04/22 18:01:31 simon Exp $
 
 \C{ch\\ap} First chapter title; for similar wrapping reasons this
 chapter title will be ludicrously long. I wonder how much more
 
 \C{ch\\ap} First chapter title; for similar wrapping reasons this
 chapter title will be ludicrously long. I wonder how much more
@@ -219,6 +219,9 @@ whitespace).
 
 It also contains a \W{http://www.tartarus.org/}{hyperlink}.
 
 
 It also contains a \W{http://www.tartarus.org/}{hyperlink}.
 
+Also I'm going to index \i\c{-output} to ensure that its two
+components are displayed as a joined-up code fragment in the index.
+
 Here are some subsections with silly chapter titles and interesting
 use of Unicode. The Unicode oddities are in the titles rather than
 the body text because that way I get to test their handling in the
 Here are some subsections with silly chapter titles and interesting
 use of Unicode. The Unicode oddities are in the titles rather than
 the body text because that way I get to test their handling in the
diff --git a/main.c b/main.c
index 18d644c..847aea8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -288,8 +288,6 @@ int main(int argc, char **argv) {
 
        sfree(in.pushback);
 
 
        sfree(in.pushback);
 
-       mark_attr_ends(sourceform);
-
        sfree(infiles);
 
        keywords = get_keywords(sourceform);
        sfree(infiles);
 
        keywords = get_keywords(sourceform);
@@ -304,6 +302,20 @@ int main(int argc, char **argv) {
 
        build_index(idx);
 
 
        build_index(idx);
 
+       /*
+        * Set up attr_First / attr_Last / attr_Always, in the main
+        * document and in the index entries.
+        */
+       for (p = sourceform; p; p = p->next)
+           mark_attr_ends(p->words);
+       {
+           int i;
+           indexentry *entry;
+
+           for (i = 0; (entry = index234(idx->entries, i)) != NULL; i++)
+               mark_attr_ends(entry->text);
+       }
+
        if (debug) {
            index_debug(idx);
            dbg_prtkws(keywords);
        if (debug) {
            index_debug(idx);
            dbg_prtkws(keywords);
diff --git a/misc.c b/misc.c
index 647d642..12333e7 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -213,23 +213,22 @@ int compare_wordlists(word *a, word *b) {
     return compare_wordlists_literally(a, b);
 }
 
     return compare_wordlists_literally(a, b);
 }
 
-void mark_attr_ends(paragraph *sourceform) {
-    paragraph *p;
+void mark_attr_ends(word *words)
+{
     word *w, *wp;
     word *w, *wp;
-    for (p = sourceform; p; p = p->next) {
-       wp = NULL;
-       for (w = p->words; w; w = w->next) {
-           if (isattr(w->type)) {
-               int before = (wp && isattr(wp->type) &&
-                             sameattr(wp->type, w->type));
-               int after = (w->next && isattr(w->next->type) &&
-                            sameattr(w->next->type, w->type));
-               w->aux |= (before ?
-                          (after ? attr_Always : attr_Last) :
-                          (after ? attr_First : attr_Only));
-           }
-           wp = w;
+
+    wp = NULL;
+    for (w = words; w; w = w->next) {
+       if (isattr(w->type)) {
+           int before = (wp && isattr(wp->type) &&
+                         sameattr(wp->type, w->type));
+           int after = (w->next && isattr(w->next->type) &&
+                        sameattr(w->next->type, w->type));
+           w->aux |= (before ?
+                      (after ? attr_Always : attr_Last) :
+                      (after ? attr_First : attr_Only));
        }
        }
+       wp = w;
     }
 }
 
     }
 }