e5519812c643fbc60dbb243dc8259d7b39cd3cb7
[oweals/cde.git] / cde / programs / dthelp / parser / canon1 / helptag / help.if
1 /*   Copyright (c) 1986, 1987, 1988, 1989, 1990 Hewlett-Packard Co. */
2 /* Interface definition for HP Tag/TeX translator */
3
4 /* Things to watch out for:
5
6    1.  Index processing.  Notice for a number of tags (<BOOK> for example),
7        there is specific code when the tag is in <IDX>:
8          <START-CODE * IDX>, etc.
9        Many tags don't have empty <* IDX> string-code processing, to save
10        on executable size.  Therefore, when you add string-code processing
11        to a tag, make sure you add empty string-code for <* IDX>.
12    2.  Index processing for <COMPUTER>, <CURSOR>, <USER>.  They all have
13        hardcoded default values for their parameters to save on program
14        size (otherwise we have to uncomment parameter code).  This is not
15        a problem since parameters is unimplemented.  Need to watch out for
16        this when we do implement.
17 */
18
19 <!ENTITY USER-DEFINED-ENTITIES SYSTEM "helptag.ent">
20
21 <!ENTITY MINUS SDATA "-">
22 <!ENTITY PM SDATA '[plusmn]'>               /* ISOnum  */
23 <!ENTITY DIV SDATA '[divide]'>              /* ISOnum  */
24 <!ENTITY TIMES SDATA '[times ]'>            /* ISOnum  */
25 <!ENTITY LEQ SDATA '[le    ]'>              /* ISOtech */
26 <!ENTITY GEQ SDATA '[ge    ]'>              /* ISOtech */
27 <!ENTITY NEQ SDATA '[ne    ]'>              /* ISOtech */
28 <!ENTITY COPY SDATA '[copy  ]'>             /* ISOnum  */
29 <!ENTITY REG SDATA '[reg   ]'>              /* ISOnum  */
30 <!ENTITY TM SDATA '[trade ]'>               /* ISOnum  */
31 <!ENTITY ELLIPSIS SDATA '[hellip]'>         /* ISOpub  */
32 <!ENTITY VELLIPSIS SDATA '[vellip]'>        /* ISOpub  */
33 <!ENTITY PELLIPSIS SDATA "....">  /* ellipsis followed by a period? */
34 <!ENTITY A.M. SDATA "a.m.">
35 <!ENTITY P.M. SDATA "p.m.">
36 <!ENTITY MINUTES SDATA '[prime ]'>          /* ISOtech */
37 <!ENTITY SECONDS SDATA '[Prime ]'>          /* ISOtech */
38 <!ENTITY DEG SDATA '[deg   ]'>              /* ISOnum  */
39 <!ENTITY SQUOTE SDATA "`">
40 <!ENTITY DQUOTE SDATA '"'>
41 <!ENTITY ENDASH SDATA "-">
42 <!ENTITY EMDASH SDATA '[mdash ]'>           /* ISOpub  */
43 <!ENTITY VBLANK SDATA "_">
44 <!ENTITY CENTS SDATA '[cent  ]'>            /* ISOnum  */
45 <!ENTITY STERLING SDATA '[pound ]'>         /* ISOnum  */
46 <!ENTITY M-D- PI "">
47 <!ENTITY SPACE SDATA " ">
48 <!ENTITY SIGSPACE SDATA "& ">
49 <!ENTITY SIGDASH SDATA "&-">
50 <!ENTITY MICRO SDATA '[micro ]'>            /* ISOnum  */
51 <!ENTITY OHM SDATA '[ohm   ]'>              /* ISOnum  */
52 <!ENTITY UP SDATA '[uarr  ]'>               /* ISOnum  */
53 <!ENTITY DOWN SDATA '[darr  ]'>             /* ISOnum  */
54 <!ENTITY LEFT SDATA '[larr  ]'>             /* ISOnum  */
55 <!ENTITY RIGHT SDATA '[rarr  ]'>            /* ISOnum  */
56 <!ENTITY HOME SDATA "home key">
57 <!ENTITY BACK SDATA "\<--">
58 <!ENTITY DATE SDATA CODE>
59      time_t nseconds;
60      struct tm *timefoo;
61      int maxsize = 20;
62      char s[20];
63
64      nseconds = time(NULL);
65      timefoo = localtime(&nseconds);
66      strftime(s, maxsize, "%x", timefoo);
67      fprintf(outfile, "%s\n", s);
68 </CODE>
69 <!ENTITY TIME SDATA CODE>
70      time_t nseconds;
71      struct tm *timefoo;
72      int maxsize = 20;
73      char s[20];
74
75      nseconds = time(NULL);
76      timefoo = localtime(&nseconds);
77      strftime(s, maxsize, "%X", timefoo);
78      fprintf(outfile, "%s\n", s);
79 </CODE>
80 <!ENTITY HALFSPACE SDATA " ">
81 <!ENTITY M-SPECCHAR SDATA "Special characters">
82
83 /* Code entities for toggling debugging traces */
84 <!ENTITY m-aopt PI CODE>
85   m_malftrace = (LOGICAL) ! m_malftrace ;
86   </CODE>
87
88 <!ENTITY m-copt PI CODE>
89   m_chtrace = (LOGICAL) ! m_chtrace ;
90   </CODE>
91
92 <!ENTITY m-dopt PI CODE>
93   m_cdtrace = (LOGICAL) ! m_cdtrace ;
94   </CODE>
95
96 <!ENTITY m-hopt PI CODE>
97   m_heapchk = (LOGICAL) ! m_heapchk ;
98   </CODE>
99
100 <!ENTITY m-oopt PI CODE>
101   tracetostd = (LOGICAL) ! tracetostd ;
102   </CODE>
103
104 /* This option pertains to automatic index processing only (called by the
105    scripts only), so we don't need it in pi's.
106
107 <!ENTITY m-popt PI CODE>
108   parentsrch = (LOGICAL) ! parentsrch ;
109   </CODE>
110
111 */
112
113 <!ENTITY m-sopt PI CODE>
114   m_scantrace = (LOGICAL) ! m_scantrace ;
115   </CODE>
116
117 <!ENTITY m-topt PI CODE>
118   m_tagtrace = (LOGICAL) ! m_tagtrace ;
119   </CODE>
120
121 /* Code entities for MARKUP and HP Tag versions */
122 <!ENTITY m-markup-ver SDATA CODE>
123   {
124   M_WCHAR *wc_1, *wc_2;
125
126   wc_1 = MakeWideCharString(M_VERSION);
127   wc_2 = MakeWideCharString("m-markup-ver");
128   m_piaction(wc_1, wc_2, M_SDATA) ;
129   m_free(wc_1,"wide character string");
130   m_free(wc_2,"wide character string");
131   }
132   </CODE>
133
134 <!ENTITY m-tagver SDATA CODE>
135   {
136   M_WCHAR *wc_1, *wc_2;
137
138   wc_1 = MakeWideCharString(version);
139   wc_2 = MakeWideCharString("m-tagver");
140   m_piaction(wc_1, wc_2, M_SDATA) ;
141   m_free(wc_1,"wide character string");
142   m_free(wc_2,"wide character string");
143   }
144   </CODE>
145
146 <!ENTITY m-machine SDATA CODE>
147 #if defined(MSDOS)
148   m_piaction("VECTRA", "m-machine", M_SDATA) ;
149 #else
150 #if defined(hpux)
151   {
152   M_WCHAR *wc_1, *wc_2;
153
154   wc_1 = MakeWideCharString("HPUX");
155   wc_2 = MakeWideCharString("m-machine");
156   m_piaction(wc_1, wc_2, M_SDATA) ;
157   m_free(wc_1,"wide character string");
158   m_free(wc_2,"wide character string");
159   }
160 #else
161 #if defined(_AIX)
162   {
163   M_WCHAR *wc_1, *wc_2;
164
165   wc_1 = MakeWideCharString("AIX");
166   wc_2 = MakeWideCharString("m-machine");
167   m_piaction(wc_1, wc_2, M_SDATA) ;
168   m_free(wc_1,"wide character string");
169   m_free(wc_2,"wide character string");
170   }
171 #else
172 #if defined(sun)
173   {
174   M_WCHAR *wc_1, *wc_2;
175
176   wc_1 = MakeWideCharString("SUN");
177   wc_2 = MakeWideCharString("m-machine");
178   m_piaction(wc_1, wc_2, M_SDATA) ;
179   m_free(wc_1,"wide character string");
180   m_free(wc_2,"wide character string");
181   }
182 #else
183 #if defined(USL)
184   {
185   M_WCHAR *wc_1, *wc_2;
186
187   wc_1 = MakeWideCharString("USL");
188   wc_2 = MakeWideCharString("m-machine");
189   m_piaction(wc_1, wc_2, M_SDATA) ;
190   m_free(wc_1,"wide character string");
191   m_free(wc_2,"wide character string");
192   }
193 #else
194 #if defined(__uxp__)
195   {
196   M_WCHAR *wc_1, *wc_2;
197
198   wc_1 = MakeWideCharString("UXP");
199   wc_2 = MakeWideCharString("m-machine");
200   m_piaction(wc_1, wc_2, M_SDATA) ;
201   m_free(wc_1,"wide character string");
202   m_free(wc_2,"wide character string");
203   }
204 #else
205 #if defined(__osf__)
206   {
207   M_WCHAR *wc_1, *wc_2;
208
209   wc_1 = MakeWideCharString("OSF1");
210   wc_2 = MakeWideCharString("m-machine");
211   m_piaction(wc_1, wc_2, M_SDATA) ;
212   m_free(wc_1,"wide character string");
213   m_free(wc_2,"wide character string");
214   }
215 #else
216   m_piaction("UNDEFINED MACHINE",
217              "m-machine",
218              M_SDATA) ;
219 #endif
220 #endif
221 #endif
222 #endif
223 #endif
224 #endif
225 #endif
226   </CODE>
227
228 <SIGN-ON>CDE HelpTag Formatting System. - Version C.00.00  (DTD Version A.01.3)
229 <GLOBAL-DEFINE>
230 #define DEFINE
231 #include "global.h"
232 #include "htag.tss"
233 static char ident1[]="@(#)CDE Help Tag Parser";
234 static char ident2[]="@(#)Version Number: C.00.00";
235 static char ident3[]="@(#) (c) Copyright 1993, 1994 Hewlett-Packard Company";
236 static char ident4[]="@(#) (c) Copyright 1993, 1994 International Business Machines Corp.";
237 static char ident5[]="@(#) (c) Copyright 1993, 1994 Sun Microsystems, Inc.";
238 static char ident6[]="@(#) (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.";
239
240 <GLOBAL-DECLARE>
241 #include "global.h"
242 #include "htag.tss"
243
244 <START-CODE>
245   SEARCH *new ;
246   char *p ;
247   char *q ;
248
249   /* Pick version number out of sign-on message */
250   if (p = strstr(m_signon, VERSION)) {
251     p += strlen(VERSION) + 1 ;
252     for (q = p ; *q && *q != '\n'; q++) ;
253     if (*q == '\n') {
254       version = (char *) m_malloc(q - p + 1, "version") ;
255       *q = M_EOS ;
256       strcpy(version, p) ;
257       *q = '\n' ;
258       }
259     }
260
261   /* Following: please refer to comments in custom.c, m_setoptions() */
262   if (m_argc > 2) {
263     if ((strchr(m_argv[2], 'p')) || (strchr(m_argv[2], 'P')))
264       parentsrch = TRUE ;  /* Implies we are processing indexes */
265     }
266
267   fbasename();
268
269   options(FALSE) ;
270   if (m_errexit && stoponerror) m_exit(m_errexit) ;
271
272   if (indir) {
273     new = (SEARCH *) m_malloc(sizeof(SEARCH), "search path") ;
274     new->directory = indir ;
275     new->next = path ;
276     path = new ;
277     }
278
279 <END-CODE>
280   int i;
281   if (outfile)
282     {
283     prebye = ftell(outfile) ;
284     fseek(outfile, texcomplete, SEEK_SET) ;
285     fseek(outfile, 0L, SEEK_END) ;
286     dumpxref() ;
287     if (glossary) checkgloss() ;
288
289     /* warn if we have forward xrefs */
290     if (have_forward_xrefs)
291         {
292         m_exit(77);
293         }
294     }
295
296 <TEXT-CODE>
297     outchar(m_textchar, outfile) ;
298
299 <PI-CODE>
300    outpi(m_enttype, m_pi, m_entname) ;
301
302
303 <ELEMENT ABBREV>
304   <START-CODE CAPTION>
305     savhd = FALSE;
306     tooutput = TRUE;
307     fputs(" ABBREV=\"", outfile);
308   <START-CODE CHAPHEAD S1,        CHAPHEAD S2,      CHAPHEAD S3,
309               CHAPHEAD S4,        CHAPHEAD S5,      CHAPHEAD S6,
310               CHAPHEAD S7,        CHAPHEAD S8,      CHAPHEAD S9,
311               CHAPHEAD HOMETOPIC, CHAPHEAD CHAPTER,
312               CHAPHEAD MESSAGE,   CHAPHEAD MSGSUB,
313               CHAPHEAD RSECT,     CHAPHEAD RSUB,
314               CHAPHEAD PROCEDURE >
315     fputs(" ABBREV=\"", outfile);
316   <START-CODE>
317     M_WCHAR *wc_stago, *wc_tagc;
318
319     wc_stago = MakeWideCharString(m_stago);
320     wc_tagc  = MakeWideCharString(m_tagc);
321     
322     m_err2("Unimplemented %sABBREV%s reached", wc_stago, wc_tagc);
323     m_free(wc_stago,"wide character string");
324     m_free(wc_tagc,"wide character string");
325   <END-CODE>
326     fputs("\"", outfile);
327
328 <ELEMENT ABSTRACT>
329   <START-CODE>
330     static char abstract[] = "-ABSTRACT";
331     char id[SDLNAMESIZ+sizeof(abstract)];
332
333     hadabstract = TRUE;
334     needabstracthead = TRUE;
335     sprintf(id, "%s%s", sdlReservedName, abstract);
336     mb_starthelpnode("_ABSTRACT", id, 0);
337   <END-CODE>
338     CloseVirpage();
339   <TEXT-CODE>
340      outchar(m_textchar, outfile);
341
342 <ELEMENT ACRO>
343   <START-CODE * IDX, * EXAMPLESEG, * IMAGE>
344   <START-CODE>
345     mb_strcode("<KEY CLASS=\"ACRO\">", outfile) ;
346     if (echo) {
347       mb_echohead(m_stago);
348       echohead(m_parent(0)) ;
349       mb_echohead(m_net);
350       }
351   <END-CODE * IDX, * EXAMPLESEG, * IMAGE>
352   <END-CODE>
353     mb_strcode("</KEY>", outfile) ;
354     if (echo) mb_echohead(m_net) ;
355   <TEXT-CODE * IDX>
356     indexchar(m_textchar) ;
357   <TEXT-CODE>
358     outchar(wc_toupper(m_textchar), outfile) ;
359
360 <ELEMENT ANNOTATION>
361   <START-CODE>
362     if (!firstAnnot)
363         {
364         exLineNum++;
365         }
366     firstAnnot = FALSE;
367
368     savhd    = TRUE;
369     hderr    = FALSE;
370     tooutput = FALSE;
371     mb_strcode("<HEAD CLASS=\"ANNOTATION\" TYPE=\"DYNAMIC\" SSI=\"ANNOT-",
372                outfile);
373     mb_strcode(stackex ? "STACK\">" : "SIDE\">", outfile);
374   <END-CODE>
375     mb_strcode("</HEAD>", outfile);
376     savehead[svheadlen] = '\0';
377     savhd    = FALSE;
378     tooutput = TRUE;
379
380 <ELEMENT BOOK>
381   <START-CODE * IDX>
382   <START-CODE>
383     mb_strcode("<KEY CLASS=\"BOOK\">", outfile) ;
384     if (echo) {
385       mb_echohead(m_stago) ;
386       echohead(m_parent(0)) ;
387       mb_echohead(m_net) ;
388       }
389   <END-CODE * IDX>
390   <END-CODE>
391     mb_strcode("</KEY>", outfile) ;
392     if (echo) mb_echohead(m_net) ;
393   <TEXT-CODE * IDX>
394     indexchar(m_textchar) ;
395
396 <ELEMENT CAPTION>
397   <START-CODE FIGURE>
398     figcaption = TRUE ;
399     newhline = 0 ;
400     savhd = TRUE ;
401     hderr = FALSE ;
402     svheadlen = 0 ;
403     tooutput = FALSE;
404     if (ftonumber)
405         fputs("<SUBHEAD TYPE=\"LINED\" SSI=\"CAPTION-NUMBERED\"", outfile);
406     else
407         fprintf(outfile,
408                 "<HEAD TYPE=\"LINED\" CLASS=\"CAPTION\" SSI=\"CAPTION%s\"",
409                 capposition);
410   <END-CODE FIGURE>
411     savehead[svheadlen] = M_EOS ;
412     savhd = FALSE ;
413     tooutput = TRUE;
414     mb_strcode(">", outfile);
415     strcode(savehead, outfile);
416     if (ftonumber)
417         fputs("</SUBHEAD>", outfile);
418     ftonumber = 0;
419
420 <ELEMENT CAUTION>
421   <START-CODE>
422     StartNCW("CAUTION");
423
424 <ELEMENT CHAPHEAD>
425   <START-CODE MESSAGE>
426     emsghead = USERHEAD ;
427 /* Node headings */
428   <END-CODE CHAPTER, RSECT,  S1, S2, S3, S4, S5, S6, S7,
429             S8, S9, HOMETOPIC, MESSAGE>
430     endhead() ;
431     mb_strcode(">", outfile);
432     strcode(savehead, outfile);
433     chksnb();
434 /* Non node headings */
435   <END-CODE RSUB, MSGSUB, PROCEDURE>
436     endhead() ;
437     mb_strcode(">", outfile);
438     strcode(savehead, outfile);
439     fputs("</HEAD>\n", outfile);
440 /* Non node headings */
441   <END-CODE OTHERHEAD>
442     endhead() ;
443     fputs("</HEAD>\n", outfile);
444
445 <ELEMENT CHAPTER>
446   <PARAM>
447     id = ID ;
448   <START-CODE>
449     M_WCHAR *wc_chapter;
450
451     wc_chapter = MakeWideCharString("CHAPTER");
452
453     assert_hometopic_exists();
454     chapstart(id);
455     thisnodelevel = 2;
456     starthelpnode(wc_chapter, id, thisnodelevel);
457     m_free(wc_chapter, "wide character string");
458   <END-CODE>
459     CloseVirpage();
460     rseqend() ;
461     thisnodelevel = 0;
462
463 <ELEMENT CIRCLE>
464   <START-CODE * IDX>
465   <END-CODE   * IDX>
466   <TEXT-CODE  * IDX>
467     indexchar('(');
468     indexchar(m_textchar) ;
469     indexchar(')');
470   <TEXT-CODE>
471     if (echo) mb_echohead("((") ;
472     mb_strcode("(", outfile) ;
473     outchar (m_textchar, outfile) ;
474     mb_strcode(")", outfile) ;
475     if (echo) mb_echohead("))") ;
476
477 <ELEMENT COMPUTER>
478   <START-CODE * IDX>
479   <START-CODE>
480     mb_strcode("<KEY CLASS=\"MACH-OUT\">", outfile) ;
481     if (echo) mb_echohead("``") ;
482   <END-CODE * IDX>
483   <END-CODE>
484     mb_strcode("</KEY>", outfile) ;
485     if (echo) mb_echohead("''") ;
486   <TEXT-CODE * IDX>
487     indexchar(m_textchar) ;
488   <TEXT-CODE * IMAGE, * EXAMPLESEG>
489      exoutchar(m_textchar) ;
490   <TEXT-CODE>
491      esoutchar(m_textchar) ;
492
493 <ELEMENT COPYRIGHT>
494   <START-CODE>
495     static char copyright[] = "-COPYRIGHT";
496     char id[SDLNAMESIZ+sizeof(copyright)];
497
498     sprintf(id, "%s%s", sdlReservedName, copyright);
499     mb_starthelpnode("_COPYRIGHT", id, 0);
500     /* No Head.  Let author have a clean slate. */
501   <END-CODE>
502     CloseVirpage();
503
504 <ELEMENT DEFINITION>
505
506 <ELEMENT DTERM>
507   <START-CODE>
508     termp = term;
509     tooutput = FALSE;
510   <END-CODE>
511     char *mb_nodeid;
512
513     tooutput = TRUE;
514     *termp = M_EOS ;
515     /* trim possible (perhaps) last space */
516     if (termp - term > 1 && *(termp-1) == ' ') {
517          *(termp-1) = M_EOS;
518     }
519     if (!(lastTermId = (int)(intptr_t) m_lookfortrie(term, &gtree)))
520         {
521         lastTermId = NextId();
522         m_ntrtrie(term, &gtree, (void *)(intptr_t) -lastTermId);
523         }
524     else
525       if (lastTermId > 0)
526           {
527           if (!m_resettrie(&gtree, term, (void *)(intptr_t) -lastTermId))
528               {
529               m_error("Internal error. Can't reset glossary trie") ;
530               m_exit(TRUE) ;
531               }
532           }
533       else
534           lastTermId = -lastTermId;
535   <TEXT-CODE>
536     termchar(m_textchar) ;
537   <PI-CODE>
538     termpi(m_enttype, m_pi, m_entname) ;
539
540 <ELEMENT EMPH>
541   <START-CODE * IDX>
542   <START-CODE>
543     mb_strcode("<KEY CLASS=\"EMPH\">", outfile) ;
544     if (echo) mb_echohead("!!") ;
545   <END-CODE * IDX>
546   <END-CODE>
547     mb_strcode("</KEY>", outfile) ;
548     if (echo) mb_echohead("!!") ;
549   <TEXT-CODE * IDX>
550     indexchar(m_textchar) ;
551
552 <ELEMENT ESC>
553   <START-CODE * IDX>
554   <START-CODE>
555     if (echo) {
556       mb_echohead(m_stago) ;
557       echohead(m_parent(0)) ;
558       mb_echohead(m_net) ;
559       }
560   <END-CODE * IDX>
561   <END-CODE>
562     if (echo) mb_echohead(m_net) ;
563   <TEXT-CODE * IDX>
564     indexchar(m_textchar) ;
565   <TEXT-CODE>
566     static M_WCHAR ch[2];
567
568     ch[0] = m_textchar;
569     strcode(ch, outfile);
570
571 <ELEMENT EX>
572   <PARAM>
573     notes = NOTES (QSIDE = SIDE,
574                    QSTACK = STACK) ;
575     lines = LINES (QNUMBER = NUMBER,
576                    QNONUMBER = NONUMBER) ;
577     textsize = TEXTSIZE (QNORMAL = NORMAL,
578                          QSMALLER = SMALLER,
579                          QSMALLEST = SMALLEST) ;
580   <START-CODE>
581     StartEx(notes, lines, textsize);
582   <END-CODE>
583     EndEx();
584     tonumexlines = FALSE;
585     fputs(saveex, outfile);
586     fputs("</BLOCK>\n", outfile);
587     inBlock = FALSE;
588   <TEXT-CODE>
589     outchar(m_textchar, outfile) ;
590
591 <ELEMENT EXAMPLESEG>
592   <START-CODE>
593     if (exLineNum > 1)
594         EndEx();
595     inSdlP     = TRUE;
596     savex      = TRUE;
597     tooutput   = FALSE;
598     saveexseg  = mb_malloc(1);
599     svexseglen = 1;
600     svheadlen  = 0; /* we save any <annotation> text in "savehead" */
601   <END-CODE>
602     savex = FALSE;
603     tooutput = TRUE;
604   <TEXT-CODE>
605     exoutchar(m_textchar);
606
607 <ELEMENT EXPLAIN>
608   <START-CODE>
609     PushForm(NULL, "EXPLAIN", NULL);
610
611 <ELEMENT FIGURE>
612   <PARAM>
613     number = NUMBER ;
614     tonumber = TONUMBER (QNUMBER = NUMBER,
615                          QNONUMBER = NONUMBER) ;
616     file = ENTITY ;
617     id = ID ;
618     figpos = FIGPOS (QLEFT = LEFT,
619                      QCENTER = CENTER,
620                      QRIGHT = RIGHT) ;
621     cappos = CAPPOS ;
622     ghyperlink = GHYPERLINK  ;
623     glinktype = GLINKTYPE (QJUMP = JUMP,
624                            QJUMPNEWVIEW = JUMPNEWVIEW,
625                            QDEFINITION = DEFINITION,
626                            QEXECUTE = EXECUTE,
627                            QAPPDEFINED = APPDEFINED,
628                            QMAN = MAN) ;
629     gdescription = GDESCRIPTION  ;
630   <START-CODE>
631      if (cappos)
632          cappos += 3; /* bump over the "CAP" */
633      figure(number,
634             tonumber,
635             id,
636             file,
637             figpos,
638             cappos,
639             ghyperlink,
640             glinktype,
641             gdescription);
642   <END-CODE>
643     if (ftonumber | (svheadlen != 0))
644         {
645         fputs("</HEAD>", outfile);
646         ftonumber = 0;
647         }
648     fputs("\n</REFITEM>\n</SNREF>", outfile);
649     if (ghyperlink)
650         {
651         fputs("</LINK>\n", outfile);
652         }
653     inSdlP = FALSE;
654     fputs("</P>\n", outfile);
655
656 <ELEMENT FOOTNOTE>
657   /* When implementing, check conditionals of <FOOTNOTE> in <P>    */
658   <TEXT-CODE * EXAMPLESEG, * IMAGE>
659     outchar(m_textchar, outfile) ;
660   <END-CODE>
661     footnoteno++;
662
663 <ELEMENT FRONTSUB>
664 <START-CODE OTHERFRONT>
665    if (!had_an_otherfront_head) {
666         endhead();
667    }
668    PushForm(NULL, NULL, NULL);
669 <START-CODE>
670    PushForm(NULL, NULL, NULL);
671
672 <ELEMENT GLOSSARY>
673   <START-CODE>
674     char *string = 
675       GetDefaultHeaderString("GlossaryElementDefaultHeadingString",
676                              M_SDATA,
677                              "Glossary");
678     static char glossary_string[] = "-GLOSSARY";
679     char id[SDLNAMESIZ+sizeof(glossary_string)];
680
681     thisnodelevel = 2;
682     sprintf(id, "%s%s", sdlReservedName, glossary_string);
683     mb_starthelpnode("_GLOSSARY", id, thisnodelevel);
684     if (strlen(string) + 1 > sizeof(chapstring)) {
685       m_error("Program error: exceeded chapstring") ;
686       m_exit(TRUE) ;
687       }
688     snprintf(chapstring, sizeof(chapstring), "%s", string) ;
689     fputs("\nGlossary\n", stderr) ;
690     glossary = TRUE ;
691     fprintf(outfile, "<HEAD SSI=\"CHAPHEAD\">%s</HEAD>\n", string);
692     m_free(string, "default header string return");
693   <END-CODE>
694     CloseVirpage();
695     thisnodelevel = 0;
696
697 <ELEMENT GLOSSENT>
698
699 <ELEMENT GRAPHIC>
700   <PARAM>
701     id = ID ;
702     file = ENTITY ;
703 <START-CODE>
704     unsigned char etype, wheredef ;
705      /* Code from figstart */
706   if (id) {
707     mbstowcs(xrefstring, "\\<xref graphic>", 400);
708     xstrlen = w_strlen(xrefstring) ;
709     m_getline(&xrffile, &xrfline) ;
710     if (xrffile == NULL) {
711          /* set to primary input source */
712          xrffile = inputname;
713     }
714     setid(id,
715           TRUE,
716           FALSE,
717           inchapter,
718           chapstring,
719           xrffile,
720           xrfline,
721           FALSE) ;
722
723     }
724   /* initialize some stuff first:
725      - file is the entity name,
726      - f_file is the content of the entity,
727        used only if f_content nonNULL
728      - f_content is f_file with the relative pathname, initialized to NULL,
729      - f_contqual is fully qualified f_file, assigned ONLY IF
730        f_content nonNULL
731   */
732   file_ent = FALSE ;
733   f_content = NULL ;
734   f_contqual[0] = M_EOS ;
735
736   /* check ENTITY and determine the figure type  */
737   if (file) {
738     m_lookent(file, &etype, &f_file, &wheredef) ;
739     if (etype != M_SYSTEM) {
740       M_WCHAR *wc_stago, *wc_tagc, *wc_entsystem, *wc_entkw;
741
742       wc_stago     = MakeWideCharString(m_stago);
743       wc_tagc      = MakeWideCharString(m_tagc);
744       wc_entsystem = MakeWideCharString(m_entsystem);
745       wc_entkw     = MakeWideCharString(m_entkw);
746       m_err6("%s not a %s %s, as required for the ENTITY parameter of %s%s%s",
747              file,
748              wc_entsystem,
749              wc_entkw,
750              wc_stago,
751              m_parent(0),
752              wc_tagc) ;
753       m_free(wc_stago,"wide character string");
754       m_free(wc_tagc,"wide character string");
755       m_free(wc_entsystem,"wide character string");
756       m_free(wc_entkw,"wide character string");
757       }
758     else {
759       file_ent = TRUE ;
760       f_content = searchforfile(f_file) ;
761       if (f_content) {
762         if (getqualified(f_contqual, f_content)) {
763           /* unsuccessful qual */
764           if (w_strlen(f_content) < FNAMELEN)
765             w_strcpy(f_contqual, f_content) ;
766           else {
767             m_err1("Internal error. File name too long: %s", f_content) ;
768             m_exit(m_errexit) ;
769             }
770           }
771         }
772       else {
773         m_err2("Can't find file %s (declared in entity %s)", f_file, file) ;
774         }
775       }
776     }
777
778     {
779     char *mb_content, snb_id[32];
780     char buffer[BIGBUF];
781     static M_WCHAR empty[1];
782     empty[0] = M_EOS;
783
784     if (!f_content) f_content = empty;
785
786     mb_content = MakeMByteString(f_content);
787     sprintf(snb_id, "%s%d", sdlReservedName, NextId());
788     mb_strcode("<SNREF", outfile);
789     if (id)
790         {
791         char *mb_id;
792
793         mb_id = MakeMByteString(id);
794         sprintf(buffer, " ID=\"%s\"", mb_id);
795         mb_strcode(buffer, outfile);
796         m_free(mb_id,"multi-byte string");
797         }
798     sprintf(buffer,
799             ">\n<REFITEM RID=\"%s\" CLASS=\"IN-LINE\"></REFITEM>\n</SNREF>",
800             snb_id);
801     mb_strcode(buffer, outfile);
802     AddToSNB(snb_id, mb_content);
803     m_free(mb_content,"multi-byte string");
804     }
805
806 <ELEMENT HEAD>
807 /* Accent headings */
808   <START-CODE NOTE, CAUTION, WARNING>
809     notehead = TRUE ;
810     newhline = 0 ;
811     fputs("<HEAD TYPE=\"LINED\" SSI=\"NCW\">", outfile);
812 /* Other headings */
813   <START-CODE LABLIST, IMAGE, LIST, EX, P>
814     char *ssi;
815
816     ssi = MakeMByteString(m_parent(1));
817     newhline = 0 ;
818     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\">", ssi);
819     m_free(ssi, "multi-byte string");
820 /* Node headings */
821   <START-CODE CHAPHEAD CHAPTER,   CHAPHEAD RSECT,
822               CHAPHEAD HOMETOPIC, CHAPHEAD MESSAGE,
823               CHAPHEAD S1,        CHAPHEAD S2,      CHAPHEAD S3,
824               CHAPHEAD S4,        CHAPHEAD S5,      CHAPHEAD S6,
825               CHAPHEAD S7,        CHAPHEAD S8,      CHAPHEAD S9
826               >
827     char *ssi;
828
829     ssi = MakeMByteString(m_parent(1));
830     newhline = 0 ;
831     echo = TRUE ;
832     savhd = TRUE ;
833     hderr = FALSE ;
834     svheadlen = 0 ;
835     savesnb = mb_malloc(1);
836     *savesnb = '\0';
837     tooutput = FALSE;
838     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\"", ssi);
839     m_free(ssi, "multi-byte string");
840 /* Non node headings */
841   <START-CODE CHAPHEAD RSUB, CHAPHEAD MSGSUB>
842     char *ssi;
843
844     ssi = MakeMByteString(m_parent(1));
845     newhline = 0 ;
846     echo = TRUE ;
847     savhd = TRUE ;
848     hderr = FALSE ;
849     svheadlen = 0 ;
850     tooutput = FALSE;
851     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\"", ssi);
852     m_free(ssi, "multi-byte string");
853 /* Non node headings */
854   <START-CODE CHAPHEAD PROCEDURE>
855     newhline = 0 ;
856     echo = TRUE ;
857     savhd = TRUE ;
858     hderr = FALSE ;
859     svheadlen = 0 ;
860     tooutput = FALSE;
861     fputs("<HEAD TYPE=\"LINED\" SSI=\"PROCEDURE\"", outfile);
862 /* Non node headings */
863   <START-CODE OTHERHEAD>
864     char *ssi;
865
866     ssi = MakeMByteString(m_parent(1));
867     newhline = 0 ;
868     echo = TRUE ;
869     savhd = TRUE ;
870     hderr = FALSE ;
871     svheadlen = 0 ;
872     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\">", ssi);
873     m_free(ssi, "multi-byte string");
874 /* Other headings */ 
875   <START-CODE CHAPHEAD>
876      M_WCHAR *wc_stago, *wc_tagc;
877
878      wc_stago = MakeWideCharString(m_stago);
879      wc_tagc  = MakeWideCharString(m_tagc);
880      m_err2("Unimplemented %sCHAPHEAD%s reached", wc_stago, wc_tagc);
881      m_free(wc_stago,"wide character string");
882      m_free(wc_tagc,"wide character string");
883 /* Non-node headings */
884   <START-CODE FRONTSUB, SYNTAX>
885     char *ssi;
886
887     ssi = MakeMByteString(m_parent(1));
888     echo = TRUE ;
889     newhline = 0 ;
890     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\">", ssi);
891     m_free(ssi, "multi-byte string");
892 /* Non-node headings */
893   <START-CODE ABSTRACT>
894     echo = TRUE ;
895     newhline = 0 ;
896     needabstracthead = FALSE;
897     fputs("<HEAD TYPE=\"LINED\" SSI=\"ABSTRACT\">", outfile);
898 /* Node headings */
899   <START-CODE OTHERFRONT>
900     had_an_otherfront_head = TRUE;
901     newhline = 0 ;
902     echo = TRUE ;
903     savhd = TRUE ;
904     hderr = FALSE ;
905     svheadlen = 0 ;
906     fputs("<HEAD TYPE=\"LINED\" SSI=\"METAINFO\">", outfile);
907 /* Other headings (mixed content) */
908   <END-CODE  P, IMAGE>
909     endhead();
910     fputs("</HEAD>", outfile);
911 /* Accent and Other headings (no mixed content) */
912   <END-CODE LABLIST, LIST, EX, NOTE, CAUTION, WARNING>
913     fputs("</HEAD>\n", outfile);
914 /* Non node headings */
915   <END-CODE ABSTRACT, FRONTSUB, MESSAGE, SYNTAX>
916     echo = FALSE ;
917     chksnb();
918 /* Node headings */
919   <END-CODE CHAPHEAD CHAPTER,   CHAPHEAD RSECT,
920             CHAPHEAD HOMETOPIC, CHAPHEAD MESSAGE,
921             CHAPHEAD S1,        CHAPHEAD S2,      CHAPHEAD S3,
922             CHAPHEAD S4,        CHAPHEAD S5,      CHAPHEAD S6,
923             CHAPHEAD S7,        CHAPHEAD S8,      CHAPHEAD S9>
924     echo = FALSE;
925     savhd = FALSE;
926     savehead[svheadlen] = '\0';
927     tooutput = TRUE;
928 /* Non node headings */
929   <END-CODE CHAPHEAD RSUB, CHAPHEAD MSGSUB, CHAPHEAD PROCEDURE>
930     echo = FALSE;
931     savhd = FALSE;
932     savehead[svheadlen] = '\0';
933     tooutput = TRUE;
934 /* Non node headings */
935   <END-CODE OTHERHEAD>
936     endhead() ;
937     fputs("</HEAD>\n", outfile);
938 /* Node headings. */
939   <END-CODE OTHERFRONT>
940     endhead() ;
941     chksnb();
942 /* Other headings. */
943   <END-CODE>
944     fputs("</HEAD>", outfile);
945 <TEXT-CODE IMAGE>
946     outchar(m_textchar, outfile) ;
947
948 <ELEMENT HELPVOLUME>
949   <START-CODE>
950     char   hostname[BIGBUF];
951     char **tossline = toss;
952     char  *mb_language, *mb_charset;
953     long   timeStamp;
954
955     ModifyEntities(); /* convert SDATA [......] to <spc name="[......]"> */
956
957     if (!getenv("_DTHELPTAG_NO_UNIQUE_ID"))
958         {
959         hostname[sizeof(hostname)-1] = '\0';
960         gethostname(hostname, sizeof(hostname)-1);
961
962         docId = mb_malloc(strlen(hostname)+1);
963         strcpy(docId, hostname);
964
965         timeStamp = time(0);
966         }
967     else
968         {
969         docId = "test";
970         timeStamp = 0;
971         }
972
973
974     thisnodelevel = 0;
975     fprintf(outfile,
976             "<SDLDOC %s=\"%s\" %s=\"%s\" %s=\"%ld\" %s=\"%s-%s\"",
977             "PUB-ID",
978             pubId,
979             "DOC-ID",
980             docId,
981             "TIMESTMP",
982             timeStamp,
983             "FIRST-PAGE",
984             sdlReservedName,
985             "HOMETOPIC");
986     if (helplang)
987         {
988         mb_language = MakeMByteString(helplang);
989         fprintf(outfile, " %s=\"%s\"", "LANGUAGE", mb_language);
990         mb_free(&mb_language);
991         }
992     if (helpcharset)
993         {
994         mb_charset = MakeMByteString(helpcharset);
995         fprintf(outfile, " %s=\"%s\"", "CHARSET", mb_charset);
996         mb_free(&mb_charset);
997         }
998     fprintf(outfile, " %s=\"%s\">\n", "SDLDTD", "1.1.1");
999     fprintf(outfile, "<VSTRUCT DOC-ID=\"%s\">\n", docId);
1000     fputs("<LOIDS>\n</LOIDS>\n", outfile);
1001     IncludeToss();
1002     fputs("</VSTRUCT>\n", outfile);
1003     snbstart = ftell(outfile);
1004   <END-CODE>
1005     assert_hometopic_exists();
1006     fputs("</SDLDOC>\n", outfile);
1007
1008 <ELEMENT HOMETOPIC>
1009   <START-CODE>
1010      static char hometopic[] = "-HOMETOPIC";
1011      char id[SDLNAMESIZ+sizeof(hometopic)];
1012
1013      sprintf(id, "%s%s", sdlReservedName, hometopic);
1014      mb_starthelpnode("_HOMETOPIC", id, 1);
1015      nohometopic = FALSE;
1016   <END-CODE>
1017     CloseVirpage();
1018
1019 <ELEMENT IDSECTION>
1020
1021 <ELEMENT IDX>
1022   <START-CODE>
1023     have_index = TRUE ;
1024     print[0] = '\0';
1025     subprint[0] = '\0';
1026     sort[0] = '\0';
1027     subsort[0] = '\0';
1028   <END-CODE>
1029      /* ignore <idx end>'s in cache creek */
1030     { /* sort field */
1031     char *mb_print, *mb_nospace1, *mb_nospace2, id[32];
1032     M_WCHAR *pwc, wnl, wsp;
1033
1034     mbtowc(&wnl, "\n", 1);
1035     mbtowc(&wsp, " ", 1);
1036
1037     pwc = print;
1038     while (pwc = w_strchr(pwc, wnl))
1039         *pwc = wsp;
1040     mb_print = MakeMByteString(print);
1041     if (w_strlen(sort) > 0)
1042         { /* use sort[] */
1043         char *mb_sort;
1044
1045         pwc = sort;
1046         while (pwc = w_strchr(pwc, wnl))
1047             *pwc = wsp;
1048         mb_sort = MakeMByteString(sort);
1049         if (w_strlen(subsort) > 0 || w_strlen(subprint) > 0)
1050             {
1051             /* append subsort or subprint */
1052             char *mb_sub;
1053             M_WCHAR *pwcSub;
1054
1055             pwcSub = (w_strlen(subsort) > 0) ? subsort : subprint;
1056             pwc = pwcSub;
1057             while (pwc = w_strchr(pwc, wnl))
1058                 *pwc = wsp;
1059             mb_sub = MakeMByteString(pwcSub);
1060
1061             /* strip trailing spaces */
1062             mb_nospace1 = mb_sort;
1063             while (*mb_nospace1++); --mb_nospace1; /* end of string */
1064             while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1065             mb_nospace2 = mb_sub;
1066             while (*mb_nospace2++); --mb_nospace2; /* end of string */
1067             while (*--mb_nospace2 == ' ') *mb_nospace2 = '\0';
1068
1069             /* strip leading spaces */
1070             mb_nospace1 = mb_sort;
1071             while (*mb_nospace1++ == ' '); --mb_nospace1;
1072             mb_nospace2 = mb_sub;
1073             while (*mb_nospace2++ == ' '); --mb_nospace2;
1074
1075             fprintf(indexfp, "%s, %s", mb_nospace1, mb_nospace2);
1076             m_free(mb_sub,"multi-byte string");
1077             }
1078         else
1079             { /* plain sort */
1080             /* strip trailing spaces */
1081             mb_nospace1 = mb_sort;
1082             while (*mb_nospace1++); --mb_nospace1; /* end of string */
1083             while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1084
1085             /* strip leading spaces */
1086             mb_nospace1 = mb_sort;
1087             while (*mb_nospace1++ == ' '); --mb_nospace1;
1088
1089             fprintf(indexfp, "%s", mb_nospace1);
1090             }
1091         m_free(mb_sort,"multi-byte string");
1092         }
1093     else
1094         { /* use print field */
1095         if (w_strlen(subsort) > 0 || w_strlen(subprint) > 0)
1096             {
1097             /* append subsort or subprint */
1098             char *mb_sub;
1099             M_WCHAR *pwcSub;
1100
1101             pwcSub = (w_strlen(subsort) > 0) ? subsort : subprint;
1102             pwc = pwcSub;
1103             while (pwc = w_strchr(pwc, wnl))
1104                 *pwc = wsp;
1105             mb_sub = MakeMByteString(pwcSub);
1106
1107             /* strip trailing spaces */
1108             mb_nospace1 = mb_print;
1109             while (*mb_nospace1++); --mb_nospace1; /* end of string */
1110             while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1111             mb_nospace2 = mb_sub;
1112             while (*mb_nospace2++); --mb_nospace2; /* end of string */
1113             while (*--mb_nospace2 == ' ') *mb_nospace2 = '\0';
1114
1115             /* strip leading spaces */
1116             mb_nospace1 = mb_print;
1117             while (*mb_nospace1++ == ' '); --mb_nospace1;
1118             mb_nospace2 = mb_sub;
1119             while (*mb_nospace2++ == ' '); --mb_nospace2;
1120
1121             fprintf(indexfp, "%s, %s", mb_nospace1, mb_nospace2);
1122             m_free(mb_sub,"multi-byte string");
1123             }
1124         else
1125             { /* plain print */
1126             /* strip trailing spaces */
1127             mb_nospace1 = mb_print;
1128             while (*mb_nospace1++); --mb_nospace1; /* end of string */
1129             while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1130
1131             /* strip leading spaces */
1132             mb_nospace1 = mb_print;
1133             while (*mb_nospace1++ == ' '); --mb_nospace1;
1134
1135             fprintf(indexfp, "%s", mb_nospace1);
1136             }
1137         }
1138     putc('\036' /* ascii record separator */, indexfp);
1139
1140     /* print field */
1141     if (w_strlen(subprint) > 0)
1142         {
1143         char *mb_subprint;
1144
1145         pwc = subprint;
1146         while (pwc = w_strchr(pwc, wnl))
1147             *pwc = wsp;
1148         mb_subprint = MakeMByteString(subprint);
1149
1150         /* strip trailing spaces */
1151         mb_nospace1 = mb_print;
1152         while (*mb_nospace1++); --mb_nospace1; /* end of string */
1153         while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1154         mb_nospace2 = mb_subprint;
1155         while (*mb_nospace2++); --mb_nospace2; /* end of string */
1156         while (*--mb_nospace2 == ' ') *mb_nospace2 = '\0';
1157
1158         /* strip leading spaces */
1159         mb_nospace1 = mb_print;
1160         while (*mb_nospace1++ == ' '); --mb_nospace1;
1161         mb_nospace2 = mb_subprint;
1162         while (*mb_nospace2++ == ' '); --mb_nospace2;
1163
1164         fprintf(indexfp, "%s, %s", mb_nospace1, mb_nospace2);
1165         m_free(mb_subprint,"multi-byte string");
1166         }
1167     else
1168         {
1169         /* strip trailing spaces */
1170         mb_nospace1 = mb_print;
1171         while (*mb_nospace1++); --mb_nospace1; /* end of string */
1172         while (*--mb_nospace1 == ' ') *mb_nospace1 = '\0';
1173
1174         /* strip leading spaces */
1175         mb_nospace1 = mb_print;
1176         while (*mb_nospace1++ == ' '); --mb_nospace1;
1177
1178         fprintf(indexfp, "%s", mb_nospace1);
1179         }
1180     m_free(mb_print,"multi-byte string");
1181     putc('\036' /* ascii record separator */, indexfp);
1182
1183     /* id field */
1184     if (inSdlP)
1185         {
1186         if (inParText)
1187             {
1188             sprintf(id, "%s%d", sdlReservedName, NextId());
1189             fprintf(outfile, "<ANCHOR ID=\"%s\">", id);
1190             fputs(id, indexfp);
1191             fputs("\n", indexfp);
1192             }
1193         else
1194             {
1195             if (!parTextId)
1196                 parTextId = NextId();
1197             sprintf(id, "%s%d", sdlReservedName, parTextId);
1198             fputs(id, indexfp);
1199             fputs("\n", indexfp);
1200             }
1201         }
1202     else if (*nodeid)
1203         {
1204         char *mb_nodeid;
1205
1206         mb_nodeid = MakeMByteString(nodeid);
1207         fputs(mb_nodeid, indexfp);
1208         fputs("\n", indexfp);
1209         m_free(mb_nodeid,"multi-byte string");
1210         }
1211     else
1212         fprintf(indexfp, "%s-HOMETOPIC\n", sdlReservedName);
1213     }
1214   <TEXT-CODE>
1215     indexchar(m_textchar) ;
1216
1217 <ELEMENT IMAGE>
1218   <PARAM>
1219     indent = INDENT ;
1220     gentity = GENTITY  ;
1221     gposition = GPOSITION (QLEFT = LEFT,
1222                            QRIGHT = RIGHT) ;
1223     ghyperlink = GHYPERLINK  ;
1224     glinktype = GLINKTYPE (QJUMP = JUMP,
1225                            QJUMPNEWVIEW = JUMPNEWVIEW,
1226                            QDEFINITION = DEFINITION,
1227                            QEXECUTE = EXECUTE,
1228                            QAPPDEFINED = APPDEFINED,
1229                            QMAN = MAN) ;
1230     gdescription = GDESCRIPTION  ;
1231     id = ID;
1232   <START-CODE>
1233     indentp = indent;
1234     imagegentityp = gentity;
1235     imagegpositionp = gposition;
1236     imageghyperlinkp = ghyperlink;
1237     imageglinktypep = glinktype;
1238     imagegdescription = gdescription;
1239
1240     if (!inBlock)
1241         StartBlock(NULL, NULL, NULL);
1242
1243     inSdlP = TRUE;
1244     fputs("<P TYPE=\"LITERAL\"", outfile);
1245     if (id) {
1246       if (imageId)
1247           m_free(imageId,"multi-byte string");
1248       imageId = MakeMByteString(id);
1249       fprintf(outfile, " ID=\"%s\"", imageId);
1250       savid = checkid(id);
1251     }
1252     fputs(" SSI=\"IMAGE", outfile);
1253     if (indentp)
1254         {
1255         fputs("-INDENT", outfile);
1256         }
1257     fputs("\">", outfile);
1258   <END-CODE>
1259     inSdlP = FALSE;
1260     fputs("</P>\n", outfile);
1261   <TEXT-CODE>
1262     imoutchar(m_textchar) ;
1263
1264 <ELEMENT INDEXPRIMARY>
1265   <START-CODE>
1266     idxsavlen = 0; 
1267     didsort = FALSE;
1268   <END-CODE>
1269     /* capture saved term unless <sort> got it already */
1270     if (! didsort) {
1271          idxsav[idxsavlen] = M_EOS;
1272          w_strcpy(print, idxsav);
1273         
1274     }
1275     else { /* save the sort field */
1276          idxsav[idxsavlen] = M_EOS;
1277          w_strcpy(sort, idxsav);
1278     }
1279
1280 <ELEMENT INDEXSUB>
1281   <START-CODE>
1282     idxsavlen = 0; 
1283     didsubsort = FALSE;
1284   <END-CODE>
1285     /* capture saved term unless <sort> got it already */
1286     if (! didsubsort) {
1287          idxsav[idxsavlen] = M_EOS;
1288          w_strcpy(subprint, idxsav);
1289     }
1290     else { /* save the sort field */
1291          idxsav[idxsavlen] = M_EOS;
1292          w_strcpy(subsort, idxsav);
1293     }
1294
1295 <ELEMENT ITEM>
1296   <PARAM>
1297     id = ID ;
1298   <START-CODE>
1299     Item(id) ;
1300
1301 <ELEMENT KEYCAP>
1302   <START-CODE * IDX>
1303     indexchar('[');
1304   <START-CODE>
1305     mb_strcode("<KEY CLASS=\"MACH-CONT\">", outfile) ;
1306     if (echo) mb_echohead("[[") ;
1307   <END-CODE * IDX>
1308     indexchar(']');
1309   <END-CODE>
1310     mb_strcode("</KEY>", outfile) ;
1311     if (echo) mb_echohead("]]") ;
1312   <TEXT-CODE * IDX>
1313     indexchar(m_textchar) ;
1314   <TEXT-CODE>
1315      esoutchar(m_textchar) ;
1316
1317 <ELEMENT LABEL>
1318   <START-CODE>
1319     char *first, *loose, *wrap;
1320
1321     first = "";
1322     if (listitems[list].firstitem)
1323         {
1324         first = "FIRST-";
1325         if (needFData)
1326             {
1327             fputs("<FDATA>\n", outfile);
1328             needFData = FALSE;
1329             }
1330         }
1331     loose = lablisttight[list] ? "TIGHT" : "LOOSE";
1332     wrap  = (listitems[list].longlabel == WRAP) ? "" : " TYPE=\"LINED\"";
1333     labelid[list] = NextId();
1334     fprintf(outfile,
1335             "<BLOCK ID=\"%s%d\" CLASS=\"ITEM\" SSI=\"%s%s-LABEL\">\n",
1336             sdlReservedName,
1337             labelid[list],
1338             first,
1339             loose);
1340     fprintf(outfile, "<P%s>", wrap);
1341   <END-CODE>
1342     char *first, *loose;
1343     char  ssi[BIGBUF], labelId[BIGBUF];
1344
1345     fputs("</P>\n</BLOCK>\n", outfile);
1346
1347     first = "";
1348     if (listitems[list].firstitem)
1349         {
1350         first = "FIRST-";
1351         listitems[list].firstitem = FALSE;
1352         }
1353     loose = lablisttight[list] ? "TIGHT" : "LOOSE";
1354     sprintf(ssi, "%s%s", first, loose);
1355
1356     sprintf(labelId, "%s%d", sdlReservedName, labelid[list]);
1357
1358     PushForm2("ITEM", ssi, labelId, NULL);
1359
1360 <ELEMENT LABH>
1361   <START-CODE>
1362     if (listitems[list].firstitem)
1363         {
1364         listitems[list].firstitem = FALSE;
1365         }
1366     labhid[list] = NextId();
1367     if (needFData)
1368         {
1369         fputs("<FDATA>\n", outfile);
1370         needFData = FALSE;
1371         }
1372     fprintf(outfile,
1373             "<BLOCK ID=\"%s%d\" CLASS=\"ITEM\" SSI=\"LABH-%s\">\n",
1374             sdlReservedName,
1375             labhid[list],
1376             lablisttight[list] ? "TIGHT" : "LOOSE");
1377     fputs("<P TYPE=\"LINED\">", outfile);
1378   <END-CODE>
1379     fputs("</P>\n</BLOCK>\n", outfile);
1380
1381 <ELEMENT LABHTEXT>
1382   <START-CODE>
1383     labhtextid[list] = NextId();
1384     fprintf(outfile,
1385             "<BLOCK ID=\"%s%d\" CLASS=\"ITEM\" SSI=\"LABHTEXT-%s\">\n",
1386             sdlReservedName,
1387             labhtextid[list],
1388             lablisttight[list] ? "TIGHT" : "LOOSE");
1389     fputs("<P TYPE=\"LINED\">", outfile);
1390   <END-CODE>
1391     char labh_id[SDLNAMESIZ + 10], labhtext_id[SDLNAMESIZ + 10];
1392
1393     fputs("</P>\n</BLOCK>\n", outfile);
1394
1395     strcpy(labh_id, sdlReservedName);
1396     m_itoa(labhid[list], labh_id + SDLNAMESIZ - 1);
1397     strcpy(labhtext_id, sdlReservedName);
1398     m_itoa(labhtextid[list], labhtext_id + SDLNAMESIZ - 1);
1399     Add2ToRowVec(&formStackTop->vecLen,
1400                  &formStackTop->rowVec,
1401                  labh_id,
1402                  labhtext_id);
1403
1404 <ELEMENT LABHEADS>
1405
1406 <ELEMENT LABLIST>
1407   <PARAM>
1408     longlabel = LONGLABEL (QWRAP = WRAP,
1409                            QNOWRAP = NOWRAP) ;
1410     spacing = SPACING (QTIGHT = TIGHT,
1411                        QLOOSE = LOOSE) ;
1412   <START-CODE>
1413     StartLabList(spacing, longlabel);
1414   <END-CODE>
1415     PopForm2();
1416     list--;
1417
1418 <ELEMENT LABLISTITEM>
1419
1420 <ELEMENT LINENO>
1421   <PARAM>
1422     id = ID ;
1423   <START-CODE>
1424     char mb_xrefstring[400];
1425
1426     if (! tonumexlines) 
1427       m_error(
1428     "Preparing cross-reference to a line in an example without line numbers"
1429       ) ;
1430     sprintf(mb_xrefstring, "%d", exLineNum) ;
1431     mbstowcs(xrefstring, mb_xrefstring, 400);
1432     xstrlen = w_strlen(xrefstring) ;
1433     m_getline(&xrffile, &xrfline) ;
1434     if (xrffile == NULL) {
1435            /* set to primary input */
1436            xrffile = inputname;
1437     }
1438     setid(id,
1439           TRUE,
1440           FALSE,
1441           inchapter,
1442           chapstring,
1443           xrffile,
1444           xrfline,
1445           TRUE) ;
1446     {
1447     char *mb_id, buffer[BIGBUF];
1448
1449     mb_id = MakeMByteString(id);
1450     sprintf(buffer, "<ANCHOR ID=\"%s\">", mb_id);
1451     mb_strcode(buffer, outfile);
1452     m_free(mb_id,"multi-byte string");
1453     }
1454
1455 <ELEMENT LINK>
1456   <PARAM>
1457      hyperlink = HYPERLINK  ;
1458      type = TYPE (QJUMP = JUMP,
1459                   QJUMPNEWVIEW = JUMPNEWVIEW,
1460                   QDEFINITION = DEFINITION,
1461                   QEXECUTE = EXECUTE,
1462                   QAPPDEFINED = APPDEFINED,
1463                   QMAN = MAN) ;
1464      description = DESCRIPTION  ;
1465   <START-CODE>
1466      HandleLink(hyperlink, type, description);
1467   <END-CODE>
1468      /* reset link type to default.  This is braindead, but enough.
1469
1470         E.g.,
1471
1472            <link foo DEFINITION><XREF bar></link> 
1473
1474         will do the right thing (remember that xref turns to an implicit link).
1475         Right_thing => xref becomes definition link.
1476
1477         However, in
1478
1479            <link foo DEFINITION> <link fub> Test </link> <xref bar> </link>
1480
1481         the xref will think that is supposed to become a link of type jump,
1482         not definition.  This case is odd, so we won't worry about it.
1483      */
1484      global_linktype = 0; 
1485      mb_strcode("</LINK>", outfile);
1486
1487 <ELEMENT LIST>
1488   <PARAM>
1489     type = TYPE (QORDER = ORDER,
1490                  QBULLET = BULLET,
1491                  QPLAIN = PLAIN,
1492                  QMILSPEC = MILSPEC,
1493                  QCHECK = CHECK) ;
1494     order = ORDERTYPE (QUALPHA = UALPHA,
1495                        QLALPHA = LALPHA,
1496                        QARABIC = ARABIC,
1497                        QUROMAN = UROMAN,
1498                        QLROMAN = LROMAN) ;
1499     spacing = SPACING (QTIGHT = TIGHT,
1500                        QLOOSE = LOOSE) ;
1501     cont = CONTINUE ;
1502   <START-CODE>
1503     StartList(type, order, spacing, cont) ;
1504   <END-CODE>
1505     EndList();
1506
1507 <ELEMENT LOCATION>
1508   <PARAM>
1509     id = ID  ;
1510   <START-CODE>
1511     if (id)
1512         {
1513         char *mb_id;
1514         char buffer[BIGBUF];
1515
1516         mb_id = MakeMByteString(id);
1517         sprintf(buffer, "<ANCHOR ID=\"%s\">", mb_id);
1518         mb_strcode(buffer, outfile);
1519         m_free(mb_id,"multi-byte string");
1520
1521         savid = checkid(id);
1522         }
1523   <END-CODE>
1524     if (savid)
1525         {
1526         mb_shchar(M_EOS,
1527                   &xstrlen,
1528                   (sizeof(xrefstring) / sizeof(M_WCHAR)),
1529                   xrefstring,
1530                   idstring,
1531                   "Too many characters in corresponding cross-reference",
1532                   &iderr);
1533         setid(savid,
1534               TRUE,
1535               TRUE,
1536               inchapter,
1537               chapstring,
1538               xrffile,
1539               xrfline,
1540               TRUE);
1541         }
1542
1543 <ELEMENT MEMO>
1544   <TEXT-CODE>
1545     if (memo && inSdlP)
1546         {
1547         if (m_textchar == '"')
1548             { /* handle funny quote in memo bug */
1549             }
1550         else
1551             {
1552             outchar(m_textchar, outfile);
1553             }
1554         }
1555   <PI-CODE>
1556     /* could need to handle calculator context sensitive entities
1557      * here if needed to reduce tex macro count 
1558      */
1559     if (memo)
1560         {
1561         outpi(m_enttype, m_pi, m_entname) ;
1562         }
1563
1564 <ELEMENT MESSAGE>
1565   <START-CODE>
1566     thisnodelevel = 2;
1567     mb_starthelpnode("MESSAGE", "", thisnodelevel);
1568     chapst = FALSE ;
1569     fprintf(stderr, "\nMessages.\n") ;
1570     emsghead = DEFHEAD ;
1571   <END-CODE>
1572     CloseVirpage();
1573     thisnodelevel = 0;
1574
1575 <ELEMENT METAINFO>
1576
1577 <ELEMENT MSG>
1578   <START-CODE>
1579     PushForm(NULL, "MSG", NULL);
1580     checkmsghead() ;
1581   <END-CODE>
1582     PopForm();
1583
1584 <ELEMENT MSGNUM>
1585   <START-CODE>
1586     fputs("<HEAD SSI=\"MSGNUM\">", outfile);
1587   <END-CODE>
1588     fputs("</HEAD>\n", outfile);
1589
1590 <ELEMENT MSGSUB>
1591   <PARAM>
1592     include = INCLUDE  ;
1593     exclude = EXCLUDE  ;
1594   <START-CODE>
1595     PushForm(NULL, NULL, NULL);
1596     checkmsghead() ;
1597     chapst = TRUE ;
1598     savid = checkid(NULL) ; /* hook for possible future ID */
1599     iderr = FALSE ;
1600   <END-CODE>
1601     PopForm();
1602
1603 <ELEMENT MSGTEXT>
1604   <START-CODE>
1605     inSdlP = TRUE;
1606     StartBlock(NULL, "MSGTEXT", NULL);
1607     fputs("<P>", outfile);
1608   <END-CODE>
1609     inSdlP = FALSE;
1610     fputs("</P>\n", outfile);
1611
1612 <ELEMENT NEWLINE>
1613   <START-CODE * TITLE, * HEAD, * ABBREV, * CAPTION>
1614       mb_strcode("\n", outfile);
1615   <START-CODE>
1616       fputs("&\n", outfile) ;
1617        
1618 <ELEMENT NOTE>
1619   <START-CODE>
1620     StartNCW("NOTE");
1621
1622 <ELEMENT OPTBLOCK>
1623   <START-CODE>
1624     synelcnt = 0;
1625     fputs("[", outfile);
1626   <END-CODE>
1627     fputs("]", outfile);
1628
1629 <ELEMENT OTHERFRONT>
1630   <PARAM>
1631     id = ID  ;
1632   <START-CODE>
1633      char    *mb_id;
1634
1635      if (!id)
1636          mb_id = NULL;
1637      else
1638          mb_id = MakeMByteString(id);
1639      mb_starthelpnode("METAINFO", mb_id, 0);
1640      if (mb_id)
1641          m_free(mb_id, "multi-byte string");
1642      had_an_otherfront_head = FALSE;
1643      savid = checkid(id) ;
1644      iderr = FALSE ;
1645   <END-CODE>
1646     CloseVirpage();
1647      if (id && !had_an_otherfront_head) {
1648         m_errline("You must use a <HEAD> tag after <OTHERFRONT>\n");
1649      }
1650
1651 <ELEMENT OTHERHEAD>
1652   <START-CODE>
1653     PushForm(NULL, "OTHERHEAD", NULL);
1654   <END-CODE>
1655     PopFormMaybe();
1656
1657 <ELEMENT P>
1658   <PARAM>
1659     indent = INDENT ;
1660     gentity = GENTITY  ;
1661     gposition = GPOSITION (QLEFT = LEFT,
1662                            QRIGHT = RIGHT) ;
1663     ghyperlink = GHYPERLINK  ;
1664     glinktype = GLINKTYPE (QJUMP = JUMP,
1665                            QJUMPNEWVIEW = JUMPNEWVIEW,
1666                            QDEFINITION = DEFINITION,
1667                            QEXECUTE = EXECUTE,
1668                            QAPPDEFINED = APPDEFINED,
1669                            QMAN = MAN) ;
1670     gdescription = GDESCRIPTION  ;
1671     id = ID;
1672   <START-CODE>
1673     paragraph(indent,
1674               id,
1675               gentity,
1676               gposition,
1677               ghyperlink,
1678               glinktype,
1679               gdescription);
1680   <END-CODE>
1681     inSdlP = FALSE;
1682     fputs("\n</P>\n", outfile);
1683
1684 <ELEMENT PARTEXT>
1685   <START-CODE INDEXPRIMARY, INDEXSUB, * ABBREV>
1686   <START-CODE IMAGE>
1687     M_WCHAR *wc_image;
1688
1689     wc_image = MakeWideCharString("IMAGE");
1690     handle_link_and_graphic(wc_image,
1691                             imagegentityp,
1692                             imagegpositionp,
1693                             imageghyperlinkp,
1694                             imageglinktypep,
1695                             imagegdescription);
1696     m_free(wc_image,"wide character string");
1697     inParText++;
1698     if (tooutput)
1699         EmitSavedAnchors();
1700   <START-CODE P>
1701     savid = NULL; /* in case there was no head */
1702     inParText++;
1703     if (tooutput)
1704         EmitSavedAnchors();
1705   <START-CODE>
1706     inParText++;
1707     if (tooutput)
1708         EmitSavedAnchors();
1709   <END-CODE INDEXPRIMARY, INDEXSUB, * ABBREV>
1710   <END-CODE HEAD CHAPHEAD, 
1711             HEAD FRONTSUB, 
1712             HEAD OTHERFRONT,
1713             HEAD OTHERHEAD>
1714     putc('\n', stderr) ;
1715     --inParText;
1716   <END-CODE HEAD ABSTRACT>
1717     putc('\n', stderr) ;
1718     --inParText;
1719   <END-CODE>
1720     --inParText;
1721   <TEXT-CODE ABBREV>
1722     M_WCHAR wc_nl;
1723
1724     mbtowc(&wc_nl, "\n", 1);
1725     if (m_textchar == wc_nl)
1726         fputs("&\n", outfile);
1727     else
1728         outchar(m_textchar, outfile);
1729   <TEXT-CODE CAPTION FIGURE>
1730     M_WCHAR wc_nl;
1731
1732     mbtowc(&wc_nl, "\n", 1);
1733     if (m_textchar == wc_nl)
1734         mb_shstring("\n",
1735                     &svheadlen,
1736                     (sizeof(savehead) / sizeof(M_WCHAR)),
1737                     savehead,
1738                     "Too many characters in head or caption",
1739                     &hderr) ;
1740     else
1741         outchar(m_textchar, outfile);
1742   <TEXT-CODE HEAD CHAPHEAD, HEAD OTHERFRONT>
1743     M_WCHAR wc_nl;
1744
1745     mbtowc(&wc_nl, "\n", 1);
1746     if (m_textchar == wc_nl) {
1747       fputs("  ", stderr) ;
1748       mb_strcode("\n", outfile) ;
1749       if (savid) shchar(' ',
1750                         &xstrlen,
1751                         (sizeof(xrefstring) / sizeof(M_WCHAR)),
1752                         xrefstring,
1753                         idstring,
1754                         "Too many characters in corresponding cross-reference",
1755                         &iderr) ;
1756       shchar(' ',
1757              &svheadlen,
1758              (sizeof(savehead) / sizeof(M_WCHAR)),
1759              savehead,
1760              svhdstring,
1761              "Too many characters in head or caption", 
1762              &hderr) ;
1763       }
1764     else
1765       outchar(m_textchar, outfile);
1766   <TEXT-CODE TITLE>
1767     M_WCHAR wc_nl;
1768
1769     mbtowc(&wc_nl, "\n", 1);
1770     if (m_textchar == wc_nl)
1771         fputs("\n", outfile) ;
1772     else
1773         outchar(m_textchar, outfile);
1774   <TEXT-CODE HEAD P,  HEAD IMAGE,  HEAD LIST,
1775              HEAD EX, HEAD SYNTAX, HEAD LABLIST>
1776     M_WCHAR wc_nl;
1777
1778     mbtowc(&wc_nl, "\n", 1);
1779     if (m_textchar == wc_nl)
1780         fputc('\n', outfile) ;
1781     else
1782         outchar(m_textchar, outfile);
1783
1784 <ELEMENT PROCEDURE>
1785   <START-CODE>
1786     PushForm("TEXT", "PROCEDURE", NULL);
1787   <END-CODE>
1788     PopFormMaybe();
1789   
1790 <ELEMENT QUOTE>
1791   <START-CODE * ABBREV>
1792     mb_strcode("``", outfile) ;
1793     if (echo) putc('"', stderr) ;
1794   <START-CODE>
1795     mb_strcode("<KEY CLASS=\"QUOTE\" SSI=\"OPEN\"></KEY>", outfile) ;
1796     if (echo) putc('"', stderr) ;
1797   <END-CODE * ABBREV>
1798     mb_strcode("''", outfile) ;
1799     if (echo) putc('"', stderr) ;
1800   <END-CODE>
1801     mb_strcode("<KEY CLASS=\"QUOTE\" SSI=\"CLOSE\"></KEY>", outfile) ;
1802     if (echo) putc('"', stderr) ;
1803
1804   <START-CODE * IDX>
1805     indexchar('\"') ;
1806   <END-CODE * IDX>
1807     indexchar('\"') ;
1808   <TEXT-CODE * IDX>
1809     indexchar(m_textchar) ;
1810
1811 <ELEMENT REQBLOCK>
1812   <START-CODE>
1813     synelcnt = 0;
1814     fputs("{", outfile);
1815   <END-CODE>
1816     fputs("}", outfile);
1817
1818 <ELEMENT RSECT>
1819   <PARAM>
1820     id = ID ;
1821   <START-CODE>
1822     M_WCHAR *wc_rsect, *wc_helpvolume;
1823
1824     wc_rsect      = MakeWideCharString("RSECT");
1825     wc_helpvolume = MakeWideCharString("HELPVOLUME");
1826
1827
1828     assert_hometopic_exists();
1829     if (!rsectseq) thisnodelevel = thisnodelevel + 1;
1830     if (w_strcmp(m_parent(1), wc_helpvolume) != 0)
1831         {
1832         CloseVirpage();
1833         starthelpnode(wc_rsect, id, thisnodelevel);
1834         }
1835     else
1836         starthelpnode(wc_rsect, id, 2);
1837     m_free(wc_rsect, "wide character string");
1838     m_free(wc_helpvolume, "wide character string");
1839     rsectstart(id) ;
1840   <END-CODE>
1841     M_WCHAR *wc_helpvolume;
1842
1843     wc_helpvolume = MakeWideCharString("HELPVOLUME");
1844     if (w_strcmp(m_parent(1), wc_helpvolume) == 0)
1845         CloseVirpage();
1846     m_free(wc_helpvolume, "wide character string");
1847
1848 <ELEMENT RSUB>
1849   <START-CODE>
1850     PushForm(NULL, NULL, NULL);
1851   <START-CODE * S2>
1852     PushForm(NULL, NULL, NULL);
1853   <END-CODE>
1854     PopFormMaybe();
1855
1856 <ELEMENT S1>
1857   <PARAM>
1858     id = ID ;
1859   <START-CODE HELPVOLUME>
1860     M_WCHAR *wc_s1;
1861
1862     wc_s1 = MakeWideCharString("S1");
1863
1864     assert_hometopic_exists();
1865     thisnodelevel = 2;
1866     starthelpnode(wc_s1, id, thisnodelevel);
1867     m_free(wc_s1, "wide character string");
1868     rsectseq = FALSE ;
1869     chapst = TRUE ;
1870     savid = checkid(id) ;
1871     iderr = FALSE ;
1872   <START-CODE>
1873     M_WCHAR *wc_s1;
1874
1875     wc_s1 = MakeWideCharString("S1");
1876
1877     assert_hometopic_exists();
1878     thisnodelevel++;
1879     CloseVirpage();
1880     starthelpnode(wc_s1, id, thisnodelevel);
1881     m_free(wc_s1, "wide character string");
1882     rsectseq = FALSE ;
1883     chapst = TRUE ;
1884     savid = checkid(id) ;
1885     iderr = FALSE ;
1886   <END-CODE HELPVOLUME>
1887     CloseVirpage();
1888     rseqend() ;
1889     thisnodelevel = 0;
1890   <END-CODE>
1891     rseqend() ;
1892     --thisnodelevel;
1893
1894 <ELEMENT S2>
1895   <PARAM>
1896     id = ID ;
1897   <START-CODE>
1898     M_WCHAR *wc_s2;
1899
1900     wc_s2 = MakeWideCharString("S2");
1901
1902     thisnodelevel++;
1903     CloseVirpage();
1904     starthelpnode(wc_s2, id, thisnodelevel);
1905     m_free(wc_s2, "wide character string");
1906     rsectseq = FALSE ;
1907     savid = checkid(id) ;
1908     iderr = FALSE ;
1909   <END-CODE>
1910     rseqend() ;
1911     --thisnodelevel;
1912
1913 <ELEMENT S3>
1914   <PARAM>
1915     id = ID ;
1916   <START-CODE>
1917     M_WCHAR *wc_s3;
1918
1919     wc_s3 = MakeWideCharString("S3");
1920
1921     thisnodelevel++;
1922     CloseVirpage();
1923     starthelpnode(wc_s3, id, thisnodelevel);
1924     m_free(wc_s3, "wide character string");
1925     rsectseq = FALSE ;
1926     savid = checkid(id) ;
1927     iderr = FALSE ;
1928   <END-CODE>
1929     rseqend() ;
1930     --thisnodelevel;
1931
1932 <ELEMENT S4>
1933   <PARAM>
1934     id = ID ;
1935   <START-CODE>
1936     M_WCHAR *wc_s4;
1937
1938     wc_s4 = MakeWideCharString("S4");
1939
1940     thisnodelevel++;
1941     CloseVirpage();
1942     starthelpnode(wc_s4, id, thisnodelevel);
1943     m_free(wc_s4, "wide character string");
1944     rsectseq = FALSE ;
1945     savid = checkid(id) ;
1946     iderr = FALSE ;
1947   <END-CODE>
1948     rseqend() ;
1949     --thisnodelevel;
1950
1951 <ELEMENT S5>
1952   <PARAM>
1953     id = ID ;
1954   <START-CODE>
1955     M_WCHAR *wc_s5;
1956
1957     wc_s5 = MakeWideCharString("S5");
1958
1959     thisnodelevel++;
1960     CloseVirpage();
1961     starthelpnode(wc_s5, id, thisnodelevel);
1962     m_free(wc_s5, "wide character string");
1963     rsectseq = FALSE ;
1964     savid = checkid(id) ;
1965     iderr = FALSE ;
1966   <END-CODE>
1967     rseqend() ;
1968     --thisnodelevel;
1969
1970 <ELEMENT S6>
1971   <PARAM>
1972     id = ID ;
1973   <START-CODE>
1974     M_WCHAR *wc_s6;
1975
1976     wc_s6 = MakeWideCharString("S6");
1977
1978     thisnodelevel++;
1979     CloseVirpage();
1980     starthelpnode(wc_s6, id, thisnodelevel);
1981     m_free(wc_s6, "wide character string");
1982     rsectseq = FALSE ;
1983     savid = checkid(id) ;
1984     iderr = FALSE ;
1985   <END-CODE>
1986     rseqend() ;
1987     --thisnodelevel;
1988
1989 <ELEMENT S7>
1990   <PARAM>
1991     id = ID ;
1992   <START-CODE>
1993     M_WCHAR *wc_s7;
1994
1995     wc_s7 = MakeWideCharString("S7");
1996
1997     thisnodelevel++;
1998     CloseVirpage();
1999     starthelpnode(wc_s7, id, thisnodelevel);
2000     m_free(wc_s7, "wide character string");
2001     rsectseq = FALSE ;
2002     savid = checkid(id) ;
2003     iderr = FALSE ;
2004   <END-CODE>
2005     rseqend() ;
2006     --thisnodelevel;
2007
2008 <ELEMENT S8>
2009   <PARAM>
2010     id = ID ;
2011   <START-CODE>
2012     M_WCHAR *wc_s8;
2013
2014     wc_s8 = MakeWideCharString("S8");
2015
2016     thisnodelevel++;
2017     CloseVirpage();
2018     starthelpnode(wc_s8, id, thisnodelevel);
2019     m_free(wc_s8, "wide character string");
2020     rsectseq = FALSE ;
2021     savid = checkid(id) ;
2022     iderr = FALSE ;
2023   <END-CODE>
2024     rseqend() ;
2025     --thisnodelevel;
2026
2027 <ELEMENT S9>
2028   <PARAM>
2029     id = ID ;
2030   <START-CODE>
2031     M_WCHAR *wc_s9;
2032
2033     wc_s9 = MakeWideCharString("S9");
2034
2035     thisnodelevel++;
2036     CloseVirpage();
2037     starthelpnode(wc_s9, id, thisnodelevel);
2038     m_free(wc_s9, "wide character string");
2039     rsectseq = FALSE ;
2040     savid = checkid(id) ;
2041     iderr = FALSE ;
2042   <END-CODE>
2043     rseqend() ;
2044     --thisnodelevel;
2045
2046 <ELEMENT SORT>
2047   <START-CODE INDEXPRIMARY>
2048      didsort = TRUE;
2049      idxsav[idxsavlen] = M_EOS;
2050      w_strcpy(print, idxsav);
2051      idxsavlen = 0;
2052   <END-CODE INDEXPRIMARY>
2053      idxsav[idxsavlen] = M_EOS;
2054      w_strcpy(sort, idxsav);
2055   <START-CODE INDEXSUB>
2056      didsubsort = TRUE;
2057      idxsav[idxsavlen] = M_EOS;
2058      w_strcpy(subprint, idxsav);
2059      idxsavlen = 0;
2060   <END-CODE INDEXSUB>
2061      idxsav[idxsavlen] = M_EOS;
2062      w_strcpy(subsort, idxsav);
2063   <START-CODE>
2064   <END-CODE>
2065
2066 <ELEMENT SUB>
2067   <START-CODE * IDX>
2068   <START-CODE>
2069     mb_strcode("<KEY CLASS=\"UDEFKEY\" SSI=\"SUB\">", outfile);
2070     mb_strcode("<SPHRASE CLASS=\"SUB\">", outfile);
2071     if (echo) mb_echohead("__") ;
2072   <END-CODE * IDX>
2073   <END-CODE>
2074     mb_strcode("</SPHRASE></KEY>", outfile);
2075     if (echo) mb_echohead("__") ;
2076   <TEXT-CODE * COMPUTER>
2077      outchar(m_textchar, outfile) ;
2078   <TEXT-CODE * IDX>
2079     indexchar(m_textchar) ;
2080   <TEXT-CODE * IMAGE>
2081     outchar(m_textchar, outfile) ;
2082
2083 <ELEMENT SUPER>
2084   <START-CODE * IDX>
2085   <START-CODE>
2086     mb_strcode("<KEY CLASS=\"UDEFKEY\" SSI=\"SUPER\">", outfile);
2087     mb_strcode("<SPHRASE CLASS=\"SUPER\">", outfile);
2088     if (echo) mb_echohead("^^") ;
2089   <END-CODE * IDX>
2090   <END-CODE>
2091     mb_strcode("</SPHRASE></KEY>", outfile);
2092     if (echo) mb_echohead("^^") ;
2093   <TEXT-CODE * COMPUTER>
2094      outchar(m_textchar, outfile) ;
2095   <TEXT-CODE * IDX>
2096     indexchar(m_textchar) ;
2097   <TEXT-CODE * IMAGE>
2098      outchar(m_textchar, outfile) ;
2099
2100 <ELEMENT SYNEL>
2101   <START-CODE OPTBLOCK, REQBLOCK>
2102     if (synelcnt++) {
2103         fputs("\n", outfile);
2104     }
2105   <END-CODE OPTBLOCK, REQBLOCK>
2106   <END-CODE>
2107     fputs("\n", outfile);
2108   <TEXT-CODE>
2109      outchar(m_textchar, outfile) ;
2110
2111 <ELEMENT SYNTAX>
2112   <START-CODE>
2113     inSdlP = TRUE;
2114     if (!inBlock)
2115         StartBlock(NULL, NULL, NULL);
2116     fprintf(outfile, "<P TYPE=\"LITERAL\" SSI=\"SYNTAX\">");
2117   <END-CODE>
2118     inSdlP = FALSE;
2119     fputs("</P>\n", outfile);
2120   <TEXT-CODE>
2121     outchar(m_textchar, outfile) ;
2122
2123 <ELEMENT TERM>
2124   <PARAM>
2125     base = BASE ;
2126     gloss = GLOSS (QGLOSS = GLOSS,
2127                    QNOGLOSS = NOGLOSS) ;
2128   <START-CODE>
2129     termp = term ;
2130     wsterm = FALSE ;
2131     tooutput = FALSE;
2132     if (echo) mb_echohead("++") ;
2133   <END-CODE * GLOSSARY>
2134     endterm(base, gloss, "current"); /* don't use definition window for link */
2135   <END-CODE>
2136     endterm(base, gloss, "popup");   /* use definition window for link       */
2137   <TEXT-CODE>
2138     termchar(m_textchar) ;
2139   <PI-CODE>
2140     termpi(m_enttype, m_pi, m_entname) ;
2141      
2142 <ELEMENT TEXT>
2143   <START-CODE NOTE>
2144     StartNCWtext("NOTE",
2145                  "NoteElementDefaultIconFile",
2146                  "NoteElementDefaultHeadingString");
2147   <START-CODE CAUTION>
2148     StartNCWtext("CAUTION",
2149                  "CautionElementDefaultIconFile",
2150                  "CautionElementDefaultHeadingString");
2151   <START-CODE WARNING>
2152     StartNCWtext("WARNING",
2153                  "WarningElementDefaultIconFile",
2154                  "WarningElementDefaultHeadingString");
2155   <START-CODE MESSAGE>
2156     PushForm(NULL, "MESSAGE", NULL);
2157     checkmsghead() ;
2158   <START-CODE MSGSUB>
2159     PushForm(NULL, "MSGSUB", NULL);
2160   <START-CODE ABSTRACT>
2161      if (needabstracthead)
2162          {
2163          fputs("<HEAD SSI=\"CHAPHEAD\">", outfile);
2164          chksnb();
2165          needabstracthead = FALSE;
2166          }
2167   <START-CODE DEFINITION>
2168     M_WCHAR *p ;
2169     char     id[SDLNAMESIZ+10];
2170
2171     sprintf(id, "%s%d", sdlReservedName, lastTermId);
2172     PushForm(NULL, NULL, id);
2173     StartBlock(NULL, "TERM", NULL);
2174     mb_strcode("<P SSI=\"P\">", outfile);
2175     strcode(term, outfile);
2176     mb_strcode("</P>\n", outfile);
2177     PushForm(NULL, "DEFINITION", NULL);
2178   <START-CODE>
2179   <END-CODE DEFINITION>
2180     PopForm(); PopForm();
2181   <END-CODE>
2182     if (formStackBase && (formStackTop >= formStackBase))
2183         {
2184         if (formStackTop->vecLen == 1)
2185             StartBlock(NULL, NULL, NULL);
2186         PopForm();
2187         }
2188     else if (inBlock)
2189         {
2190         fputs("</BLOCK>\n", outfile);
2191         inBlock = FALSE;
2192         }
2193
2194 <ELEMENT TITLE>
2195   <START-CODE>
2196     fputs("<HEAD TYPE=\"LINED\" SSI=\"TITLE\">", outfile);
2197     hadtitle = TRUE;
2198     newhline = 0 ;
2199     savhd = TRUE ;
2200     hderr = FALSE ;
2201     svheadlen = 0 ;
2202   <END-CODE>
2203     char *mb_savehead, *ssi;
2204     static char title_string[] = "-TITLE";
2205     char id[SDLNAMESIZ+sizeof(title_string)];
2206
2207     if (hderr)
2208         {
2209         m_error("Error collecting title characters.");
2210         }
2211     savhd = FALSE ;
2212
2213     fputs("</HEAD>\n", outfile);
2214
2215     sprintf(id, "%s%s", sdlReservedName, title_string);
2216     mb_starthelpnode("_TITLE", id, 0);
2217
2218     ssi = MakeMByteString(m_parent(1));
2219     fprintf(outfile, "<HEAD TYPE=\"LINED\" SSI=\"%s\">", ssi);
2220     savehead[svheadlen] = M_EOS ;
2221     mb_savehead = MakeMByteString(savehead);
2222     fputs(mb_savehead, outfile);
2223     m_free(mb_savehead,"multi-byte string");
2224     m_free(ssi,"multi-byte string");
2225     fputs("</HEAD>\n", outfile);
2226     CloseVirpage();
2227
2228     savedtitle = (M_WCHAR *) m_malloc(w_strlen(savehead) + 1, "saved title");
2229     w_strcpy(savedtitle, savehead);
2230
2231 <ELEMENT USER>
2232   <START-CODE>
2233     if (echo) {
2234       mb_echohead(m_stago) ;
2235       echohead(m_parent(0)) ;
2236       mb_echohead(m_net) ;
2237       }
2238     mb_strcode("<KEY CLASS=\"MACH-IN\">", outfile) ;
2239   <TEXT-CODE>
2240     esoutchar(m_textchar) ;
2241   <END-CODE>
2242     if (echo) mb_echohead(m_net) ;
2243     mb_strcode("</KEY>", outfile) ;
2244   <TEXT-CODE * EXAMPLESEG>
2245     exoutchar(m_textchar) ;
2246
2247   <START-CODE * IDX>
2248   <END-CODE * IDX>
2249   <TEXT-CODE * IDX>
2250     indexchar(m_textchar) ;
2251
2252 <ELEMENT VAR>
2253   <START-CODE>
2254     mb_strcode("<KEY CLASS=\"NAME\">", outfile) ;
2255     if (echo) mb_echohead("%%") ;
2256   <END-CODE>
2257     mb_strcode("</KEY>", outfile) ;
2258     if (echo) mb_echohead("%%") ;
2259
2260   <START-CODE * IDX>
2261   <END-CODE * IDX>
2262   <TEXT-CODE * IDX>
2263     indexchar(m_textchar) ;
2264
2265   <END-CODE * EXAMPLESEG, * IMAGE, * SYNEL>
2266     mb_strcode("</KEY>", outfile) ;
2267
2268   /* added to fix calculator computer chars */
2269   <TEXT-CODE * SYNEL> 
2270     if (m_textchar == M_SPACE) fputs("\\ ", outfile) ;
2271     else outchar(m_textchar, outfile) ;
2272
2273 <ELEMENT VEX>
2274   <PARAM>
2275     textsize = TEXTSIZE (QNORMAL = NORMAL,
2276                          QSMALLER = SMALLER,
2277                          QSMALLEST = SMALLEST) ;
2278   <START-CODE>
2279     int   tsize;
2280     char *ssi;
2281
2282     inSdlP = TRUE;
2283     StartBlock(NULL, "EX", NULL);
2284     tsize = vextextsize(textsize);
2285     if (tsize == SMALLEST)
2286         ssi = "SMLST";
2287     else if (tsize == SMALLER)
2288         ssi = "SMLR";
2289     else
2290         ssi = "NML";
2291     fprintf(outfile, "<P TYPE=\"LITERAL\" SSI=\"EX-%s\">", ssi);
2292   <END-CODE>
2293     inSdlP = FALSE;
2294     fputs("</P>\n", outfile);
2295     fputs("</BLOCK>\n", outfile);
2296     inBlock = FALSE;
2297   <TEXT-CODE>
2298     vexoutchar(m_textchar) ;
2299
2300 <ELEMENT WARNING>
2301   <START-CODE>
2302     StartNCW("WARNING");
2303
2304 <ELEMENT XREF>
2305 /* Cross-referencing that allows forward references is inherently a two-pass
2306 process.  However, this interface assumes a two-pass process.  MARKUP
2307 provides the first pass and TeX the second.  MARKUP can therefore define
2308 a TeX macro for every cross-reference and write a file of definitions of
2309 these macros that is read at the beginning of the TeX pass.  In fact,
2310 information about cross-references is stored in a trie by MARKUP.  Data is
2311 entered into this structure both when a cross-reference is defined (with
2312 an id parameter on a chapter, figure, etc.) and when it is used (with the
2313 xref element).  At the end of the manual, the file xref.tex is written
2314 with definitions of macros corresponding to all cross-references defined
2315 or accessed.  In addition, the file xreftbl is written to save this
2316 information in a form that can be read to initialize the trie the next
2317 time the manual is processed.  Saving cross-reference information across
2318 runs of MARKUP allows a manual to be processed a chapter at a time without
2319 invalidating interchapter references.  The file xreftbl should be
2320 deleted before final processing, however, to verify that no cross-references
2321 remain to an id that existed at one time and was deleted.  Such an id could
2322 remain in the cross-reference table indefinitely.
2323 */
2324   <PARAM>
2325     id = ID ;
2326   <START-CODE * IDX>
2327   <TEXT-CODE * IDX>
2328     indexchar(m_textchar) ;
2329   <START-CODE>
2330     xrefexpand(id) ;