2 * info backend for Halibut
4 * Possible future work:
6 * - configurable indentation, bullets, emphasis, quotes etc?
8 * - configurable choice of how to allocate node names?
9 * + possibly a template-like approach, choosing node names to
10 * be the full section title or perhaps the internal keyword?
11 * + neither of those seems quite right. Perhaps instead a
12 * Windows Help-like mechanism, where a magic config
13 * directive allows user choice of name for every node.
14 * + Only trouble with that is, now what happens to the section
15 * numbers? Do they become completely vestigial and just sit
16 * in the title text of each node? Or do we keep them in the
17 * menus somehow? I think people might occasionally want to
18 * go to a section by number, if only because all the _other_
19 * formats of the same document will reference the numbers
20 * all the time. So our menu lines could look like one of
22 * * Nodename: Section 1.2. Title of section.
23 * * Section 1.2: Nodename. Title of section.
25 * - might be helpful to diagnose duplicate node names!
38 typedef struct node_tag node
;
41 node
*up
, *prev
, *next
, *lastchild
;
42 int pos
, started_menu
, filenum
;
53 static int info_convert(wchar_t *, char **);
55 static void info_heading(rdstringc
*, word
*, word
*, int);
56 static void info_rule(rdstringc
*, int, int);
57 static void info_para(rdstringc
*, word
*, char *, word
*, keywordlist
*,
59 static void info_codepara(rdstringc
*, word
*, int, int);
60 static void info_versionid(rdstringc
*, word
*);
61 static void info_menu_item(rdstringc
*, node
*, paragraph
*);
62 static word
*info_transform_wordlist(word
*, keywordlist
*);
63 static int info_check_index(word
*, node
*, indexdata
*);
65 static void info_rdaddwc(rdstringc
*, word
*, word
*, int);
67 static node
*info_node_new(char *name
);
68 static char *info_node_name(paragraph
*p
);
70 static infoconfig
info_configure(paragraph
*source
) {
76 ret
.filename
= dupstr("output.info");
77 ret
.maxfilesize
= 64 << 10;
79 for (; source
; source
= source
->next
) {
80 if (source
->type
== para_Config
) {
81 if (!ustricmp(source
->keyword
, L
"info-filename")) {
83 ret
.filename
= utoa_dup(uadv(source
->keyword
));
84 } else if (!ustricmp(source
->keyword
, L
"info-max-file-size")) {
85 ret
.maxfilesize
= utoi(uadv(source
->keyword
));
93 paragraph
*info_config_filename(char *filename
)
96 wchar_t *ufilename
, *up
;
100 memset(p
, 0, sizeof(*p
));
101 p
->type
= para_Config
;
103 p
->fpos
.filename
= "<command line>";
104 p
->fpos
.line
= p
->fpos
.col
= -1;
106 ufilename
= ufroma_dup(filename
);
107 len
= ustrlen(ufilename
) + 2 + lenof(L
"info-filename");
108 p
->keyword
= mknewa(wchar_t, len
);
110 ustrcpy(up
, L
"info-filename");
112 ustrcpy(up
, ufilename
);
115 assert(up
- p
->keyword
< len
);
121 void info_backend(paragraph
*sourceform
, keywordlist
*keywords
,
122 indexdata
*idx
, void *unused
) {
125 word
*prefix
, *body
, *wp
;
128 int nesting
, nestindent
;
129 int indentb
, indenta
;
132 rdstringc intro_text
= { 0, 0, NULL
};
133 node
*topnode
, *currnode
;
140 int width
= 70, listindentbefore
= 1, listindentafter
= 3;
141 int indent_code
= 2, index_width
= 40;
145 conf
= info_configure(sourceform
);
148 * Go through and create a node for each section.
150 topnode
= info_node_new("Top");
152 for (p
= sourceform
; p
; p
= p
->next
) switch (p
->type
) {
158 case para_UnnumberedChapter
:
162 node
*newnode
, *upnode
;
165 nodename
= info_node_name(p
);
166 newnode
= info_node_new(nodename
);
169 p
->private_data
= newnode
;
172 upnode
= (node
*)p
->parent
->private_data
;
176 newnode
->up
= upnode
;
178 currnode
->next
= newnode
;
179 newnode
->prev
= currnode
;
181 currnode
->listnext
= newnode
;
188 * Set up the display form of each index entry.
194 for (i
= 0; (entry
= index234(idx
->entries
, i
)) != NULL
; i
++) {
195 info_idx
*ii
= mknew(info_idx
);
196 rdstringc rs
= { 0, 0, NULL
};
198 ii
->nnodes
= ii
->nodesize
= 0;
201 info_rdaddwc(&rs
, entry
->text
, NULL
, FALSE
);
205 entry
->backend_data
= ii
;
210 * An Info file begins with a piece of introductory text which
211 * is apparently never shown anywhere. This seems to me to be a
212 * good place to put the copyright notice and the version IDs.
213 * Also, Info directory entries are expected to go here.
217 "This Info file generated by Halibut, ");
218 rdaddsc(&intro_text
, version
);
219 rdaddsc(&intro_text
, "\n\n");
221 for (p
= sourceform
; p
; p
= p
->next
)
222 if (p
->type
== para_Config
&&
223 !ustricmp(p
->keyword
, L
"info-dir-entry")) {
224 wchar_t *section
, *shortname
, *longname
, *kw
;
227 section
= uadv(p
->keyword
);
228 shortname
= *section ?
uadv(section
) : NULL
;
229 longname
= *shortname ?
uadv(shortname
) : NULL
;
230 kw
= *longname ?
uadv(longname
) : NULL
;
233 error(err_infodirentry
, &p
->fpos
);
237 rdaddsc(&intro_text
, "INFO-DIR-SECTION ");
238 s
= utoa_dup(section
);
239 rdaddsc(&intro_text
, s
);
241 rdaddsc(&intro_text
, "\nSTART-INFO-DIR-ENTRY\n* ");
242 s
= utoa_dup(shortname
);
243 rdaddsc(&intro_text
, s
);
245 rdaddsc(&intro_text
, ": (");
246 s
= dupstr(conf
.filename
);
247 if (strlen(s
) > 5 && !strcmp(s
+strlen(s
)-5, ".info"))
248 s
[strlen(s
)-5] = '\0';
249 rdaddsc(&intro_text
, s
);
251 rdaddsc(&intro_text
, ")");
253 keyword
*kwl
= kw_lookup(keywords
, kw
);
254 if (kwl
&& kwl
->para
->private_data
) {
255 node
*n
= (node
*)kwl
->para
->private_data
;
256 rdaddsc(&intro_text
, n
->name
);
259 rdaddsc(&intro_text
, ". ");
260 s
= utoa_dup(longname
);
261 rdaddsc(&intro_text
, s
);
263 rdaddsc(&intro_text
, "\nEND-INFO-DIR-ENTRY\n\n");
266 for (p
= sourceform
; p
; p
= p
->next
)
267 if (p
->type
== para_Copyright
)
268 info_para(&intro_text
, NULL
, NULL
, p
->words
, keywords
,
271 for (p
= sourceform
; p
; p
= p
->next
)
272 if (p
->type
== para_VersionID
)
273 info_versionid(&intro_text
, p
->words
);
275 if (intro_text
.text
[intro_text
.pos
-1] != '\n')
276 rdaddc(&intro_text
, '\n');
279 for (p
= sourceform
; p
; p
= p
->next
)
280 if (p
->type
== para_Title
)
281 info_heading(&topnode
->text
, NULL
, p
->words
, width
);
283 nestindent
= listindentbefore
+ listindentafter
;
288 /* Do the main document */
289 for (p
= sourceform
; p
; p
= p
->next
) switch (p
->type
) {
296 assert(nesting
>= 0);
300 nesting
+= nestindent
;
303 nesting
-= nestindent
;
304 assert(nesting
>= 0);
308 * Things we ignore because we've already processed them or
309 * aren't going to touch them in this pass.
313 case para_Biblio
: /* only touch BiblioCited */
324 case para_UnnumberedChapter
:
327 currnode
= p
->private_data
;
329 assert(currnode
->up
);
331 if (!currnode
->up
->started_menu
) {
332 rdaddsc(&currnode
->up
->text
, "* Menu:\n\n");
333 currnode
->up
->started_menu
= TRUE
;
335 info_menu_item(&currnode
->up
->text
, currnode
, p
);
337 has_index
|= info_check_index(p
->words
, currnode
, idx
);
338 info_heading(&currnode
->text
, p
->kwtext
, p
->words
, width
);
343 info_rule(&currnode
->text
, nesting
, width
- nesting
);
348 case para_DescribedThing
:
349 case para_Description
:
350 case para_BiblioCited
:
352 case para_NumberedList
:
353 has_index
|= info_check_index(p
->words
, currnode
, idx
);
354 if (p
->type
== para_Bullet
) {
357 bullet
.type
= word_Normal
;
358 bullet
.text
= L
"-"; /* FIXME: configurability */
361 indentb
= listindentbefore
;
362 indenta
= listindentafter
;
363 } else if (p
->type
== para_NumberedList
) {
365 prefixextra
= "."; /* FIXME: configurability */
366 indentb
= listindentbefore
;
367 indenta
= listindentafter
;
368 } else if (p
->type
== para_Description
) {
371 indentb
= listindentbefore
;
372 indenta
= listindentafter
;
376 indentb
= indenta
= 0;
378 if (p
->type
== para_BiblioCited
) {
379 body
= dup_word_list(p
->kwtext
);
380 for (wp
= body
; wp
->next
; wp
= wp
->next
);
381 wp
->next
= &spaceword
;
382 spaceword
.next
= p
->words
;
383 spaceword
.alt
= NULL
;
384 spaceword
.type
= word_WhiteSpace
;
385 spaceword
.text
= NULL
;
390 info_para(&currnode
->text
, prefix
, prefixextra
, body
, keywords
,
391 nesting
+ indentb
, indenta
,
392 width
- nesting
- indentb
- indenta
);
395 free_word_list(body
);
400 info_codepara(&currnode
->text
, p
->words
,
401 nesting
+ indent_code
,
402 width
- nesting
- 2 * indent_code
);
407 * Create an index node if required.
414 newnode
= info_node_new("Index");
415 newnode
->up
= topnode
;
417 currnode
->next
= newnode
;
418 newnode
->prev
= currnode
;
419 currnode
->listnext
= newnode
;
421 rdaddsc(&newnode
->text
, "Index\n-----\n\n");
423 info_menu_item(&topnode
->text
, newnode
, NULL
);
425 for (i
= 0; (entry
= index234(idx
->entries
, i
)) != NULL
; i
++) {
426 info_idx
*ii
= (info_idx
*)entry
->backend_data
;
428 for (j
= 0; j
< ii
->nnodes
; j
++) {
429 int pos0
= newnode
->text
.pos
;
431 * When we have multiple references for a single
432 * index term, we only display the actual term on
433 * the first line, to make it clear that the terms
434 * really are the same.
437 rdaddsc(&newnode
->text
, ii
->text
);
438 for (k
= newnode
->text
.pos
- pos0
; k
< index_width
; k
++)
439 rdaddc(&newnode
->text
, ' ');
440 rdaddsc(&newnode
->text
, " *Note ");
441 rdaddsc(&newnode
->text
, ii
->nodes
[j
]->name
);
442 rdaddsc(&newnode
->text
, "::\n");
448 * Finalise the text of each node, by adding the ^_ delimiter
449 * and the node line at the top.
451 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
452 char *origtext
= currnode
->text
.text
;
453 currnode
->text
.text
= NULL
;
454 currnode
->text
.pos
= currnode
->text
.size
= 0;
455 rdaddsc(&currnode
->text
, "\037\nFile: ");
456 rdaddsc(&currnode
->text
, conf
.filename
);
457 rdaddsc(&currnode
->text
, ", Node: ");
458 rdaddsc(&currnode
->text
, currnode
->name
);
459 if (currnode
->prev
) {
460 rdaddsc(&currnode
->text
, ", Prev: ");
461 rdaddsc(&currnode
->text
, currnode
->prev
->name
);
463 rdaddsc(&currnode
->text
, ", Up: ");
464 rdaddsc(&currnode
->text
, (currnode
->up ?
465 currnode
->up
->name
: "(dir)"));
466 if (currnode
->next
) {
467 rdaddsc(&currnode
->text
, ", Next: ");
468 rdaddsc(&currnode
->text
, currnode
->next
->name
);
470 rdaddsc(&currnode
->text
, "\n\n");
471 rdaddsc(&currnode
->text
, origtext
);
473 * Just make _absolutely_ sure we end with a newline.
475 if (currnode
->text
.text
[currnode
->text
.pos
-1] != '\n')
476 rdaddc(&currnode
->text
, '\n');
482 * Compute the offsets for the tag table.
484 filepos
= intro_text
.pos
;
485 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
486 currnode
->pos
= filepos
;
487 filepos
+= currnode
->text
.pos
;
491 * Split into sub-files.
493 if (conf
.maxfilesize
> 0) {
494 int currfilesize
= intro_text
.pos
, currfilenum
= 1;
495 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
496 if (currfilesize
> intro_text
.pos
&&
497 currfilesize
+ currnode
->text
.pos
> conf
.maxfilesize
) {
499 currfilesize
= intro_text
.pos
;
501 currnode
->filenum
= currfilenum
;
502 currfilesize
+= currnode
->text
.pos
;
507 * Write the primary output file.
509 fp
= fopen(conf
.filename
, "w");
511 error(err_cantopenw
, conf
.filename
);
514 fputs(intro_text
.text
, fp
);
515 if (conf
.maxfilesize
== 0) {
516 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
517 fputs(currnode
->text
.text
, fp
);
520 fprintf(fp
, "\037\nIndirect:\n");
521 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
522 if (filenum
!= currnode
->filenum
) {
523 filenum
= currnode
->filenum
;
524 fprintf(fp
, "%s-%d: %d\n", conf
.filename
, filenum
,
528 fprintf(fp
, "\037\nTag Table:\n");
529 if (conf
.maxfilesize
> 0)
530 fprintf(fp
, "(Indirect)\n");
531 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
532 fprintf(fp
, "Node: %s\177%d\n", currnode
->name
, currnode
->pos
);
533 fprintf(fp
, "\037\nEnd Tag Table\n");
537 * Write the subfiles.
539 if (conf
.maxfilesize
> 0) {
543 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
544 if (filenum
!= currnode
->filenum
) {
547 filenum
= currnode
->filenum
;
551 fname
= mknewa(char, strlen(conf
.filename
) + 40);
552 sprintf(fname
, "%s-%d", conf
.filename
, filenum
);
553 fp
= fopen(fname
, "w");
555 error(err_cantopenw
, fname
);
559 fputs(intro_text
.text
, fp
);
561 fputs(currnode
->text
.text
, fp
);
569 static int info_check_index(word
*w
, node
*n
, indexdata
*idx
)
573 for (; w
; w
= w
->next
) {
574 if (w
->type
== word_IndexRef
) {
578 tag
= index_findtag(idx
, w
->text
);
582 for (i
= 0; i
< tag
->nrefs
; i
++) {
583 indexentry
*entry
= tag
->refs
[i
];
584 info_idx
*ii
= (info_idx
*)entry
->backend_data
;
586 if (ii
->nnodes
> 0 && ii
->nodes
[ii
->nnodes
-1] == n
) {
588 * If the same index term is indexed twice
589 * within the same section, we only want to
590 * mention it once in the index. So do nothing
596 if (ii
->nnodes
>= ii
->nodesize
) {
598 ii
->nodes
= resize(ii
->nodes
, ii
->nodesize
);
601 ii
->nodes
[ii
->nnodes
++] = n
;
612 * Convert a wide string into a string of chars. If `result' is
613 * non-NULL, mallocs the resulting string and stores a pointer to
614 * it in `*result'. If `result' is NULL, merely checks whether all
615 * characters in the string are feasible for the output character
618 * Return is nonzero if all characters are OK. If not all
619 * characters are OK but `result' is non-NULL, a result _will_
620 * still be generated!
622 static int info_convert(wchar_t *s
, char **result
) {
624 * FIXME. Currently this is ISO8859-1 only.
626 int doing
= (result
!= 0);
629 int plen
= 0, psize
= 0;
635 if ((c
>= 32 && c
<= 126) ||
636 (c
>= 160 && c
<= 255)) {
640 /* Char is not OK. */
642 outc
= 0xBF; /* approximate the good old DEC `uh?' */
647 p
= resize(p
, psize
);
653 p
= resize(p
, plen
+1);
660 static word
*info_transform_wordlist(word
*words
, keywordlist
*keywords
)
662 word
*ret
= dup_word_list(words
);
666 for (w
= ret
; w
; w
= w
->next
) {
667 w
->private_data
= NULL
;
668 if (w
->type
== word_UpperXref
|| w
->type
== word_LowerXref
) {
669 kwl
= kw_lookup(keywords
, w
->text
);
671 if (kwl
->para
->type
== para_NumberedList
||
672 kwl
->para
->type
== para_BiblioCited
) {
674 * In Info, we do nothing special for xrefs to
675 * numbered list items or bibliography entries.
680 * An xref to a different section has its text
681 * completely replaced.
687 if (w2
->type
== word_XrefEnd
) {
697 * Now w is the UpperXref / LowerXref we
698 * started with, and w4 is the next word after
699 * the corresponding XrefEnd (if any). The
700 * simplest thing is just to stick a pointer to
701 * the target node structure in the private
702 * data field of the xref word, and let
703 * info_rdaddwc and friends read the node name
707 w
->private_data
= kwl
->para
->private_data
;
708 assert(w
->private_data
);
717 static void info_rdaddwc(rdstringc
*rs
, word
*words
, word
*end
, int xrefs
) {
720 for (; words
&& words
!= end
; words
= words
->next
) switch (words
->type
) {
731 case word_WhiteSpace
:
734 case word_WkCodeSpace
:
738 case word_WkCodeQuote
:
739 assert(words
->type
!= word_CodeQuote
&&
740 words
->type
!= word_WkCodeQuote
);
741 if (towordstyle(words
->type
) == word_Emph
&&
742 (attraux(words
->aux
) == attr_First
||
743 attraux(words
->aux
) == attr_Only
))
744 rdaddc(rs
, '_'); /* FIXME: configurability */
745 else if (towordstyle(words
->type
) == word_Code
&&
746 (attraux(words
->aux
) == attr_First
||
747 attraux(words
->aux
) == attr_Only
))
748 rdaddc(rs
, '`'); /* FIXME: configurability */
749 if (removeattr(words
->type
) == word_Normal
) {
750 if (info_convert(words
->text
, &c
))
753 info_rdaddwc(rs
, words
->alt
, NULL
, FALSE
);
755 } else if (removeattr(words
->type
) == word_WhiteSpace
) {
757 } else if (removeattr(words
->type
) == word_Quote
) {
758 rdaddc(rs
, quoteaux(words
->aux
) == quote_Open ?
'`' : '\'');
759 /* FIXME: configurability */
761 if (towordstyle(words
->type
) == word_Emph
&&
762 (attraux(words
->aux
) == attr_Last
||
763 attraux(words
->aux
) == attr_Only
))
764 rdaddc(rs
, '_'); /* FIXME: configurability */
765 else if (towordstyle(words
->type
) == word_Code
&&
766 (attraux(words
->aux
) == attr_Last
||
767 attraux(words
->aux
) == attr_Only
))
768 rdaddc(rs
, '\''); /* FIXME: configurability */
773 if (xrefs
&& words
->private_data
) {
774 rdaddsc(rs
, "*Note ");
775 rdaddsc(rs
, ((node
*)words
->private_data
)->name
);
782 static int info_width_internal(word
*words
, int xrefs
);
784 static int info_width_internal_list(word
*words
, int xrefs
) {
787 w
+= info_width_internal(words
, xrefs
);
793 static int info_width_internal(word
*words
, int xrefs
) {
794 switch (words
->type
) {
805 return (((words
->type
== word_Emph
||
806 words
->type
== word_Code
)
807 ?
(attraux(words
->aux
) == attr_Only ?
2 :
808 attraux(words
->aux
) == attr_Always ?
0 : 1)
810 (info_convert(words
->text
, NULL
) ?
811 ustrlen(words
->text
) :
812 info_width_internal_list(words
->alt
, xrefs
)));
814 case word_WhiteSpace
:
817 case word_WkCodeSpace
:
821 case word_WkCodeQuote
:
822 assert(words
->type
!= word_CodeQuote
&&
823 words
->type
!= word_WkCodeQuote
);
824 return (((towordstyle(words
->type
) == word_Emph
||
825 towordstyle(words
->type
) == word_Code
)
826 ?
(attraux(words
->aux
) == attr_Only ?
2 :
827 attraux(words
->aux
) == attr_Always ?
0 : 1)
832 if (xrefs
&& words
->private_data
) {
833 /* "*Note " plus "::" comes to 8 characters */
834 return 8 + strlen(((node
*)words
->private_data
)->name
);
838 return 0; /* should never happen */
841 static int info_width_noxrefs(void *ctx
, word
*words
)
844 return info_width_internal(words
, FALSE
);
846 static int info_width_xrefs(void *ctx
, word
*words
)
849 return info_width_internal(words
, TRUE
);
852 static void info_heading(rdstringc
*text
, word
*tprefix
,
853 word
*words
, int width
) {
854 rdstringc t
= { 0, 0, NULL
};
856 int firstlinewidth
, wrapwidth
;
858 wrappedline
*wrapping
, *p
;
861 info_rdaddwc(&t
, tprefix
, NULL
, FALSE
);
862 rdaddsc(&t
, ": "); /* FIXME: configurability */
864 margin
= length
= (t
.text ?
strlen(t
.text
) : 0);
867 firstlinewidth
= width
- length
;
870 wrapping
= wrap_para(words
, firstlinewidth
, wrapwidth
,
871 info_width_noxrefs
, NULL
, 0);
872 for (p
= wrapping
; p
; p
= p
->next
) {
873 info_rdaddwc(&t
, p
->begin
, p
->end
, FALSE
);
874 length
= (t
.text ?
strlen(t
.text
) : 0);
875 for (i
= 0; i
< margin
; i
++)
877 rdaddsc(text
, t
.text
);
879 for (i
= 0; i
< margin
; i
++)
894 static void info_rule(rdstringc
*text
, int indent
, int width
) {
895 while (indent
--) rdaddc(text
, ' ');
896 while (width
--) rdaddc(text
, '-');
901 static void info_para(rdstringc
*text
, word
*prefix
, char *prefixextra
,
902 word
*input
, keywordlist
*keywords
,
903 int indent
, int extraindent
, int width
) {
904 wrappedline
*wrapping
, *p
;
906 rdstringc pfx
= { 0, 0, NULL
};
909 int firstlinewidth
= width
;
911 words
= info_transform_wordlist(input
, keywords
);
914 info_rdaddwc(&pfx
, prefix
, NULL
, FALSE
);
916 rdaddsc(&pfx
, prefixextra
);
917 for (i
= 0; i
< indent
; i
++)
919 rdaddsc(text
, pfx
.text
);
920 /* If the prefix is too long, shorten the first line to fit. */
921 e
= extraindent
- strlen(pfx
.text
);
923 firstlinewidth
+= e
; /* this decreases it, since e < 0 */
924 if (firstlinewidth
< 0) {
925 e
= indent
+ extraindent
;
926 firstlinewidth
= width
;
933 e
= indent
+ extraindent
;
935 wrapping
= wrap_para(words
, firstlinewidth
, width
, info_width_xrefs
,
937 for (p
= wrapping
; p
; p
= p
->next
) {
938 for (i
= 0; i
< e
; i
++)
940 info_rdaddwc(text
, p
->begin
, p
->end
, TRUE
);
942 e
= indent
+ extraindent
;
947 free_word_list(words
);
950 static void info_codepara(rdstringc
*text
, word
*words
,
951 int indent
, int width
) {
954 for (; words
; words
= words
->next
) if (words
->type
== word_WeakCode
) {
956 info_convert(words
->text
, &c
);
957 if (strlen(c
) > (size_t)width
) {
960 for (i
= 0; i
< indent
; i
++)
970 static void info_versionid(rdstringc
*text
, word
*words
) {
971 rdaddc(text
, '['); /* FIXME: configurability */
972 info_rdaddwc(text
, words
, NULL
, FALSE
);
973 rdaddsc(text
, "]\n");
976 static node
*info_node_new(char *name
)
982 n
->text
.pos
= n
->text
.size
= 0;
983 n
->up
= n
->next
= n
->prev
= n
->lastchild
= n
->listnext
= NULL
;
984 n
->name
= dupstr(name
);
985 n
->started_menu
= FALSE
;
990 static char *info_node_name(paragraph
*par
)
992 rdstringc rsc
= { 0, 0, NULL
};
994 info_rdaddwc(&rsc
, par
->kwtext ? par
->kwtext
: par
->words
, NULL
, FALSE
);
997 * We cannot have commas or colons in a node name. Remove any
998 * that we find, with a warning.
1002 if (*p
== ':' || *p
== ',') {
1003 error(err_infonodechar
, &par
->fpos
, *p
);
1014 static void info_menu_item(rdstringc
*text
, node
*n
, paragraph
*p
)
1017 * FIXME: Depending on how we're doing node names in this info
1018 * file, we might want to do
1020 * * Node name:: Chapter title
1024 * * Chapter number: Node name.
1028 rdaddsc(text
, "* ");
1029 rdaddsc(text
, n
->name
);
1030 rdaddsc(text
, "::");
1033 info_rdaddwc(text
, p
->words
, NULL
, FALSE
);