1 | /* cmds.c -- Texinfo commands. |
---|
2 | $Id: cmds.c,v 1.1.1.2 2003-02-28 17:45:05 amb Exp $ |
---|
3 | |
---|
4 | Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software |
---|
5 | Foundation, Inc. |
---|
6 | |
---|
7 | This program is free software; you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation; either version 2, or (at your option) |
---|
10 | any later version. |
---|
11 | |
---|
12 | This program is distributed in the hope that it will be useful, |
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | GNU General Public License for more details. |
---|
16 | |
---|
17 | You should have received a copy of the GNU General Public License |
---|
18 | along with this program; if not, write to the Free Software Foundation, |
---|
19 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
---|
20 | |
---|
21 | #include "system.h" |
---|
22 | #include "cmds.h" |
---|
23 | #include "defun.h" |
---|
24 | #include "files.h" |
---|
25 | #include "footnote.h" |
---|
26 | #include "html.h" |
---|
27 | #include "insertion.h" |
---|
28 | #include "lang.h" |
---|
29 | #include "macro.h" |
---|
30 | #include "makeinfo.h" |
---|
31 | #include "node.h" |
---|
32 | #include "sectioning.h" |
---|
33 | #include "toc.h" |
---|
34 | #include "xml.h" |
---|
35 | |
---|
36 | #ifdef TM_IN_SYS_TIME |
---|
37 | #include <sys/time.h> |
---|
38 | #else |
---|
39 | #include <time.h> |
---|
40 | #endif |
---|
41 | |
---|
42 | |
---|
43 | void insert_self (), insert_space (), cm_ignore_line (), cm_ignore_arg (); |
---|
44 | |
---|
45 | void |
---|
46 | cm_TeX (), cm_acronym (), cm_asterisk (), cm_b (), cm_bullet (), cm_cite (), |
---|
47 | cm_code (), cm_copyright (), cm_ctrl (), cm_dfn (), cm_dircategory (), |
---|
48 | cm_direntry (), cm_dmn (), cm_dots (), cm_emph (), cm_enddots (), cm_i (), |
---|
49 | cm_image (), cm_kbd (), cm_key (), cm_no_op (), |
---|
50 | cm_novalidate (), cm_not_fixed_width (), cm_r (), |
---|
51 | cm_strong (), cm_var (), cm_sc (), cm_w (), cm_email (), cm_url (), |
---|
52 | cm_verb (), cm_copying (), cm_insert_copying (), |
---|
53 | cm_documentdescription (); |
---|
54 | |
---|
55 | void |
---|
56 | cm_anchor (), cm_node (), cm_menu (), cm_xref (), cm_ftable (), |
---|
57 | cm_vtable (), cm_pxref (), cm_inforef (), cm_uref (), cm_email (), |
---|
58 | cm_quotation (), cm_display (), cm_smalldisplay (), cm_itemize (), |
---|
59 | cm_enumerate (), cm_tab (), cm_table (), cm_itemx (), cm_noindent (), |
---|
60 | cm_setfilename (), cm_br (), cm_sp (), cm_page (), cm_group (), |
---|
61 | cm_center (), cm_ref (), cm_include (), cm_bye (), cm_item (), cm_end (), |
---|
62 | cm_kindex (), cm_cindex (), cm_findex (), cm_pindex (), cm_vindex (), |
---|
63 | cm_tindex (), cm_synindex (), cm_printindex (), cm_minus (), |
---|
64 | cm_example (), cm_smallexample (), cm_smalllisp (), cm_lisp (), |
---|
65 | cm_format (), cm_smallformat (), cm_exdent (), cm_defindex (), |
---|
66 | cm_defcodeindex (), cm_result (), cm_expansion (), cm_equiv (), |
---|
67 | cm_print (), cm_error (), cm_point (), cm_today (), cm_flushleft (), |
---|
68 | cm_flushright (), cm_finalout (), cm_cartouche (), cm_detailmenu (), |
---|
69 | cm_multitable (), cm_settitle (), cm_titlefont (), cm_titlepage (), cm_tie (), cm_tt (), |
---|
70 | cm_verbatim (), cm_verbatiminclude (); |
---|
71 | |
---|
72 | /* Conditionals. */ |
---|
73 | void cm_set (), cm_clear (), cm_ifset (), cm_ifclear (); |
---|
74 | void cm_value (), cm_ifeq (); |
---|
75 | |
---|
76 | /* Options. */ |
---|
77 | static void cm_paragraphindent (), cm_exampleindent (); |
---|
78 | |
---|
79 | /* Internals. */ |
---|
80 | static void cm_obsolete (); |
---|
81 | |
---|
82 | /* A random string. */ |
---|
83 | static const char small_tag[] = "small"; |
---|
84 | |
---|
85 | /* The dispatch table. */ |
---|
86 | COMMAND command_table[] = { |
---|
87 | { "\t", insert_space, NO_BRACE_ARGS }, |
---|
88 | { "\n", insert_space, NO_BRACE_ARGS }, |
---|
89 | { " ", insert_space, NO_BRACE_ARGS }, |
---|
90 | { "!", insert_self, NO_BRACE_ARGS }, |
---|
91 | { "\"", cm_accent_umlaut, MAYBE_BRACE_ARGS }, |
---|
92 | { "'", cm_accent_acute, MAYBE_BRACE_ARGS }, |
---|
93 | { "*", cm_asterisk, NO_BRACE_ARGS }, |
---|
94 | { ",", cm_accent_cedilla, MAYBE_BRACE_ARGS }, |
---|
95 | { "-", cm_no_op, NO_BRACE_ARGS }, |
---|
96 | { ".", insert_self, NO_BRACE_ARGS }, |
---|
97 | { ":", cm_no_op, NO_BRACE_ARGS }, |
---|
98 | { "=", cm_accent, MAYBE_BRACE_ARGS }, |
---|
99 | { "?", insert_self, NO_BRACE_ARGS }, |
---|
100 | { "@", insert_self, NO_BRACE_ARGS }, |
---|
101 | { "\\", insert_self, NO_BRACE_ARGS }, |
---|
102 | { "^", cm_accent_hat, MAYBE_BRACE_ARGS }, |
---|
103 | { "`", cm_accent_grave, MAYBE_BRACE_ARGS }, |
---|
104 | { "{", insert_self, NO_BRACE_ARGS }, |
---|
105 | { "|", cm_no_op, NO_BRACE_ARGS }, |
---|
106 | { "}", insert_self, NO_BRACE_ARGS }, |
---|
107 | { "~", cm_accent_tilde, MAYBE_BRACE_ARGS }, |
---|
108 | { "AA", cm_special_char, BRACE_ARGS }, |
---|
109 | { "AE", cm_special_char, BRACE_ARGS }, |
---|
110 | { "H", cm_accent, MAYBE_BRACE_ARGS }, |
---|
111 | { "L", cm_special_char, BRACE_ARGS }, |
---|
112 | { "O", cm_special_char, BRACE_ARGS }, |
---|
113 | { "OE", cm_special_char, BRACE_ARGS }, |
---|
114 | { "TeX", cm_TeX, BRACE_ARGS }, |
---|
115 | { "aa", cm_special_char, BRACE_ARGS }, |
---|
116 | { "acronym", cm_acronym, BRACE_ARGS }, |
---|
117 | { "ae", cm_special_char, BRACE_ARGS }, |
---|
118 | { "afivepaper", cm_ignore_line, NO_BRACE_ARGS }, |
---|
119 | { "afourlatex", cm_ignore_line, NO_BRACE_ARGS }, |
---|
120 | { "afourpaper", cm_ignore_line, NO_BRACE_ARGS }, |
---|
121 | { "afourwide", cm_ignore_line, NO_BRACE_ARGS }, |
---|
122 | { "alias", cm_alias, NO_BRACE_ARGS }, |
---|
123 | { "anchor", cm_anchor, BRACE_ARGS }, |
---|
124 | { "appendix", cm_appendix, NO_BRACE_ARGS }, |
---|
125 | { "appendixsection", cm_appendixsec, NO_BRACE_ARGS }, |
---|
126 | { "appendixsec", cm_appendixsec, NO_BRACE_ARGS }, |
---|
127 | { "appendixsubsec", cm_appendixsubsec, NO_BRACE_ARGS }, |
---|
128 | { "appendixsubsubsec", cm_appendixsubsubsec, NO_BRACE_ARGS }, |
---|
129 | { "asis", cm_no_op, BRACE_ARGS }, |
---|
130 | { "b", cm_b, BRACE_ARGS }, |
---|
131 | { "bullet", cm_bullet, BRACE_ARGS }, |
---|
132 | { "bye", cm_bye, NO_BRACE_ARGS }, |
---|
133 | { "c", cm_ignore_line, NO_BRACE_ARGS }, |
---|
134 | { "cartouche", cm_cartouche, NO_BRACE_ARGS }, |
---|
135 | { "center", cm_center, NO_BRACE_ARGS }, |
---|
136 | { "centerchap", cm_unnumbered, NO_BRACE_ARGS }, |
---|
137 | { "chapheading", cm_chapheading, NO_BRACE_ARGS }, |
---|
138 | { "chapter", cm_chapter, NO_BRACE_ARGS }, |
---|
139 | { "cindex", cm_cindex, NO_BRACE_ARGS }, |
---|
140 | { "cite", cm_cite, BRACE_ARGS }, |
---|
141 | { "clear", cm_clear, NO_BRACE_ARGS }, |
---|
142 | { "code", cm_code, BRACE_ARGS }, |
---|
143 | { "command", cm_code, BRACE_ARGS }, |
---|
144 | { "comment", cm_ignore_line, NO_BRACE_ARGS }, |
---|
145 | { "contents", cm_contents, NO_BRACE_ARGS }, |
---|
146 | { "copying", cm_copying, NO_BRACE_ARGS }, |
---|
147 | { "copyright", cm_copyright, BRACE_ARGS }, |
---|
148 | { "ctrl", cm_obsolete, BRACE_ARGS }, |
---|
149 | { "defcodeindex", cm_defcodeindex, NO_BRACE_ARGS }, |
---|
150 | { "defcv", cm_defun, NO_BRACE_ARGS }, |
---|
151 | { "defcvx", cm_defun, NO_BRACE_ARGS }, |
---|
152 | { "deffn", cm_defun, NO_BRACE_ARGS }, |
---|
153 | { "deffnx", cm_defun, NO_BRACE_ARGS }, |
---|
154 | { "defindex", cm_defindex, NO_BRACE_ARGS }, |
---|
155 | { "definfoenclose", cm_definfoenclose, NO_BRACE_ARGS }, |
---|
156 | { "defivar", cm_defun, NO_BRACE_ARGS }, |
---|
157 | { "defivarx", cm_defun, NO_BRACE_ARGS }, |
---|
158 | { "defmac", cm_defun, NO_BRACE_ARGS }, |
---|
159 | { "defmacx", cm_defun, NO_BRACE_ARGS }, |
---|
160 | { "defmethod", cm_defun, NO_BRACE_ARGS }, |
---|
161 | { "defmethodx", cm_defun, NO_BRACE_ARGS }, |
---|
162 | { "defop", cm_defun, NO_BRACE_ARGS }, |
---|
163 | { "defopt", cm_defun, NO_BRACE_ARGS }, |
---|
164 | { "defoptx", cm_defun, NO_BRACE_ARGS }, |
---|
165 | { "defopx", cm_defun, NO_BRACE_ARGS }, |
---|
166 | { "defspec", cm_defun, NO_BRACE_ARGS }, |
---|
167 | { "defspecx", cm_defun, NO_BRACE_ARGS }, |
---|
168 | { "deftp", cm_defun, NO_BRACE_ARGS }, |
---|
169 | { "deftpx", cm_defun, NO_BRACE_ARGS }, |
---|
170 | { "deftypefn", cm_defun, NO_BRACE_ARGS }, |
---|
171 | { "deftypefnx", cm_defun, NO_BRACE_ARGS }, |
---|
172 | { "deftypefun", cm_defun, NO_BRACE_ARGS }, |
---|
173 | { "deftypefunx", cm_defun, NO_BRACE_ARGS }, |
---|
174 | { "deftypeivar", cm_defun, NO_BRACE_ARGS }, |
---|
175 | { "deftypeivarx", cm_defun, NO_BRACE_ARGS }, |
---|
176 | { "deftypemethod", cm_defun, NO_BRACE_ARGS }, |
---|
177 | { "deftypemethodx", cm_defun, NO_BRACE_ARGS }, |
---|
178 | { "deftypeop", cm_defun, NO_BRACE_ARGS }, |
---|
179 | { "deftypeopx", cm_defun, NO_BRACE_ARGS }, |
---|
180 | { "deftypevar", cm_defun, NO_BRACE_ARGS }, |
---|
181 | { "deftypevarx", cm_defun, NO_BRACE_ARGS }, |
---|
182 | { "deftypevr", cm_defun, NO_BRACE_ARGS }, |
---|
183 | { "deftypevrx", cm_defun, NO_BRACE_ARGS }, |
---|
184 | { "defun", cm_defun, NO_BRACE_ARGS }, |
---|
185 | { "defunx", cm_defun, NO_BRACE_ARGS }, |
---|
186 | { "defvar", cm_defun, NO_BRACE_ARGS }, |
---|
187 | { "defvarx", cm_defun, NO_BRACE_ARGS }, |
---|
188 | { "defvr", cm_defun, NO_BRACE_ARGS }, |
---|
189 | { "defvrx", cm_defun, NO_BRACE_ARGS }, |
---|
190 | { "detailmenu", cm_detailmenu, NO_BRACE_ARGS }, |
---|
191 | { "dfn", cm_dfn, BRACE_ARGS }, |
---|
192 | { "dircategory", cm_dircategory, NO_BRACE_ARGS }, |
---|
193 | { "direntry", cm_direntry, NO_BRACE_ARGS }, |
---|
194 | { "display", cm_display, NO_BRACE_ARGS }, |
---|
195 | { "dmn", cm_no_op, BRACE_ARGS }, |
---|
196 | { "documentdescription", cm_documentdescription, NO_BRACE_ARGS }, |
---|
197 | { "documentencoding", cm_documentencoding, NO_BRACE_ARGS }, |
---|
198 | { "documentlanguage", cm_documentlanguage, NO_BRACE_ARGS }, |
---|
199 | { "dotaccent", cm_accent, MAYBE_BRACE_ARGS }, |
---|
200 | { "dotless", cm_dotless, BRACE_ARGS }, |
---|
201 | { "dots", cm_dots, BRACE_ARGS }, |
---|
202 | { "email", cm_email, BRACE_ARGS }, |
---|
203 | { "emph", cm_emph, BRACE_ARGS }, |
---|
204 | { "end", cm_end, NO_BRACE_ARGS }, |
---|
205 | { "enddots", cm_enddots, BRACE_ARGS }, |
---|
206 | { "enumerate", cm_enumerate, NO_BRACE_ARGS }, |
---|
207 | { "env", cm_code, BRACE_ARGS }, |
---|
208 | { "equiv", cm_equiv, BRACE_ARGS }, |
---|
209 | { "error", cm_error, BRACE_ARGS }, |
---|
210 | { "evenfooting", cm_ignore_line, NO_BRACE_ARGS }, |
---|
211 | { "evenheading", cm_ignore_line, NO_BRACE_ARGS }, |
---|
212 | { "everyfooting", cm_ignore_line, NO_BRACE_ARGS }, |
---|
213 | { "everyheading", cm_ignore_line, NO_BRACE_ARGS }, |
---|
214 | { "example", cm_example, NO_BRACE_ARGS }, |
---|
215 | { "exampleindent", cm_exampleindent, NO_BRACE_ARGS }, |
---|
216 | { "exclamdown", cm_special_char, BRACE_ARGS }, |
---|
217 | { "exdent", cm_exdent, NO_BRACE_ARGS }, |
---|
218 | { "expansion", cm_expansion, BRACE_ARGS }, |
---|
219 | { "file", cm_code, BRACE_ARGS }, |
---|
220 | { "finalout", cm_no_op, NO_BRACE_ARGS }, |
---|
221 | { "findex", cm_findex, NO_BRACE_ARGS }, |
---|
222 | { "flushleft", cm_flushleft, NO_BRACE_ARGS }, |
---|
223 | { "flushright", cm_flushright, NO_BRACE_ARGS }, |
---|
224 | { "footnote", cm_footnote, NO_BRACE_ARGS}, /* self-arg eater */ |
---|
225 | { "footnotestyle", cm_footnotestyle, NO_BRACE_ARGS }, |
---|
226 | { "format", cm_format, NO_BRACE_ARGS }, |
---|
227 | { "ftable", cm_ftable, NO_BRACE_ARGS }, |
---|
228 | { "group", cm_group, NO_BRACE_ARGS }, |
---|
229 | { "heading", cm_heading, NO_BRACE_ARGS }, |
---|
230 | { "headings", cm_ignore_line, NO_BRACE_ARGS }, |
---|
231 | { "html", cm_html, NO_BRACE_ARGS }, |
---|
232 | { "hyphenation", cm_ignore_arg, BRACE_ARGS }, |
---|
233 | { "i", cm_i, BRACE_ARGS }, |
---|
234 | { "ifclear", cm_ifclear, NO_BRACE_ARGS }, |
---|
235 | { "ifeq", cm_ifeq, NO_BRACE_ARGS }, |
---|
236 | { "ifhtml", cm_ifhtml, NO_BRACE_ARGS }, |
---|
237 | { "ifinfo", cm_ifinfo, NO_BRACE_ARGS }, |
---|
238 | { "ifnothtml", cm_ifnothtml, NO_BRACE_ARGS }, |
---|
239 | { "ifnotinfo", cm_ifnotinfo, NO_BRACE_ARGS }, |
---|
240 | { "ifnotplaintext", cm_ifnotplaintext, NO_BRACE_ARGS }, |
---|
241 | { "ifnottex", cm_ifnottex, NO_BRACE_ARGS }, |
---|
242 | { "ifnotxml", cm_ifnotxml, NO_BRACE_ARGS }, |
---|
243 | { "ifplaintext", cm_ifplaintext, NO_BRACE_ARGS }, |
---|
244 | { "ifset", cm_ifset, NO_BRACE_ARGS }, |
---|
245 | { "iftex", cm_iftex, NO_BRACE_ARGS }, |
---|
246 | { "ifxml", cm_ifxml, NO_BRACE_ARGS }, |
---|
247 | { "ignore", command_name_condition, NO_BRACE_ARGS }, |
---|
248 | { "image", cm_image, BRACE_ARGS }, |
---|
249 | { "include", cm_include, NO_BRACE_ARGS }, |
---|
250 | { "inforef", cm_inforef, BRACE_ARGS }, |
---|
251 | { "insertcopying", cm_insert_copying, NO_BRACE_ARGS }, |
---|
252 | { "item", cm_item, NO_BRACE_ARGS }, |
---|
253 | { "itemize", cm_itemize, NO_BRACE_ARGS }, |
---|
254 | { "itemx", cm_itemx, NO_BRACE_ARGS }, |
---|
255 | { "kbd", cm_kbd, BRACE_ARGS }, |
---|
256 | { "kbdinputstyle", cm_ignore_line, NO_BRACE_ARGS }, |
---|
257 | { "key", cm_key, BRACE_ARGS }, |
---|
258 | { "kindex", cm_kindex, NO_BRACE_ARGS }, |
---|
259 | { "l", cm_special_char, BRACE_ARGS }, |
---|
260 | { "lisp", cm_lisp, NO_BRACE_ARGS }, |
---|
261 | { "lowersections", cm_lowersections, NO_BRACE_ARGS }, |
---|
262 | { "macro", cm_macro, NO_BRACE_ARGS }, |
---|
263 | { "majorheading", cm_majorheading, NO_BRACE_ARGS }, |
---|
264 | { "math", cm_no_op, BRACE_ARGS }, |
---|
265 | { "menu", cm_menu, NO_BRACE_ARGS }, |
---|
266 | { "minus", cm_minus, BRACE_ARGS }, |
---|
267 | { "multitable", cm_multitable, NO_BRACE_ARGS }, |
---|
268 | { "need", cm_ignore_line, NO_BRACE_ARGS }, |
---|
269 | { "node", cm_node, NO_BRACE_ARGS }, |
---|
270 | { "noindent", cm_noindent, NO_BRACE_ARGS }, |
---|
271 | { "noindent", cm_novalidate, NO_BRACE_ARGS }, |
---|
272 | { "nwnode", cm_node, NO_BRACE_ARGS }, |
---|
273 | { "o", cm_special_char, BRACE_ARGS }, |
---|
274 | { "oddfooting", cm_ignore_line, NO_BRACE_ARGS }, |
---|
275 | { "oddheading", cm_ignore_line, NO_BRACE_ARGS }, |
---|
276 | { "oe", cm_special_char, BRACE_ARGS }, |
---|
277 | { "option", cm_code, BRACE_ARGS }, |
---|
278 | { "page", cm_no_op, NO_BRACE_ARGS }, |
---|
279 | { "pagesizes", cm_ignore_line, NO_BRACE_ARGS }, |
---|
280 | { "paragraphindent", cm_paragraphindent, NO_BRACE_ARGS }, |
---|
281 | { "pindex", cm_pindex, NO_BRACE_ARGS }, |
---|
282 | { "point", cm_point, BRACE_ARGS }, |
---|
283 | { "pounds", cm_special_char, BRACE_ARGS }, |
---|
284 | { "print", cm_print, BRACE_ARGS }, |
---|
285 | { "printindex", cm_printindex, NO_BRACE_ARGS }, |
---|
286 | { "pxref", cm_pxref, BRACE_ARGS }, |
---|
287 | { "questiondown", cm_special_char, BRACE_ARGS }, |
---|
288 | { "quotation", cm_quotation, NO_BRACE_ARGS }, |
---|
289 | { "r", cm_r, BRACE_ARGS }, |
---|
290 | { "raisesections", cm_raisesections, NO_BRACE_ARGS }, |
---|
291 | { "ref", cm_ref, BRACE_ARGS }, |
---|
292 | { "refill", cm_no_op, NO_BRACE_ARGS }, |
---|
293 | { "result", cm_result, BRACE_ARGS }, |
---|
294 | { "ringaccent", cm_accent, MAYBE_BRACE_ARGS }, |
---|
295 | { "rmacro", cm_rmacro, NO_BRACE_ARGS }, |
---|
296 | { "samp", cm_code, BRACE_ARGS }, |
---|
297 | { "sc", cm_sc, BRACE_ARGS }, |
---|
298 | { "section", cm_section, NO_BRACE_ARGS }, |
---|
299 | { "set", cm_set, NO_BRACE_ARGS }, |
---|
300 | { "setchapternewpage", cm_ignore_line, NO_BRACE_ARGS }, |
---|
301 | { "setchapterstyle", cm_obsolete, NO_BRACE_ARGS }, |
---|
302 | { "setcontentsaftertitlepage", cm_no_op, NO_BRACE_ARGS }, |
---|
303 | { "setfilename", cm_setfilename, NO_BRACE_ARGS }, |
---|
304 | { "setshortcontentsaftertitlepage", cm_no_op, NO_BRACE_ARGS }, |
---|
305 | { "settitle", cm_settitle, NO_BRACE_ARGS }, |
---|
306 | { "shortcontents", cm_shortcontents, NO_BRACE_ARGS }, |
---|
307 | { "shorttitlepage", cm_ignore_line, NO_BRACE_ARGS }, |
---|
308 | { "smallbook", cm_ignore_line, NO_BRACE_ARGS }, |
---|
309 | { "smalldisplay", cm_smalldisplay, NO_BRACE_ARGS }, |
---|
310 | { "smallexample", cm_smallexample, NO_BRACE_ARGS }, |
---|
311 | { "smallformat", cm_smallformat, NO_BRACE_ARGS }, |
---|
312 | { "smalllisp", cm_smalllisp, NO_BRACE_ARGS }, |
---|
313 | { "sp", cm_sp, NO_BRACE_ARGS }, |
---|
314 | { "ss", cm_special_char, BRACE_ARGS }, |
---|
315 | { "strong", cm_strong, BRACE_ARGS }, |
---|
316 | { "subheading", cm_subheading, NO_BRACE_ARGS }, |
---|
317 | { "subsection", cm_subsection, NO_BRACE_ARGS }, |
---|
318 | { "subsubheading", cm_subsubheading, NO_BRACE_ARGS }, |
---|
319 | { "subsubsection", cm_subsubsection, NO_BRACE_ARGS }, |
---|
320 | { "summarycontents", cm_shortcontents, NO_BRACE_ARGS }, |
---|
321 | { "syncodeindex", cm_synindex, NO_BRACE_ARGS }, |
---|
322 | { "synindex", cm_synindex, NO_BRACE_ARGS }, |
---|
323 | { "t", cm_tt, BRACE_ARGS }, |
---|
324 | { "tab", cm_tab, NO_BRACE_ARGS }, |
---|
325 | { "table", cm_table, NO_BRACE_ARGS }, |
---|
326 | { "tex", cm_tex, NO_BRACE_ARGS }, |
---|
327 | { "tie", cm_tie, BRACE_ARGS }, |
---|
328 | { "tieaccent", cm_accent, MAYBE_BRACE_ARGS }, |
---|
329 | { "tindex", cm_tindex, NO_BRACE_ARGS }, |
---|
330 | { "titlefont", cm_titlefont, BRACE_ARGS }, |
---|
331 | { "titlepage", cm_titlepage, NO_BRACE_ARGS }, |
---|
332 | { "today", cm_today, BRACE_ARGS }, |
---|
333 | { "top", cm_top, NO_BRACE_ARGS }, |
---|
334 | { "u", cm_accent, MAYBE_BRACE_ARGS }, |
---|
335 | { "ubaraccent", cm_accent, MAYBE_BRACE_ARGS }, |
---|
336 | { "udotaccent", cm_accent, MAYBE_BRACE_ARGS }, |
---|
337 | { "unmacro", cm_unmacro, NO_BRACE_ARGS }, |
---|
338 | { "unnumbered", cm_unnumbered, NO_BRACE_ARGS }, |
---|
339 | { "unnumberedsec", cm_unnumberedsec, NO_BRACE_ARGS }, |
---|
340 | { "unnumberedsubsec", cm_unnumberedsubsec, NO_BRACE_ARGS }, |
---|
341 | { "unnumberedsubsubsec", cm_unnumberedsubsubsec, NO_BRACE_ARGS }, |
---|
342 | { "uref", cm_uref, BRACE_ARGS }, |
---|
343 | { "url", cm_url, BRACE_ARGS }, |
---|
344 | { "v", cm_accent, MAYBE_BRACE_ARGS }, |
---|
345 | { "value", cm_value, BRACE_ARGS }, |
---|
346 | { "var", cm_var, BRACE_ARGS }, |
---|
347 | { "verb", cm_verb, NO_BRACE_ARGS }, |
---|
348 | { "verbatim", cm_verbatim, NO_BRACE_ARGS }, |
---|
349 | { "verbatiminclude", cm_verbatiminclude, NO_BRACE_ARGS }, |
---|
350 | { "vindex", cm_vindex, NO_BRACE_ARGS }, |
---|
351 | { "vtable", cm_vtable, NO_BRACE_ARGS }, |
---|
352 | { "w", cm_w, BRACE_ARGS }, |
---|
353 | { "xml", cm_html, NO_BRACE_ARGS }, |
---|
354 | { "xref", cm_xref, BRACE_ARGS }, |
---|
355 | |
---|
356 | /* Deprecated commands. These used to be for italics. */ |
---|
357 | { "iappendix", cm_ideprecated, NO_BRACE_ARGS }, |
---|
358 | { "iappendixsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
359 | { "iappendixsection", cm_ideprecated, NO_BRACE_ARGS }, |
---|
360 | { "iappendixsubsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
361 | { "iappendixsubsubsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
362 | { "ichapter", cm_ideprecated, NO_BRACE_ARGS }, |
---|
363 | { "isection", cm_ideprecated, NO_BRACE_ARGS }, |
---|
364 | { "isubsection", cm_ideprecated, NO_BRACE_ARGS }, |
---|
365 | { "isubsubsection", cm_ideprecated, NO_BRACE_ARGS }, |
---|
366 | { "iunnumbered", cm_ideprecated, NO_BRACE_ARGS }, |
---|
367 | { "iunnumberedsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
368 | { "iunnumberedsubsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
369 | { "iunnumberedsubsubsec", cm_ideprecated, NO_BRACE_ARGS }, |
---|
370 | |
---|
371 | /* Now @include does what this was used to. */ |
---|
372 | { "infoinclude", cm_obsolete, NO_BRACE_ARGS }, |
---|
373 | { "titlespec", cm_obsolete, NO_BRACE_ARGS }, |
---|
374 | |
---|
375 | { NULL, NULL, NO_BRACE_ARGS } |
---|
376 | }; |
---|
377 | |
---|
378 | /* The bulk of the Texinfo commands. */ |
---|
379 | |
---|
380 | /* Commands which insert their own names. */ |
---|
381 | void |
---|
382 | insert_self (arg) |
---|
383 | int arg; |
---|
384 | { |
---|
385 | if (arg == START) |
---|
386 | add_word (command); |
---|
387 | } |
---|
388 | |
---|
389 | void |
---|
390 | insert_space (arg) |
---|
391 | int arg; |
---|
392 | { |
---|
393 | if (arg == START) |
---|
394 | { |
---|
395 | if (xml && !docbook) |
---|
396 | xml_insert_entity ("space"); |
---|
397 | else |
---|
398 | add_char (' '); |
---|
399 | } |
---|
400 | } |
---|
401 | |
---|
402 | /* Force a line break in the output. */ |
---|
403 | void |
---|
404 | cm_asterisk () |
---|
405 | { |
---|
406 | if (html) |
---|
407 | add_word ("<br>"); |
---|
408 | else if (xml && !docbook) |
---|
409 | xml_insert_entity ("linebreak"); |
---|
410 | else if (docbook) |
---|
411 | xml_asterisk (); |
---|
412 | else |
---|
413 | { |
---|
414 | close_single_paragraph (); |
---|
415 | cm_noindent (); |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | /* Insert ellipsis. */ |
---|
420 | void |
---|
421 | cm_dots (arg) |
---|
422 | int arg; |
---|
423 | { |
---|
424 | if (arg == START) |
---|
425 | { |
---|
426 | if (xml && !docbook) |
---|
427 | xml_insert_entity ("dots"); |
---|
428 | else if (docbook) |
---|
429 | xml_insert_entity ("hellip"); |
---|
430 | else |
---|
431 | add_word (html && !in_fixed_width_font |
---|
432 | ? "<small class=\"dots\">...</small>" : "..."); |
---|
433 | } |
---|
434 | } |
---|
435 | |
---|
436 | /* Insert ellipsis for sentence end. */ |
---|
437 | void |
---|
438 | cm_enddots (arg) |
---|
439 | int arg; |
---|
440 | { |
---|
441 | if (arg == START) |
---|
442 | { |
---|
443 | if (xml && !docbook) |
---|
444 | xml_insert_entity ("enddots"); |
---|
445 | else if (docbook) |
---|
446 | { |
---|
447 | xml_insert_entity ("hellip"); |
---|
448 | add_char ('.'); |
---|
449 | } |
---|
450 | else |
---|
451 | add_word (html && !in_fixed_width_font |
---|
452 | ? "<small class=\"enddots\">....</small>" : "...."); |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | void |
---|
457 | cm_bullet (arg) |
---|
458 | int arg; |
---|
459 | { |
---|
460 | if (arg == START) |
---|
461 | { |
---|
462 | if (html) |
---|
463 | add_word ("•"); |
---|
464 | else if (xml && !docbook) |
---|
465 | xml_insert_entity ("bullet"); |
---|
466 | else if (docbook) |
---|
467 | xml_insert_entity ("bull"); |
---|
468 | else |
---|
469 | add_char ('*'); |
---|
470 | } |
---|
471 | } |
---|
472 | |
---|
473 | void |
---|
474 | cm_minus (arg) |
---|
475 | int arg; |
---|
476 | { |
---|
477 | if (arg == START) |
---|
478 | { |
---|
479 | if (xml) |
---|
480 | xml_insert_entity ("minus"); |
---|
481 | else |
---|
482 | add_char ('-'); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | /* Insert "TeX". */ |
---|
487 | void |
---|
488 | cm_TeX (arg) |
---|
489 | int arg; |
---|
490 | { |
---|
491 | if (arg == START) |
---|
492 | { |
---|
493 | if (xml && ! docbook) |
---|
494 | xml_insert_entity ("tex"); |
---|
495 | else |
---|
496 | add_word ("TeX"); |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | /* Copyright symbol. */ |
---|
501 | void |
---|
502 | cm_copyright (arg) |
---|
503 | int arg; |
---|
504 | { |
---|
505 | if (arg == START) |
---|
506 | { |
---|
507 | if (html) |
---|
508 | add_word ("©"); |
---|
509 | else if (xml && !docbook) |
---|
510 | xml_insert_entity ("copyright"); |
---|
511 | else if (docbook) |
---|
512 | xml_insert_entity ("copy"); |
---|
513 | else |
---|
514 | add_word ("(C)"); |
---|
515 | } |
---|
516 | } |
---|
517 | |
---|
518 | void |
---|
519 | cm_today (arg) |
---|
520 | int arg; |
---|
521 | { |
---|
522 | static char *months[12] = |
---|
523 | { N_("January"), N_("February"), N_("March"), N_("April"), N_("May"), |
---|
524 | N_("June"), N_("July"), N_("August"), N_("September"), N_("October"), |
---|
525 | N_("November"), N_("December") }; |
---|
526 | if (arg == START) |
---|
527 | { |
---|
528 | time_t timer = time (0); |
---|
529 | struct tm *ts = localtime (&timer); |
---|
530 | add_word_args ("%d %s %d", ts->tm_mday, _(months[ts->tm_mon]), |
---|
531 | ts->tm_year + 1900); |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | void |
---|
536 | cm_acronym (arg) |
---|
537 | int arg; |
---|
538 | { |
---|
539 | if (html) |
---|
540 | insert_html_tag (arg, small_tag); |
---|
541 | else if (xml) |
---|
542 | xml_insert_element (ACRONYM, arg); |
---|
543 | } |
---|
544 | |
---|
545 | void |
---|
546 | cm_tt (arg) |
---|
547 | int arg; |
---|
548 | { |
---|
549 | /* @t{} is a no-op in Info. */ |
---|
550 | if (html) |
---|
551 | insert_html_tag (arg, "tt"); |
---|
552 | else if (xml) |
---|
553 | xml_insert_element (TT, arg); |
---|
554 | } |
---|
555 | |
---|
556 | void |
---|
557 | cm_code (arg) |
---|
558 | int arg; |
---|
559 | { |
---|
560 | if (xml) |
---|
561 | xml_insert_element (CODE, arg); |
---|
562 | else |
---|
563 | { |
---|
564 | extern int printing_index; |
---|
565 | |
---|
566 | if (arg == START) |
---|
567 | { |
---|
568 | in_fixed_width_font++; |
---|
569 | |
---|
570 | if (html) |
---|
571 | insert_html_tag (arg, "code"); |
---|
572 | else if (!printing_index) |
---|
573 | add_char ('`'); |
---|
574 | } |
---|
575 | else if (html) |
---|
576 | insert_html_tag (arg, "code"); |
---|
577 | else |
---|
578 | { |
---|
579 | if (!printing_index) |
---|
580 | add_meta_char ('\''); |
---|
581 | } |
---|
582 | } |
---|
583 | } |
---|
584 | |
---|
585 | void |
---|
586 | cm_kbd (arg) |
---|
587 | int arg; |
---|
588 | { |
---|
589 | if (xml) |
---|
590 | xml_insert_element (KBD, arg); |
---|
591 | else if (html) |
---|
592 | { /* Seems like we should increment in_fixed_width_font for Info |
---|
593 | format too, but then the quote-omitting special case gets |
---|
594 | confused. Punt. */ |
---|
595 | if (arg == START) |
---|
596 | in_fixed_width_font++; |
---|
597 | insert_html_tag (arg, "kbd"); |
---|
598 | } |
---|
599 | else |
---|
600 | { /* People use @kbd in an example to get the "user input" font. |
---|
601 | We don't want quotes in that case. */ |
---|
602 | if (!in_fixed_width_font) |
---|
603 | cm_code (arg); |
---|
604 | } |
---|
605 | } |
---|
606 | |
---|
607 | void |
---|
608 | cm_url (arg, start, end) |
---|
609 | { |
---|
610 | if (xml) |
---|
611 | xml_insert_element (URL, arg); |
---|
612 | else if (html) |
---|
613 | { |
---|
614 | if (arg == START) |
---|
615 | add_word ("<"); |
---|
616 | insert_html_tag (arg, "code"); |
---|
617 | if (arg != START) |
---|
618 | add_word (">"); |
---|
619 | } |
---|
620 | else |
---|
621 | if (arg == START) |
---|
622 | add_word ("<"); |
---|
623 | else |
---|
624 | add_word (">"); |
---|
625 | } |
---|
626 | |
---|
627 | void |
---|
628 | cm_key (arg) |
---|
629 | int arg; |
---|
630 | { |
---|
631 | if (xml) |
---|
632 | xml_insert_element (KEY, arg); |
---|
633 | else if (html) |
---|
634 | add_word (arg == START ? "<" : ">"); |
---|
635 | else |
---|
636 | add_char (arg == START ? '<' : '>'); |
---|
637 | } |
---|
638 | |
---|
639 | /* Handle a command that switches to a non-fixed-width font. */ |
---|
640 | void |
---|
641 | not_fixed_width (arg) |
---|
642 | int arg; |
---|
643 | { |
---|
644 | if (arg == START) |
---|
645 | in_fixed_width_font = 0; |
---|
646 | } |
---|
647 | |
---|
648 | /* @var in makeinfo just uppercases the text. */ |
---|
649 | void |
---|
650 | cm_var (arg, start_pos, end_pos) |
---|
651 | int arg, start_pos, end_pos; |
---|
652 | { |
---|
653 | if (xml) |
---|
654 | xml_insert_element (VAR, arg); |
---|
655 | else |
---|
656 | { |
---|
657 | not_fixed_width (arg); |
---|
658 | |
---|
659 | if (html) |
---|
660 | insert_html_tag (arg, "var"); |
---|
661 | else if (arg == END) |
---|
662 | { |
---|
663 | while (start_pos < end_pos) |
---|
664 | { |
---|
665 | unsigned char c = output_paragraph[start_pos]; |
---|
666 | if (strchr ("[](),", c)) |
---|
667 | warning (_("unlikely character %c in @var"), c); |
---|
668 | output_paragraph[start_pos] = coerce_to_upper (c); |
---|
669 | start_pos++; |
---|
670 | } |
---|
671 | } |
---|
672 | } |
---|
673 | } |
---|
674 | |
---|
675 | void |
---|
676 | cm_sc (arg, start_pos, end_pos) |
---|
677 | int arg, start_pos, end_pos; |
---|
678 | { |
---|
679 | if (xml) |
---|
680 | xml_insert_element (SC, arg); |
---|
681 | else |
---|
682 | { |
---|
683 | not_fixed_width (arg); |
---|
684 | |
---|
685 | if (arg == START) |
---|
686 | { |
---|
687 | if (html) |
---|
688 | insert_html_tag (arg, small_tag); |
---|
689 | } |
---|
690 | else |
---|
691 | { |
---|
692 | int all_upper; |
---|
693 | |
---|
694 | if (html) |
---|
695 | start_pos += sizeof (small_tag) + 2 - 1; /* skip <small> */ |
---|
696 | |
---|
697 | /* Avoid the warning below if there's no text inside @sc{}, or |
---|
698 | when processing menus under --no-headers. */ |
---|
699 | all_upper = start_pos < end_pos; |
---|
700 | |
---|
701 | while (start_pos < end_pos) |
---|
702 | { |
---|
703 | unsigned char c = output_paragraph[start_pos]; |
---|
704 | if (!isupper (c)) |
---|
705 | all_upper = 0; |
---|
706 | output_paragraph[start_pos] = coerce_to_upper (c); |
---|
707 | start_pos++; |
---|
708 | } |
---|
709 | if (all_upper) |
---|
710 | warning (_("@sc argument all uppercase, thus no effect")); |
---|
711 | |
---|
712 | if (html) |
---|
713 | insert_html_tag (arg, small_tag); |
---|
714 | } |
---|
715 | } |
---|
716 | } |
---|
717 | |
---|
718 | void |
---|
719 | cm_dfn (arg, position) |
---|
720 | int arg, position; |
---|
721 | { |
---|
722 | if (xml) |
---|
723 | xml_insert_element (DFN, arg); |
---|
724 | else |
---|
725 | { |
---|
726 | if (html) |
---|
727 | insert_html_tag (arg, "dfn"); |
---|
728 | else if (arg == START) |
---|
729 | add_char ('"'); |
---|
730 | else |
---|
731 | add_meta_char ('"'); |
---|
732 | } |
---|
733 | } |
---|
734 | |
---|
735 | void |
---|
736 | cm_emph (arg) |
---|
737 | int arg; |
---|
738 | { |
---|
739 | if (xml) |
---|
740 | xml_insert_element (EMPH, arg); |
---|
741 | else if (html) |
---|
742 | insert_html_tag (arg, "em"); |
---|
743 | else |
---|
744 | add_char ('_'); |
---|
745 | } |
---|
746 | |
---|
747 | void |
---|
748 | cm_verb (arg) |
---|
749 | int arg; |
---|
750 | { |
---|
751 | int character; |
---|
752 | int delimiter; |
---|
753 | int seen_end = 0; |
---|
754 | |
---|
755 | in_fixed_width_font++; |
---|
756 | /* are these necessary ? */ |
---|
757 | last_char_was_newline = 0; |
---|
758 | |
---|
759 | if (html) |
---|
760 | add_word ("<tt>"); |
---|
761 | |
---|
762 | if (input_text_offset < input_text_length) |
---|
763 | { |
---|
764 | character = curchar (); |
---|
765 | if (character == '{') |
---|
766 | input_text_offset++; |
---|
767 | else |
---|
768 | line_error (_("`{' expected, but saw `%c'"), character); |
---|
769 | } |
---|
770 | |
---|
771 | if (input_text_offset < input_text_length) |
---|
772 | { |
---|
773 | delimiter = curchar (); |
---|
774 | input_text_offset++; |
---|
775 | } |
---|
776 | |
---|
777 | while (input_text_offset < input_text_length) |
---|
778 | { |
---|
779 | character = curchar (); |
---|
780 | |
---|
781 | if (character == '\n') |
---|
782 | { |
---|
783 | line_number++; |
---|
784 | if (html) |
---|
785 | add_word ("<br>\n"); |
---|
786 | } |
---|
787 | |
---|
788 | else if (html && character == '<') |
---|
789 | add_word ("<"); |
---|
790 | |
---|
791 | else if (html && character == '&') |
---|
792 | add_word ("&"); |
---|
793 | |
---|
794 | else if (character == delimiter) |
---|
795 | { /* Assume no newlines in END_VERBATIM. */ |
---|
796 | seen_end = 1; |
---|
797 | input_text_offset++; |
---|
798 | break; |
---|
799 | } |
---|
800 | |
---|
801 | else |
---|
802 | add_char (character); |
---|
803 | |
---|
804 | input_text_offset++; |
---|
805 | } |
---|
806 | |
---|
807 | if (!seen_end) |
---|
808 | warning (_("end of file inside verb block")); |
---|
809 | |
---|
810 | if (input_text_offset < input_text_length) |
---|
811 | { |
---|
812 | character = curchar (); |
---|
813 | if (character == '}') |
---|
814 | input_text_offset++; |
---|
815 | else |
---|
816 | line_error (_("`}' expected, but saw `%c'"), character); |
---|
817 | } |
---|
818 | |
---|
819 | if (html) |
---|
820 | add_word ("</tt>"); |
---|
821 | |
---|
822 | in_fixed_width_font--; |
---|
823 | } |
---|
824 | |
---|
825 | |
---|
826 | void |
---|
827 | cm_strong (arg, position) |
---|
828 | int arg, position; |
---|
829 | { |
---|
830 | if (xml) |
---|
831 | xml_insert_element (STRONG, arg); |
---|
832 | else if (html) |
---|
833 | insert_html_tag (arg, "strong"); |
---|
834 | else |
---|
835 | add_char ('*'); |
---|
836 | } |
---|
837 | |
---|
838 | void |
---|
839 | cm_cite (arg, position) |
---|
840 | int arg, position; |
---|
841 | { |
---|
842 | if (xml) |
---|
843 | xml_insert_element (CITE, arg); |
---|
844 | else if (html) |
---|
845 | insert_html_tag (arg, "cite"); |
---|
846 | else |
---|
847 | { |
---|
848 | if (arg == START) |
---|
849 | add_char ('`'); |
---|
850 | else |
---|
851 | add_char ('\''); |
---|
852 | } |
---|
853 | } |
---|
854 | |
---|
855 | /* No highlighting, but argument switches fonts. */ |
---|
856 | void |
---|
857 | cm_not_fixed_width (arg, start, end) |
---|
858 | int arg, start, end; |
---|
859 | { |
---|
860 | if (xml) |
---|
861 | xml_insert_element (NOTFIXEDWIDTH, arg); |
---|
862 | not_fixed_width (arg); |
---|
863 | } |
---|
864 | |
---|
865 | void |
---|
866 | cm_i (arg) |
---|
867 | int arg; |
---|
868 | { |
---|
869 | if (xml) |
---|
870 | xml_insert_element (I, arg); |
---|
871 | else if (html) |
---|
872 | insert_html_tag (arg, "i"); |
---|
873 | else |
---|
874 | not_fixed_width (arg); |
---|
875 | } |
---|
876 | |
---|
877 | void |
---|
878 | cm_b (arg) |
---|
879 | int arg; |
---|
880 | { |
---|
881 | if (xml) |
---|
882 | xml_insert_element (B, arg); |
---|
883 | else if (html) |
---|
884 | insert_html_tag (arg, "b"); |
---|
885 | else |
---|
886 | not_fixed_width (arg); |
---|
887 | } |
---|
888 | |
---|
889 | void |
---|
890 | cm_r (arg) |
---|
891 | int arg; |
---|
892 | { |
---|
893 | if (xml) |
---|
894 | xml_insert_element (R, arg); |
---|
895 | else |
---|
896 | { |
---|
897 | if (html) |
---|
898 | insert_html_tag (arg, ""); |
---|
899 | |
---|
900 | not_fixed_width (arg); |
---|
901 | } |
---|
902 | } |
---|
903 | |
---|
904 | void |
---|
905 | cm_titlefont (arg) |
---|
906 | int arg; |
---|
907 | { |
---|
908 | if (xml) |
---|
909 | xml_insert_element (TITLEFONT, arg); |
---|
910 | else |
---|
911 | { |
---|
912 | not_fixed_width (arg); |
---|
913 | if (html) |
---|
914 | { |
---|
915 | html_title_written = 1; /* suppress title from @settitle */ |
---|
916 | if (arg == START) |
---|
917 | add_word ("<h1 class=\"titlefont\">"); |
---|
918 | else |
---|
919 | add_word ("</h1>\n"); |
---|
920 | } |
---|
921 | } |
---|
922 | } |
---|
923 | |
---|
924 | int titlepage_cmd_present = 0; |
---|
925 | |
---|
926 | void |
---|
927 | cm_titlepage (arg) |
---|
928 | int arg; |
---|
929 | { |
---|
930 | titlepage_cmd_present = 1; |
---|
931 | command_name_condition (); |
---|
932 | } |
---|
933 | |
---|
934 | /* Various commands are no-op's. */ |
---|
935 | void |
---|
936 | cm_no_op () |
---|
937 | { |
---|
938 | } |
---|
939 | |
---|
940 | |
---|
941 | /* For proofing single chapters, etc. */ |
---|
942 | void |
---|
943 | cm_novalidate () |
---|
944 | { |
---|
945 | validating = 0; |
---|
946 | } |
---|
947 | |
---|
948 | |
---|
949 | /* Prevent the argument from being split across two lines. */ |
---|
950 | void |
---|
951 | cm_w (arg, start, end) |
---|
952 | int arg, start, end; |
---|
953 | { |
---|
954 | if (arg == START) |
---|
955 | non_splitting_words++; |
---|
956 | else |
---|
957 | non_splitting_words--; |
---|
958 | } |
---|
959 | |
---|
960 | |
---|
961 | /* An unbreakable word space. Same as @w{ } for makeinfo, but different |
---|
962 | for TeX (the space stretches and stretches, and does not inhibit |
---|
963 | hyphenation). */ |
---|
964 | void |
---|
965 | cm_tie (arg) |
---|
966 | int arg; |
---|
967 | { |
---|
968 | if (arg == START) |
---|
969 | { |
---|
970 | cm_w (START); |
---|
971 | add_char (' '); |
---|
972 | } |
---|
973 | else |
---|
974 | cm_w (END); |
---|
975 | } |
---|
976 | |
---|
977 | /* Explain that this command is obsolete, thus the user shouldn't |
---|
978 | do anything with it. */ |
---|
979 | static void |
---|
980 | cm_obsolete (arg, start, end) |
---|
981 | int arg, start, end; |
---|
982 | { |
---|
983 | if (arg == START) |
---|
984 | warning (_("%c%s is obsolete"), COMMAND_PREFIX, command); |
---|
985 | } |
---|
986 | |
---|
987 | |
---|
988 | /* This says to inhibit the indentation of the next paragraph, but |
---|
989 | not of following paragraphs. */ |
---|
990 | void |
---|
991 | cm_noindent () |
---|
992 | { |
---|
993 | if (!inhibit_paragraph_indentation) |
---|
994 | inhibit_paragraph_indentation = -1; |
---|
995 | } |
---|
996 | |
---|
997 | /* I don't know exactly what to do with this. Should I allow |
---|
998 | someone to switch filenames in the middle of output? Since the |
---|
999 | file could be partially written, this doesn't seem to make sense. |
---|
1000 | Another option: ignore it, since they don't *really* want to |
---|
1001 | switch files. Finally, complain, or at least warn. It doesn't |
---|
1002 | really matter, anyway, since this doesn't get executed. */ |
---|
1003 | void |
---|
1004 | cm_setfilename () |
---|
1005 | { |
---|
1006 | char *filename; |
---|
1007 | get_rest_of_line (1, &filename); |
---|
1008 | /* warning ("`@%s %s' encountered and ignored", command, filename); */ |
---|
1009 | if (xml) |
---|
1010 | add_word_args ("<setfilename>%s</setfilename>", filename); |
---|
1011 | free (filename); |
---|
1012 | } |
---|
1013 | |
---|
1014 | void |
---|
1015 | cm_settitle () |
---|
1016 | { |
---|
1017 | if (xml) |
---|
1018 | { |
---|
1019 | xml_begin_document (current_output_filename); |
---|
1020 | xml_insert_element (SETTITLE, START); |
---|
1021 | xml_in_book_title = 1; |
---|
1022 | get_rest_of_line (0, &title); |
---|
1023 | execute_string ("%s", title); |
---|
1024 | xml_in_book_title = 0; |
---|
1025 | xml_insert_element (SETTITLE, END); |
---|
1026 | if (docbook && !xml_in_bookinfo) |
---|
1027 | { |
---|
1028 | xml_insert_element (BOOKINFO, START); |
---|
1029 | xml_in_bookinfo = 1; |
---|
1030 | } |
---|
1031 | } |
---|
1032 | else |
---|
1033 | get_rest_of_line (0, &title); |
---|
1034 | } |
---|
1035 | |
---|
1036 | |
---|
1037 | /* Ignore argument in braces. */ |
---|
1038 | void |
---|
1039 | cm_ignore_arg (arg, start_pos, end_pos) |
---|
1040 | int arg, start_pos, end_pos; |
---|
1041 | { |
---|
1042 | if (arg == END) |
---|
1043 | output_paragraph_offset = start_pos; |
---|
1044 | } |
---|
1045 | |
---|
1046 | /* Ignore argument on rest of line. */ |
---|
1047 | void |
---|
1048 | cm_ignore_line () |
---|
1049 | { |
---|
1050 | discard_until ("\n"); |
---|
1051 | } |
---|
1052 | |
---|
1053 | /* Insert the number of blank lines passed as argument. */ |
---|
1054 | void |
---|
1055 | cm_sp () |
---|
1056 | { |
---|
1057 | int lines; |
---|
1058 | char *line; |
---|
1059 | |
---|
1060 | get_rest_of_line (1, &line); |
---|
1061 | |
---|
1062 | if (sscanf (line, "%d", &lines) != 1 || lines <= 0) |
---|
1063 | line_error (_("@sp requires a positive numeric argument, not `%s'"), line); |
---|
1064 | else |
---|
1065 | { |
---|
1066 | if (xml) |
---|
1067 | { |
---|
1068 | xml_insert_element_with_attribute (SP, START, "lines=\"%s\"", line); |
---|
1069 | /* insert_string (line);*/ |
---|
1070 | xml_insert_element (SP, END); |
---|
1071 | } |
---|
1072 | else |
---|
1073 | { |
---|
1074 | /* Must disable filling since otherwise multiple newlines is like |
---|
1075 | multiple spaces. Must close paragraph since that's what the |
---|
1076 | manual says and that's what TeX does. */ |
---|
1077 | int save_filling_enabled = filling_enabled; |
---|
1078 | filling_enabled = 0; |
---|
1079 | |
---|
1080 | /* close_paragraph generates an extra blank line. */ |
---|
1081 | close_single_paragraph (); |
---|
1082 | |
---|
1083 | if (lines && html && !executing_string) |
---|
1084 | html_output_head (); |
---|
1085 | |
---|
1086 | while (lines--) |
---|
1087 | { |
---|
1088 | if (html) |
---|
1089 | insert_string ("<br><p>\n"); |
---|
1090 | else |
---|
1091 | add_char ('\n'); |
---|
1092 | } |
---|
1093 | |
---|
1094 | filling_enabled = save_filling_enabled; |
---|
1095 | } |
---|
1096 | } |
---|
1097 | free (line); |
---|
1098 | } |
---|
1099 | |
---|
1100 | /* @dircategory LINE outputs INFO-DIR-SECTION LINE, unless --no-headers. */ |
---|
1101 | void |
---|
1102 | cm_dircategory () |
---|
1103 | { |
---|
1104 | char *line; |
---|
1105 | |
---|
1106 | if (html || docbook) |
---|
1107 | cm_ignore_line (); |
---|
1108 | else if (xml) |
---|
1109 | { |
---|
1110 | xml_insert_element (DIRCATEGORY, START); |
---|
1111 | get_rest_of_line (1, &line); |
---|
1112 | insert_string (line); |
---|
1113 | free (line); |
---|
1114 | xml_insert_element (DIRCATEGORY, END); |
---|
1115 | } |
---|
1116 | else |
---|
1117 | { |
---|
1118 | get_rest_of_line (1, &line); |
---|
1119 | |
---|
1120 | if (!no_headers && !html) |
---|
1121 | { |
---|
1122 | kill_self_indent (-1); /* make sure there's no indentation */ |
---|
1123 | insert_string ("INFO-DIR-SECTION "); |
---|
1124 | insert_string (line); |
---|
1125 | insert ('\n'); |
---|
1126 | } |
---|
1127 | |
---|
1128 | free (line); |
---|
1129 | } |
---|
1130 | } |
---|
1131 | |
---|
1132 | /* Start a new line with just this text on it. |
---|
1133 | Then center the line of text. |
---|
1134 | */ |
---|
1135 | void |
---|
1136 | cm_center () |
---|
1137 | { |
---|
1138 | if (xml) |
---|
1139 | { |
---|
1140 | unsigned char *line; |
---|
1141 | xml_insert_element (CENTER, START); |
---|
1142 | get_rest_of_line (0, (char **)&line); |
---|
1143 | execute_string ("%s", (char *)line); |
---|
1144 | free (line); |
---|
1145 | xml_insert_element (CENTER, END); |
---|
1146 | } |
---|
1147 | else |
---|
1148 | { |
---|
1149 | int i, start, length; |
---|
1150 | unsigned char *line; |
---|
1151 | int save_indented_fill = indented_fill; |
---|
1152 | int save_filling_enabled = filling_enabled; |
---|
1153 | int fudge_factor = 1; |
---|
1154 | |
---|
1155 | filling_enabled = indented_fill = 0; |
---|
1156 | cm_noindent (); |
---|
1157 | start = output_paragraph_offset; |
---|
1158 | |
---|
1159 | if (html) |
---|
1160 | add_word ("<div align=\"center\">"); |
---|
1161 | |
---|
1162 | inhibit_output_flushing (); |
---|
1163 | get_rest_of_line (0, (char **)&line); |
---|
1164 | execute_string ("%s", (char *)line); |
---|
1165 | free (line); |
---|
1166 | uninhibit_output_flushing (); |
---|
1167 | if (html) |
---|
1168 | add_word ("</div>"); |
---|
1169 | |
---|
1170 | else |
---|
1171 | { |
---|
1172 | i = output_paragraph_offset - 1; |
---|
1173 | while (i > (start - 1) && output_paragraph[i] == '\n') |
---|
1174 | i--; |
---|
1175 | |
---|
1176 | output_paragraph_offset = ++i; |
---|
1177 | length = output_paragraph_offset - start; |
---|
1178 | |
---|
1179 | if (length < (fill_column - fudge_factor)) |
---|
1180 | { |
---|
1181 | line = xmalloc (1 + length); |
---|
1182 | memcpy (line, (char *)(output_paragraph + start), length); |
---|
1183 | |
---|
1184 | i = (fill_column - fudge_factor - length) / 2; |
---|
1185 | output_paragraph_offset = start; |
---|
1186 | |
---|
1187 | while (i--) |
---|
1188 | insert (' '); |
---|
1189 | |
---|
1190 | for (i = 0; i < length; i++) |
---|
1191 | insert (line[i]); |
---|
1192 | |
---|
1193 | free (line); |
---|
1194 | } |
---|
1195 | } |
---|
1196 | |
---|
1197 | insert ('\n'); |
---|
1198 | filling_enabled = save_filling_enabled; |
---|
1199 | indented_fill = save_indented_fill; |
---|
1200 | } |
---|
1201 | } |
---|
1202 | |
---|
1203 | /* Show what an expression returns. */ |
---|
1204 | void |
---|
1205 | cm_result (arg) |
---|
1206 | int arg; |
---|
1207 | { |
---|
1208 | if (arg == END) |
---|
1209 | add_word (html ? "=>" : "=>"); |
---|
1210 | } |
---|
1211 | |
---|
1212 | /* What an expression expands to. */ |
---|
1213 | void |
---|
1214 | cm_expansion (arg) |
---|
1215 | int arg; |
---|
1216 | { |
---|
1217 | if (arg == END) |
---|
1218 | add_word (html ? "==>" : "==>"); |
---|
1219 | } |
---|
1220 | |
---|
1221 | /* Indicates two expressions are equivalent. */ |
---|
1222 | void |
---|
1223 | cm_equiv (arg) |
---|
1224 | int arg; |
---|
1225 | { |
---|
1226 | if (arg == END) |
---|
1227 | add_word ("=="); |
---|
1228 | } |
---|
1229 | |
---|
1230 | /* What an expression may print. */ |
---|
1231 | void |
---|
1232 | cm_print (arg) |
---|
1233 | int arg; |
---|
1234 | { |
---|
1235 | if (arg == END) |
---|
1236 | add_word ("-|"); |
---|
1237 | } |
---|
1238 | |
---|
1239 | /* An error signaled. */ |
---|
1240 | void |
---|
1241 | cm_error (arg) |
---|
1242 | int arg; |
---|
1243 | { |
---|
1244 | if (arg == END) |
---|
1245 | add_word (html ? "error-->" : "error-->"); |
---|
1246 | } |
---|
1247 | |
---|
1248 | /* The location of point in an example of a buffer. */ |
---|
1249 | void |
---|
1250 | cm_point (arg) |
---|
1251 | int arg; |
---|
1252 | { |
---|
1253 | if (arg == END) |
---|
1254 | add_word ("-!-"); |
---|
1255 | } |
---|
1256 | |
---|
1257 | /* @exdent: Start a new line with just this text on it. |
---|
1258 | The text is outdented one level if possible. */ |
---|
1259 | void |
---|
1260 | cm_exdent () |
---|
1261 | { |
---|
1262 | char *line; |
---|
1263 | int save_indent = current_indent; |
---|
1264 | int save_in_fixed_width_font = in_fixed_width_font; |
---|
1265 | |
---|
1266 | /* Read argument. */ |
---|
1267 | get_rest_of_line (0, &line); |
---|
1268 | |
---|
1269 | /* Exdent the output. Actually this may be a no-op. */ |
---|
1270 | if (current_indent) |
---|
1271 | current_indent -= default_indentation_increment; |
---|
1272 | |
---|
1273 | /* @exdent arg is supposed to be in roman. */ |
---|
1274 | in_fixed_width_font = 0; |
---|
1275 | |
---|
1276 | /* The preceding newline already inserted the `current_indent'. |
---|
1277 | Remove one level's worth. */ |
---|
1278 | kill_self_indent (default_indentation_increment); |
---|
1279 | |
---|
1280 | if (html) |
---|
1281 | add_word ("<br>"); |
---|
1282 | |
---|
1283 | /* Can't close_single_paragraph, then we lose preceding blank lines. */ |
---|
1284 | flush_output (); |
---|
1285 | execute_string ("%s", line); |
---|
1286 | free (line); |
---|
1287 | |
---|
1288 | if (html) |
---|
1289 | add_word ("<br>"); |
---|
1290 | close_single_paragraph (); |
---|
1291 | |
---|
1292 | current_indent = save_indent; |
---|
1293 | in_fixed_width_font = save_in_fixed_width_font; |
---|
1294 | start_paragraph (); |
---|
1295 | } |
---|
1296 | |
---|
1297 | /* |
---|
1298 | Read include-filename, process the include-file: |
---|
1299 | verbatim_include == 0: process through reader_loop |
---|
1300 | verbatim_include != 0: process through handle_verbatim_environment |
---|
1301 | */ |
---|
1302 | static void |
---|
1303 | handle_include (verbatim_include) |
---|
1304 | int verbatim_include; |
---|
1305 | { |
---|
1306 | char *arg, *filename; |
---|
1307 | |
---|
1308 | if (macro_expansion_output_stream && !executing_string) |
---|
1309 | me_append_before_this_command (); |
---|
1310 | |
---|
1311 | close_paragraph (); |
---|
1312 | get_rest_of_line (0, &arg); |
---|
1313 | /* We really only want to expand @value, but it's easier to just do |
---|
1314 | everything. TeX will only work with @value. */ |
---|
1315 | filename = text_expansion (arg); |
---|
1316 | free (arg); |
---|
1317 | |
---|
1318 | if (macro_expansion_output_stream && !executing_string) |
---|
1319 | remember_itext (input_text, input_text_offset); |
---|
1320 | |
---|
1321 | pushfile (); |
---|
1322 | |
---|
1323 | /* In verbose mode we print info about including another file. */ |
---|
1324 | if (verbose_mode) |
---|
1325 | { |
---|
1326 | int i = 0; |
---|
1327 | FSTACK *stack = filestack; |
---|
1328 | |
---|
1329 | for (i = 0, stack = filestack; stack; stack = stack->next, i++); |
---|
1330 | |
---|
1331 | i *= 2; |
---|
1332 | |
---|
1333 | printf ("%*s", i, ""); |
---|
1334 | printf ("%c%s `%s'\n", COMMAND_PREFIX, command, filename); |
---|
1335 | fflush (stdout); |
---|
1336 | } |
---|
1337 | |
---|
1338 | if (!find_and_load (filename)) |
---|
1339 | { |
---|
1340 | popfile (); |
---|
1341 | line_number--; |
---|
1342 | |
---|
1343 | /* /wh/bar:5: @include/@verbatiminclude `foo': No such file or dir */ |
---|
1344 | line_error ("%c%s `%s': %s", COMMAND_PREFIX, command, filename, |
---|
1345 | strerror (errno)); |
---|
1346 | |
---|
1347 | free (filename); |
---|
1348 | return; |
---|
1349 | } |
---|
1350 | else |
---|
1351 | { |
---|
1352 | if (macro_expansion_output_stream && !executing_string) |
---|
1353 | remember_itext (input_text, input_text_offset); |
---|
1354 | |
---|
1355 | if (!verbatim_include) |
---|
1356 | reader_loop (); |
---|
1357 | else |
---|
1358 | handle_verbatim_environment (0); |
---|
1359 | } |
---|
1360 | free (filename); |
---|
1361 | popfile (); |
---|
1362 | } |
---|
1363 | |
---|
1364 | |
---|
1365 | /* Include file as if put in @verbatim environment */ |
---|
1366 | void |
---|
1367 | cm_verbatiminclude () |
---|
1368 | { |
---|
1369 | handle_include (1); |
---|
1370 | } |
---|
1371 | |
---|
1372 | |
---|
1373 | /* Remember this file, and move onto the next. */ |
---|
1374 | void |
---|
1375 | cm_include () |
---|
1376 | { |
---|
1377 | handle_include (0); |
---|
1378 | } |
---|
1379 | |
---|
1380 | |
---|
1381 | /* @bye: Signals end of processing. Easy to make this happen. */ |
---|
1382 | |
---|
1383 | void |
---|
1384 | cm_bye () |
---|
1385 | { |
---|
1386 | discard_braces (); /* should not have any unclosed braces left */ |
---|
1387 | flush_output (); |
---|
1388 | input_text_offset = input_text_length; |
---|
1389 | } |
---|
1390 | |
---|
1391 | /* @paragraphindent */ |
---|
1392 | |
---|
1393 | static void |
---|
1394 | cm_paragraphindent () |
---|
1395 | { |
---|
1396 | char *arg; |
---|
1397 | |
---|
1398 | get_rest_of_line (1, &arg); |
---|
1399 | if (set_paragraph_indent (arg) != 0) |
---|
1400 | line_error (_("Bad argument to %c%s"), COMMAND_PREFIX, command); |
---|
1401 | |
---|
1402 | free (arg); |
---|
1403 | } |
---|
1404 | |
---|
1405 | /* @exampleindent: change indentation of example-like environments. */ |
---|
1406 | static int |
---|
1407 | set_default_indentation_increment (string) |
---|
1408 | char *string; |
---|
1409 | { |
---|
1410 | if (strcmp (string, "asis") == 0 || strcmp (string, _("asis")) == 0) |
---|
1411 | ; |
---|
1412 | else if (strcmp (string, "none") == 0 || strcmp (string, _("none")) == 0) |
---|
1413 | default_indentation_increment = 0; |
---|
1414 | else if (sscanf (string, "%d", &default_indentation_increment) != 1) |
---|
1415 | return -1; |
---|
1416 | return 0; |
---|
1417 | } |
---|
1418 | |
---|
1419 | static void |
---|
1420 | cm_exampleindent () |
---|
1421 | { |
---|
1422 | char *arg; |
---|
1423 | |
---|
1424 | get_rest_of_line (1, &arg); |
---|
1425 | if (set_default_indentation_increment (arg) != 0) |
---|
1426 | line_error (_("Bad argument to %c%s"), COMMAND_PREFIX, command); |
---|
1427 | |
---|
1428 | free (arg); |
---|
1429 | } |
---|