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
,
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;
143 IGNORE(keywords
); /* we don't happen to need this */
144 IGNORE(idx
); /* or this */
146 conf
= info_configure(sourceform
);
149 * Go through and create a node for each section.
151 topnode
= info_node_new("Top");
153 for (p
= sourceform
; p
; p
= p
->next
) switch (p
->type
) {
159 case para_UnnumberedChapter
:
163 node
*newnode
, *upnode
;
166 nodename
= info_node_name(p
);
167 newnode
= info_node_new(nodename
);
170 p
->private_data
= newnode
;
173 upnode
= (node
*)p
->parent
->private_data
;
177 newnode
->up
= upnode
;
179 currnode
->next
= newnode
;
180 newnode
->prev
= currnode
;
182 currnode
->listnext
= newnode
;
189 * Set up the display form of each index entry.
195 for (i
= 0; (entry
= index234(idx
->entries
, i
)) != NULL
; i
++) {
196 info_idx
*ii
= mknew(info_idx
);
197 rdstringc rs
= { 0, 0, NULL
};
199 ii
->nnodes
= ii
->nodesize
= 0;
202 info_rdaddwc(&rs
, entry
->text
, NULL
, FALSE
);
206 entry
->backend_data
= ii
;
211 * An Info file begins with a piece of introductory text which
212 * is apparently never shown anywhere. This seems to me to be a
213 * good place to put the copyright notice and the version IDs.
214 * Also, Info directory entries are expected to go here.
218 "This Info file generated by Halibut, ");
219 rdaddsc(&intro_text
, version
);
220 rdaddsc(&intro_text
, "\n\n");
222 for (p
= sourceform
; p
; p
= p
->next
)
223 if (p
->type
== para_Config
&&
224 !ustricmp(p
->keyword
, L
"info-dir-entry")) {
225 wchar_t *section
, *shortname
, *longname
, *kw
;
228 section
= uadv(p
->keyword
);
229 shortname
= *section ?
uadv(section
) : NULL
;
230 longname
= *shortname ?
uadv(shortname
) : NULL
;
231 kw
= *longname ?
uadv(longname
) : NULL
;
234 error(err_infodirentry
, &p
->fpos
);
238 rdaddsc(&intro_text
, "INFO-DIR-SECTION ");
239 s
= utoa_dup(section
);
240 rdaddsc(&intro_text
, s
);
242 rdaddsc(&intro_text
, "\nSTART-INFO-DIR-ENTRY\n* ");
243 s
= utoa_dup(shortname
);
244 rdaddsc(&intro_text
, s
);
246 rdaddsc(&intro_text
, ": (");
247 s
= dupstr(conf
.filename
);
248 if (strlen(s
) > 5 && !strcmp(s
+strlen(s
)-5, ".info"))
249 s
[strlen(s
)-5] = '\0';
250 rdaddsc(&intro_text
, s
);
252 rdaddsc(&intro_text
, ")");
254 keyword
*kwl
= kw_lookup(keywords
, kw
);
255 if (kwl
&& kwl
->para
->private_data
) {
256 node
*n
= (node
*)kwl
->para
->private_data
;
257 rdaddsc(&intro_text
, n
->name
);
260 rdaddsc(&intro_text
, ". ");
261 s
= utoa_dup(longname
);
262 rdaddsc(&intro_text
, s
);
264 rdaddsc(&intro_text
, "\nEND-INFO-DIR-ENTRY\n\n");
267 for (p
= sourceform
; p
; p
= p
->next
)
268 if (p
->type
== para_Copyright
)
269 info_para(&intro_text
, NULL
, NULL
, p
->words
, keywords
,
272 for (p
= sourceform
; p
; p
= p
->next
)
273 if (p
->type
== para_VersionID
)
274 info_versionid(&intro_text
, p
->words
);
276 if (intro_text
.text
[intro_text
.pos
-1] != '\n')
277 rdaddc(&intro_text
, '\n');
280 for (p
= sourceform
; p
; p
= p
->next
)
281 if (p
->type
== para_Title
)
282 info_heading(&topnode
->text
, NULL
, p
->words
, width
);
284 nestindent
= listindentbefore
+ listindentafter
;
289 /* Do the main document */
290 for (p
= sourceform
; p
; p
= p
->next
) switch (p
->type
) {
297 assert(nesting
>= 0);
301 nesting
+= nestindent
;
304 nesting
-= nestindent
;
305 assert(nesting
>= 0);
309 * Things we ignore because we've already processed them or
310 * aren't going to touch them in this pass.
314 case para_Biblio
: /* only touch BiblioCited */
325 case para_UnnumberedChapter
:
328 currnode
= p
->private_data
;
330 assert(currnode
->up
);
332 if (!currnode
->up
->started_menu
) {
333 rdaddsc(&currnode
->up
->text
, "* Menu:\n\n");
334 currnode
->up
->started_menu
= TRUE
;
336 info_menu_item(&currnode
->up
->text
, currnode
, p
);
338 has_index
|= info_check_index(p
->words
, currnode
, idx
);
339 info_heading(&currnode
->text
, p
->kwtext
, p
->words
, width
);
344 info_rule(&currnode
->text
, nesting
, width
- nesting
);
349 case para_DescribedThing
:
350 case para_Description
:
351 case para_BiblioCited
:
353 case para_NumberedList
:
354 has_index
|= info_check_index(p
->words
, currnode
, idx
);
355 if (p
->type
== para_Bullet
) {
358 bullet
.type
= word_Normal
;
359 bullet
.text
= L
"-"; /* FIXME: configurability */
362 indentb
= listindentbefore
;
363 indenta
= listindentafter
;
364 } else if (p
->type
== para_NumberedList
) {
366 prefixextra
= "."; /* FIXME: configurability */
367 indentb
= listindentbefore
;
368 indenta
= listindentafter
;
369 } else if (p
->type
== para_Description
) {
372 indentb
= listindentbefore
;
373 indenta
= listindentafter
;
377 indentb
= indenta
= 0;
379 if (p
->type
== para_BiblioCited
) {
380 body
= dup_word_list(p
->kwtext
);
381 for (wp
= body
; wp
->next
; wp
= wp
->next
);
382 wp
->next
= &spaceword
;
383 spaceword
.next
= p
->words
;
384 spaceword
.alt
= NULL
;
385 spaceword
.type
= word_WhiteSpace
;
386 spaceword
.text
= NULL
;
391 info_para(&currnode
->text
, prefix
, prefixextra
, body
, keywords
,
392 nesting
+ indentb
, indenta
,
393 width
- nesting
- indentb
- indenta
);
396 free_word_list(body
);
401 info_codepara(&currnode
->text
, p
->words
,
402 nesting
+ indent_code
,
403 width
- nesting
- 2 * indent_code
);
408 * Create an index node if required.
415 newnode
= info_node_new("Index");
416 newnode
->up
= topnode
;
418 currnode
->next
= newnode
;
419 newnode
->prev
= currnode
;
420 currnode
->listnext
= newnode
;
422 rdaddsc(&newnode
->text
, "Index\n-----\n\n");
424 info_menu_item(&topnode
->text
, newnode
, NULL
);
426 for (i
= 0; (entry
= index234(idx
->entries
, i
)) != NULL
; i
++) {
427 info_idx
*ii
= (info_idx
*)entry
->backend_data
;
429 for (j
= 0; j
< ii
->nnodes
; j
++) {
430 int pos0
= newnode
->text
.pos
;
432 * When we have multiple references for a single
433 * index term, we only display the actual term on
434 * the first line, to make it clear that the terms
435 * really are the same.
438 rdaddsc(&newnode
->text
, ii
->text
);
439 for (k
= newnode
->text
.pos
- pos0
; k
< index_width
; k
++)
440 rdaddc(&newnode
->text
, ' ');
441 rdaddsc(&newnode
->text
, " *Note ");
442 rdaddsc(&newnode
->text
, ii
->nodes
[j
]->name
);
443 rdaddsc(&newnode
->text
, "::\n");
449 * Finalise the text of each node, by adding the ^_ delimiter
450 * and the node line at the top.
452 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
453 char *origtext
= currnode
->text
.text
;
454 currnode
->text
.text
= NULL
;
455 currnode
->text
.pos
= currnode
->text
.size
= 0;
456 rdaddsc(&currnode
->text
, "\037\nFile: ");
457 rdaddsc(&currnode
->text
, conf
.filename
);
458 rdaddsc(&currnode
->text
, ", Node: ");
459 rdaddsc(&currnode
->text
, currnode
->name
);
460 if (currnode
->prev
) {
461 rdaddsc(&currnode
->text
, ", Prev: ");
462 rdaddsc(&currnode
->text
, currnode
->prev
->name
);
464 rdaddsc(&currnode
->text
, ", Up: ");
465 rdaddsc(&currnode
->text
, (currnode
->up ?
466 currnode
->up
->name
: "(dir)"));
467 if (currnode
->next
) {
468 rdaddsc(&currnode
->text
, ", Next: ");
469 rdaddsc(&currnode
->text
, currnode
->next
->name
);
471 rdaddsc(&currnode
->text
, "\n\n");
472 rdaddsc(&currnode
->text
, origtext
);
474 * Just make _absolutely_ sure we end with a newline.
476 if (currnode
->text
.text
[currnode
->text
.pos
-1] != '\n')
477 rdaddc(&currnode
->text
, '\n');
483 * Compute the offsets for the tag table.
485 filepos
= intro_text
.pos
;
486 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
487 currnode
->pos
= filepos
;
488 filepos
+= currnode
->text
.pos
;
492 * Split into sub-files.
494 if (conf
.maxfilesize
> 0) {
495 int currfilesize
= intro_text
.pos
, currfilenum
= 1;
496 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
497 if (currfilesize
> intro_text
.pos
&&
498 currfilesize
+ currnode
->text
.pos
> conf
.maxfilesize
) {
500 currfilesize
= intro_text
.pos
;
502 currnode
->filenum
= currfilenum
;
503 currfilesize
+= currnode
->text
.pos
;
508 * Write the primary output file.
510 fp
= fopen(conf
.filename
, "w");
512 error(err_cantopenw
, conf
.filename
);
515 fputs(intro_text
.text
, fp
);
516 if (conf
.maxfilesize
== 0) {
517 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
518 fputs(currnode
->text
.text
, fp
);
521 fprintf(fp
, "\037\nIndirect:\n");
522 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
523 if (filenum
!= currnode
->filenum
) {
524 filenum
= currnode
->filenum
;
525 fprintf(fp
, "%s-%d: %d\n", conf
.filename
, filenum
,
529 fprintf(fp
, "\037\nTag Table:\n");
530 if (conf
.maxfilesize
> 0)
531 fprintf(fp
, "(Indirect)\n");
532 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
)
533 fprintf(fp
, "Node: %s\177%d\n", currnode
->name
, currnode
->pos
);
534 fprintf(fp
, "\037\nEnd Tag Table\n");
538 * Write the subfiles.
540 if (conf
.maxfilesize
> 0) {
544 for (currnode
= topnode
; currnode
; currnode
= currnode
->listnext
) {
545 if (filenum
!= currnode
->filenum
) {
548 filenum
= currnode
->filenum
;
552 fname
= mknewa(char, strlen(conf
.filename
) + 40);
553 sprintf(fname
, "%s-%d", conf
.filename
, filenum
);
554 fp
= fopen(fname
, "w");
556 error(err_cantopenw
, fname
);
560 fputs(intro_text
.text
, fp
);
562 fputs(currnode
->text
.text
, fp
);
570 static int info_check_index(word
*w
, node
*n
, indexdata
*idx
)
574 for (; w
; w
= w
->next
) {
575 if (w
->type
== word_IndexRef
) {
579 tag
= index_findtag(idx
, w
->text
);
583 for (i
= 0; i
< tag
->nrefs
; i
++) {
584 indexentry
*entry
= tag
->refs
[i
];
585 info_idx
*ii
= (info_idx
*)entry
->backend_data
;
587 if (ii
->nnodes
> 0 && ii
->nodes
[ii
->nnodes
-1] == n
) {
589 * If the same index term is indexed twice
590 * within the same section, we only want to
591 * mention it once in the index. So do nothing
597 if (ii
->nnodes
>= ii
->nodesize
) {
599 ii
->nodes
= resize(ii
->nodes
, ii
->nodesize
);
602 ii
->nodes
[ii
->nnodes
++] = n
;
613 * Convert a wide string into a string of chars. If `result' is
614 * non-NULL, mallocs the resulting string and stores a pointer to
615 * it in `*result'. If `result' is NULL, merely checks whether all
616 * characters in the string are feasible for the output character
619 * Return is nonzero if all characters are OK. If not all
620 * characters are OK but `result' is non-NULL, a result _will_
621 * still be generated!
623 static int info_convert(wchar_t *s
, char **result
) {
625 * FIXME. Currently this is ISO8859-1 only.
627 int doing
= (result
!= 0);
630 int plen
= 0, psize
= 0;
636 if ((c
>= 32 && c
<= 126) ||
637 (c
>= 160 && c
<= 255)) {
641 /* Char is not OK. */
643 outc
= 0xBF; /* approximate the good old DEC `uh?' */
648 p
= resize(p
, psize
);
654 p
= resize(p
, plen
+1);
661 static word
*info_transform_wordlist(word
*words
, keywordlist
*keywords
)
663 word
*ret
= dup_word_list(words
);
667 for (w
= ret
; w
; w
= w
->next
) {
668 w
->private_data
= NULL
;
669 if (w
->type
== word_UpperXref
|| w
->type
== word_LowerXref
) {
670 kwl
= kw_lookup(keywords
, w
->text
);
672 if (kwl
->para
->type
== para_NumberedList
||
673 kwl
->para
->type
== para_BiblioCited
) {
675 * In Info, we do nothing special for xrefs to
676 * numbered list items or bibliography entries.
681 * An xref to a different section has its text
682 * completely replaced.
688 if (w2
->type
== word_XrefEnd
) {
698 * Now w is the UpperXref / LowerXref we
699 * started with, and w4 is the next word after
700 * the corresponding XrefEnd (if any). The
701 * simplest thing is just to stick a pointer to
702 * the target node structure in the private
703 * data field of the xref word, and let
704 * info_rdaddwc and friends read the node name
708 w
->private_data
= kwl
->para
->private_data
;
709 assert(w
->private_data
);
718 static void info_rdaddwc(rdstringc
*rs
, word
*words
, word
*end
, int xrefs
) {
721 for (; words
&& words
!= end
; words
= words
->next
) switch (words
->type
) {
732 case word_WhiteSpace
:
735 case word_WkCodeSpace
:
739 case word_WkCodeQuote
:
740 assert(words
->type
!= word_CodeQuote
&&
741 words
->type
!= word_WkCodeQuote
);
742 if (towordstyle(words
->type
) == word_Emph
&&
743 (attraux(words
->aux
) == attr_First
||
744 attraux(words
->aux
) == attr_Only
))
745 rdaddc(rs
, '_'); /* FIXME: configurability */
746 else if (towordstyle(words
->type
) == word_Code
&&
747 (attraux(words
->aux
) == attr_First
||
748 attraux(words
->aux
) == attr_Only
))
749 rdaddc(rs
, '`'); /* FIXME: configurability */
750 if (removeattr(words
->type
) == word_Normal
) {
751 if (info_convert(words
->text
, &c
))
754 info_rdaddwc(rs
, words
->alt
, NULL
, FALSE
);
756 } else if (removeattr(words
->type
) == word_WhiteSpace
) {
758 } else if (removeattr(words
->type
) == word_Quote
) {
759 rdaddc(rs
, quoteaux(words
->aux
) == quote_Open ?
'`' : '\'');
760 /* FIXME: configurability */
762 if (towordstyle(words
->type
) == word_Emph
&&
763 (attraux(words
->aux
) == attr_Last
||
764 attraux(words
->aux
) == attr_Only
))
765 rdaddc(rs
, '_'); /* FIXME: configurability */
766 else if (towordstyle(words
->type
) == word_Code
&&
767 (attraux(words
->aux
) == attr_Last
||
768 attraux(words
->aux
) == attr_Only
))
769 rdaddc(rs
, '\''); /* FIXME: configurability */
774 if (xrefs
&& words
->private_data
) {
775 rdaddsc(rs
, "*Note ");
776 rdaddsc(rs
, ((node
*)words
->private_data
)->name
);
783 static int info_width_internal(word
*words
, int xrefs
);
785 static int info_width_internal_list(word
*words
, int xrefs
) {
788 w
+= info_width_internal(words
, xrefs
);
794 static int info_width_internal(word
*words
, int xrefs
) {
795 switch (words
->type
) {
806 return (((words
->type
== word_Emph
||
807 words
->type
== word_Code
)
808 ?
(attraux(words
->aux
) == attr_Only ?
2 :
809 attraux(words
->aux
) == attr_Always ?
0 : 1)
811 (info_convert(words
->text
, NULL
) ?
812 ustrlen(words
->text
) :
813 info_width_internal_list(words
->alt
, xrefs
)));
815 case word_WhiteSpace
:
818 case word_WkCodeSpace
:
822 case word_WkCodeQuote
:
823 assert(words
->type
!= word_CodeQuote
&&
824 words
->type
!= word_WkCodeQuote
);
825 return (((towordstyle(words
->type
) == word_Emph
||
826 towordstyle(words
->type
) == word_Code
)
827 ?
(attraux(words
->aux
) == attr_Only ?
2 :
828 attraux(words
->aux
) == attr_Always ?
0 : 1)
833 if (xrefs
&& words
->private_data
) {
834 /* "*Note " plus "::" comes to 8 characters */
835 return 8 + strlen(((node
*)words
->private_data
)->name
);
839 return 0; /* should never happen */
842 static int info_width_noxrefs(word
*words
)
844 return info_width_internal(words
, FALSE
);
846 static int info_width_xrefs(word
*words
)
848 return info_width_internal(words
, TRUE
);
851 static void info_heading(rdstringc
*text
, word
*tprefix
,
852 word
*words
, int width
) {
853 rdstringc t
= { 0, 0, NULL
};
855 int firstlinewidth
, wrapwidth
;
857 wrappedline
*wrapping
, *p
;
860 info_rdaddwc(&t
, tprefix
, NULL
, FALSE
);
861 rdaddsc(&t
, ": "); /* FIXME: configurability */
863 margin
= length
= (t
.text ?
strlen(t
.text
) : 0);
866 firstlinewidth
= width
- length
;
869 wrapping
= wrap_para(words
, firstlinewidth
, wrapwidth
, info_width_noxrefs
);
870 for (p
= wrapping
; p
; p
= p
->next
) {
871 info_rdaddwc(&t
, p
->begin
, p
->end
, FALSE
);
872 length
= (t
.text ?
strlen(t
.text
) : 0);
873 for (i
= 0; i
< margin
; i
++)
875 rdaddsc(text
, t
.text
);
877 for (i
= 0; i
< margin
; i
++)
892 static void info_rule(rdstringc
*text
, int indent
, int width
) {
893 while (indent
--) rdaddc(text
, ' ');
894 while (width
--) rdaddc(text
, '-');
899 static void info_para(rdstringc
*text
, word
*prefix
, char *prefixextra
,
900 word
*input
, keywordlist
*keywords
,
901 int indent
, int extraindent
, int width
) {
902 wrappedline
*wrapping
, *p
;
904 rdstringc pfx
= { 0, 0, NULL
};
907 int firstlinewidth
= width
;
909 words
= info_transform_wordlist(input
, keywords
);
912 info_rdaddwc(&pfx
, prefix
, NULL
, FALSE
);
914 rdaddsc(&pfx
, prefixextra
);
915 for (i
= 0; i
< indent
; i
++)
917 rdaddsc(text
, pfx
.text
);
918 /* If the prefix is too long, shorten the first line to fit. */
919 e
= extraindent
- strlen(pfx
.text
);
921 firstlinewidth
+= e
; /* this decreases it, since e < 0 */
922 if (firstlinewidth
< 0) {
923 e
= indent
+ extraindent
;
924 firstlinewidth
= width
;
931 e
= indent
+ extraindent
;
933 wrapping
= wrap_para(words
, firstlinewidth
, width
, info_width_xrefs
);
934 for (p
= wrapping
; p
; p
= p
->next
) {
935 for (i
= 0; i
< e
; i
++)
937 info_rdaddwc(text
, p
->begin
, p
->end
, TRUE
);
939 e
= indent
+ extraindent
;
944 free_word_list(words
);
947 static void info_codepara(rdstringc
*text
, word
*words
,
948 int indent
, int width
) {
951 for (; words
; words
= words
->next
) if (words
->type
== word_WeakCode
) {
953 info_convert(words
->text
, &c
);
954 if (strlen(c
) > (size_t)width
) {
957 for (i
= 0; i
< indent
; i
++)
967 static void info_versionid(rdstringc
*text
, word
*words
) {
968 rdaddc(text
, '['); /* FIXME: configurability */
969 info_rdaddwc(text
, words
, NULL
, FALSE
);
970 rdaddsc(text
, "]\n");
973 static node
*info_node_new(char *name
)
979 n
->text
.pos
= n
->text
.size
= 0;
980 n
->up
= n
->next
= n
->prev
= n
->lastchild
= n
->listnext
= NULL
;
981 n
->name
= dupstr(name
);
982 n
->started_menu
= FALSE
;
987 static char *info_node_name(paragraph
*par
)
989 rdstringc rsc
= { 0, 0, NULL
};
991 info_rdaddwc(&rsc
, par
->kwtext ? par
->kwtext
: par
->words
, NULL
, FALSE
);
994 * We cannot have commas or colons in a node name. Remove any
995 * that we find, with a warning.
999 if (*p
== ':' || *p
== ',') {
1000 error(err_infonodechar
, &par
->fpos
, *p
);
1011 static void info_menu_item(rdstringc
*text
, node
*n
, paragraph
*p
)
1014 * FIXME: Depending on how we're doing node names in this info
1015 * file, we might want to do
1017 * * Node name:: Chapter title
1021 * * Chapter number: Node name.
1025 rdaddsc(text
, "* ");
1026 rdaddsc(text
, n
->name
);
1027 rdaddsc(text
, "::");
1030 info_rdaddwc(text
, p
->words
, NULL
, FALSE
);