summaryrefslogtreecommitdiff
path: root/contrib/texinfo/makeinfo/cmds.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2005-05-23 10:46:22 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2005-05-23 10:46:22 +0000
commitb641f89e0854f71e850ba1353f4f1b96e04e4385 (patch)
tree3fc59092050a7fe0bd61c1e105cf78dc1c99d284 /contrib/texinfo/makeinfo/cmds.c
parent9456217d09f0616433b42ba7b4c1fa601f1a56e9 (diff)
downloadsrc-test2-b641f89e0854f71e850ba1353f4f1b96e04e4385.tar.gz
src-test2-b641f89e0854f71e850ba1353f4f1b96e04e4385.zip
Notes
Diffstat (limited to 'contrib/texinfo/makeinfo/cmds.c')
-rw-r--r--contrib/texinfo/makeinfo/cmds.c1012
1 files changed, 711 insertions, 301 deletions
diff --git a/contrib/texinfo/makeinfo/cmds.c b/contrib/texinfo/makeinfo/cmds.c
index db9472bc5465..87ac7bb80de4 100644
--- a/contrib/texinfo/makeinfo/cmds.c
+++ b/contrib/texinfo/makeinfo/cmds.c
@@ -1,7 +1,7 @@
/* cmds.c -- Texinfo commands.
- $Id: cmds.c,v 1.18 2003/04/21 01:02:39 karl Exp $
+ $Id: cmds.c,v 1.55 2004/12/14 00:15:36 karl Exp $
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -39,70 +39,32 @@
#include <time.h>
#endif
-
-void insert_self (), insert_space (), cm_ignore_line (), cm_ignore_arg ();
-
-void
- cm_TeX (), cm_acronym (), cm_asterisk (), cm_b (), cm_bullet (), cm_cite (),
- cm_code (), cm_copyright (), cm_ctrl (), cm_dfn (), cm_dircategory (),
- cm_direntry (), cm_dmn (), cm_dots (), cm_emph (), cm_enddots (), cm_i (),
- cm_image (), cm_kbd (), cm_key (), cm_no_op (),
- cm_novalidate (), cm_not_fixed_width (), cm_r (),
- cm_strong (), cm_var (), cm_sc (), cm_w (), cm_email (), cm_url (),
- cm_verb (), cm_copying (), cm_insert_copying (),
- cm_documentdescription ();
-
-void
- cm_anchor (), cm_node (), cm_menu (), cm_xref (), cm_ftable (),
- cm_vtable (), cm_pxref (), cm_inforef (), cm_uref (), cm_email (),
- cm_quotation (), cm_display (), cm_smalldisplay (), cm_itemize (),
- cm_enumerate (), cm_tab (), cm_table (), cm_itemx (),
- cm_noindent (), cm_indent (),
- cm_setfilename (), cm_br (), cm_sp (), cm_page (), cm_group (),
- cm_center (), cm_ref (), cm_include (), cm_bye (), cm_item (), cm_end (),
- cm_kindex (), cm_cindex (), cm_findex (), cm_pindex (), cm_vindex (),
- cm_tindex (), cm_synindex (), cm_printindex (), cm_minus (),
- cm_example (), cm_smallexample (), cm_smalllisp (), cm_lisp (),
- cm_format (), cm_smallformat (), cm_exdent (), cm_defindex (),
- cm_defcodeindex (), cm_result (), cm_expansion (), cm_equiv (),
- cm_print (), cm_error (), cm_point (), cm_today (), cm_flushleft (),
- cm_flushright (), cm_finalout (), cm_cartouche (), cm_detailmenu (),
- cm_multitable (), cm_settitle (), cm_titlefont (), cm_titlepage (),
- cm_tie (), cm_tt (),
- cm_verbatim (), cm_verbatiminclude ();
-
-/* Conditionals. */
-void cm_set (), cm_clear (), cm_ifset (), cm_ifclear ();
-void cm_value (), cm_ifeq ();
-
/* Options. */
-static void
- cm_exampleindent (),
- cm_firstparagraphindent (),
- cm_paragraphindent ();
+static void cm_exampleindent (void),
+ cm_firstparagraphindent (void),
+ cm_paragraphindent (void),
+ cm_novalidate (void);
/* Internals. */
-static void cm_obsolete ();
-
-/* A random string. */
-static const char small_tag[] = "small";
+static void cm_obsolete (int arg, int start, int end),
+ not_fixed_width (int arg);
/* The dispatch table. */
COMMAND command_table[] = {
{ "\t", insert_space, NO_BRACE_ARGS },
{ "\n", insert_space, NO_BRACE_ARGS },
{ " ", insert_space, NO_BRACE_ARGS },
- { "!", insert_self, NO_BRACE_ARGS },
+ { "!", cm_punct, NO_BRACE_ARGS },
{ "\"", cm_accent_umlaut, MAYBE_BRACE_ARGS },
{ "'", cm_accent_acute, MAYBE_BRACE_ARGS },
{ "*", cm_asterisk, NO_BRACE_ARGS },
{ ",", cm_accent_cedilla, MAYBE_BRACE_ARGS },
{ "-", cm_no_op, NO_BRACE_ARGS },
- { ".", insert_self, NO_BRACE_ARGS },
+ { ".", cm_punct, NO_BRACE_ARGS },
{ "/", cm_no_op, NO_BRACE_ARGS },
- { ":", cm_no_op, NO_BRACE_ARGS },
+ { ":", cm_colon, NO_BRACE_ARGS },
{ "=", cm_accent, MAYBE_BRACE_ARGS },
- { "?", insert_self, NO_BRACE_ARGS },
+ { "?", cm_punct, NO_BRACE_ARGS },
{ "@", insert_self, NO_BRACE_ARGS },
{ "\\", insert_self, NO_BRACE_ARGS },
{ "^", cm_accent_hat, MAYBE_BRACE_ARGS },
@@ -115,10 +77,12 @@ COMMAND command_table[] = {
{ "AE", cm_special_char, BRACE_ARGS },
{ "H", cm_accent, MAYBE_BRACE_ARGS },
{ "L", cm_special_char, BRACE_ARGS },
+ { "LaTeX", cm_LaTeX, BRACE_ARGS },
{ "O", cm_special_char, BRACE_ARGS },
{ "OE", cm_special_char, BRACE_ARGS },
{ "TeX", cm_TeX, BRACE_ARGS },
{ "aa", cm_special_char, BRACE_ARGS },
+ { "abbr", cm_abbr, BRACE_ARGS },
{ "acronym", cm_acronym, BRACE_ARGS },
{ "ae", cm_special_char, BRACE_ARGS },
{ "afivepaper", cm_ignore_line, NO_BRACE_ARGS },
@@ -133,10 +97,12 @@ COMMAND command_table[] = {
{ "appendixsubsec", cm_appendixsubsec, NO_BRACE_ARGS },
{ "appendixsubsubsec", cm_appendixsubsubsec, NO_BRACE_ARGS },
{ "asis", cm_no_op, BRACE_ARGS },
+ { "author", cm_author, NO_BRACE_ARGS },
{ "b", cm_b, BRACE_ARGS },
{ "bullet", cm_bullet, BRACE_ARGS },
{ "bye", cm_bye, NO_BRACE_ARGS },
- { "c", cm_ignore_line, NO_BRACE_ARGS },
+ { "c", cm_comment, NO_BRACE_ARGS },
+ { "caption", cm_caption, BRACE_ARGS },
{ "cartouche", cm_cartouche, NO_BRACE_ARGS },
{ "center", cm_center, NO_BRACE_ARGS },
{ "centerchap", cm_unnumbered, NO_BRACE_ARGS },
@@ -146,8 +112,9 @@ COMMAND command_table[] = {
{ "cite", cm_cite, BRACE_ARGS },
{ "clear", cm_clear, NO_BRACE_ARGS },
{ "code", cm_code, BRACE_ARGS },
+ { "comma", cm_comma, BRACE_ARGS },
{ "command", cm_code, BRACE_ARGS },
- { "comment", cm_ignore_line, NO_BRACE_ARGS },
+ { "comment", cm_comment, NO_BRACE_ARGS },
{ "contents", cm_contents, NO_BRACE_ARGS },
{ "copying", cm_copying, NO_BRACE_ARGS },
{ "copyright", cm_copyright, BRACE_ARGS },
@@ -173,6 +140,8 @@ COMMAND command_table[] = {
{ "defspecx", cm_defun, NO_BRACE_ARGS },
{ "deftp", cm_defun, NO_BRACE_ARGS },
{ "deftpx", cm_defun, NO_BRACE_ARGS },
+ { "deftypecv", cm_defun, NO_BRACE_ARGS },
+ { "deftypecvx", cm_defun, NO_BRACE_ARGS },
{ "deftypefn", cm_defun, NO_BRACE_ARGS },
{ "deftypefnx", cm_defun, NO_BRACE_ARGS },
{ "deftypefun", cm_defun, NO_BRACE_ARGS },
@@ -198,7 +167,8 @@ COMMAND command_table[] = {
{ "dircategory", cm_dircategory, NO_BRACE_ARGS },
{ "direntry", cm_direntry, NO_BRACE_ARGS },
{ "display", cm_display, NO_BRACE_ARGS },
- { "dmn", cm_no_op, BRACE_ARGS },
+ { "dmn", cm_dmn, BRACE_ARGS },
+ { "docbook", cm_docbook, NO_BRACE_ARGS },
{ "documentdescription", cm_documentdescription, NO_BRACE_ARGS },
{ "documentencoding", cm_documentencoding, NO_BRACE_ARGS },
{ "documentlanguage", cm_documentlanguage, NO_BRACE_ARGS },
@@ -213,6 +183,7 @@ COMMAND command_table[] = {
{ "env", cm_code, BRACE_ARGS },
{ "equiv", cm_equiv, BRACE_ARGS },
{ "error", cm_error, BRACE_ARGS },
+ { "euro", cm_special_char, BRACE_ARGS },
{ "evenfooting", cm_ignore_line, NO_BRACE_ARGS },
{ "evenheading", cm_ignore_line, NO_BRACE_ARGS },
{ "everyfooting", cm_ignore_line, NO_BRACE_ARGS },
@@ -226,6 +197,7 @@ COMMAND command_table[] = {
{ "finalout", cm_no_op, NO_BRACE_ARGS },
{ "findex", cm_findex, NO_BRACE_ARGS },
{ "firstparagraphindent", cm_firstparagraphindent, NO_BRACE_ARGS },
+ { "float", cm_float, NO_BRACE_ARGS },
{ "flushleft", cm_flushleft, NO_BRACE_ARGS },
{ "flushright", cm_flushright, NO_BRACE_ARGS },
{ "footnote", cm_footnote, NO_BRACE_ARGS}, /* self-arg eater */
@@ -235,13 +207,16 @@ COMMAND command_table[] = {
{ "group", cm_group, NO_BRACE_ARGS },
{ "heading", cm_heading, NO_BRACE_ARGS },
{ "headings", cm_ignore_line, NO_BRACE_ARGS },
+ { "headitem", cm_headitem, NO_BRACE_ARGS },
{ "html", cm_html, NO_BRACE_ARGS },
{ "hyphenation", cm_ignore_arg, BRACE_ARGS },
{ "i", cm_i, BRACE_ARGS },
{ "ifclear", cm_ifclear, NO_BRACE_ARGS },
{ "ifeq", cm_ifeq, NO_BRACE_ARGS },
+ { "ifdocbook", cm_ifdocbook, NO_BRACE_ARGS },
{ "ifhtml", cm_ifhtml, NO_BRACE_ARGS },
{ "ifinfo", cm_ifinfo, NO_BRACE_ARGS },
+ { "ifnotdocbook", cm_ifnotdocbook, NO_BRACE_ARGS },
{ "ifnothtml", cm_ifnothtml, NO_BRACE_ARGS },
{ "ifnotinfo", cm_ifnotinfo, NO_BRACE_ARGS },
{ "ifnotplaintext", cm_ifnotplaintext, NO_BRACE_ARGS },
@@ -255,6 +230,7 @@ COMMAND command_table[] = {
{ "image", cm_image, BRACE_ARGS },
{ "include", cm_include, NO_BRACE_ARGS },
{ "indent", cm_indent, NO_BRACE_ARGS },
+ { "indicateurl", cm_indicate_url, BRACE_ARGS },
{ "inforef", cm_inforef, BRACE_ARGS },
{ "insertcopying", cm_insert_copying, NO_BRACE_ARGS },
{ "item", cm_item, NO_BRACE_ARGS },
@@ -266,16 +242,17 @@ COMMAND command_table[] = {
{ "kindex", cm_kindex, NO_BRACE_ARGS },
{ "l", cm_special_char, BRACE_ARGS },
{ "lisp", cm_lisp, NO_BRACE_ARGS },
+ { "listoffloats", cm_listoffloats, NO_BRACE_ARGS },
{ "lowersections", cm_lowersections, NO_BRACE_ARGS },
{ "macro", cm_macro, NO_BRACE_ARGS },
{ "majorheading", cm_majorheading, NO_BRACE_ARGS },
- { "math", cm_no_op, BRACE_ARGS },
+ { "math", cm_math, BRACE_ARGS },
{ "menu", cm_menu, NO_BRACE_ARGS },
{ "minus", cm_minus, BRACE_ARGS },
{ "multitable", cm_multitable, NO_BRACE_ARGS },
{ "need", cm_ignore_line, NO_BRACE_ARGS },
{ "node", cm_node, NO_BRACE_ARGS },
- { "noindent", cm_noindent, NO_BRACE_ARGS },
+ { "noindent", cm_noindent_cmd, NO_BRACE_ARGS },
{ "novalidate", cm_novalidate, NO_BRACE_ARGS },
{ "nwnode", cm_node, NO_BRACE_ARGS },
{ "o", cm_special_char, BRACE_ARGS },
@@ -283,6 +260,8 @@ COMMAND command_table[] = {
{ "oddheading", cm_ignore_line, NO_BRACE_ARGS },
{ "oe", cm_special_char, BRACE_ARGS },
{ "option", cm_code, BRACE_ARGS },
+ { "ordf", cm_special_char, BRACE_ARGS },
+ { "ordm", cm_special_char, BRACE_ARGS },
{ "page", cm_no_op, NO_BRACE_ARGS },
{ "pagesizes", cm_ignore_line, NO_BRACE_ARGS },
{ "paragraphindent", cm_paragraphindent, NO_BRACE_ARGS },
@@ -298,10 +277,12 @@ COMMAND command_table[] = {
{ "raisesections", cm_raisesections, NO_BRACE_ARGS },
{ "ref", cm_ref, BRACE_ARGS },
{ "refill", cm_no_op, NO_BRACE_ARGS },
+ { "registeredsymbol", cm_registeredsymbol, BRACE_ARGS },
{ "result", cm_result, BRACE_ARGS },
{ "ringaccent", cm_accent, MAYBE_BRACE_ARGS },
{ "rmacro", cm_rmacro, NO_BRACE_ARGS },
{ "samp", cm_code, BRACE_ARGS },
+ { "sansserif", cm_sansserif, BRACE_ARGS },
{ "sc", cm_sc, BRACE_ARGS },
{ "section", cm_section, NO_BRACE_ARGS },
{ "set", cm_set, NO_BRACE_ARGS },
@@ -311,8 +292,10 @@ COMMAND command_table[] = {
{ "setfilename", cm_setfilename, NO_BRACE_ARGS },
{ "setshortcontentsaftertitlepage", cm_no_op, NO_BRACE_ARGS },
{ "settitle", cm_settitle, NO_BRACE_ARGS },
- { "shortcontents", cm_shortcontents, NO_BRACE_ARGS },
+ { "shortcaption", cm_caption, BRACE_ARGS },
+ { "shortcontents", cm_contents, NO_BRACE_ARGS },
{ "shorttitlepage", cm_ignore_line, NO_BRACE_ARGS },
+ { "slanted", cm_slanted, BRACE_ARGS },
{ "smallbook", cm_ignore_line, NO_BRACE_ARGS },
{ "smalldisplay", cm_smalldisplay, NO_BRACE_ARGS },
{ "smallexample", cm_smallexample, NO_BRACE_ARGS },
@@ -325,7 +308,8 @@ COMMAND command_table[] = {
{ "subsection", cm_subsection, NO_BRACE_ARGS },
{ "subsubheading", cm_subsubheading, NO_BRACE_ARGS },
{ "subsubsection", cm_subsubsection, NO_BRACE_ARGS },
- { "summarycontents", cm_shortcontents, NO_BRACE_ARGS },
+ { "subtitle", cm_titlepage_cmds, NO_BRACE_ARGS },
+ { "summarycontents", cm_contents, NO_BRACE_ARGS },
{ "syncodeindex", cm_synindex, NO_BRACE_ARGS },
{ "synindex", cm_synindex, NO_BRACE_ARGS },
{ "t", cm_tt, BRACE_ARGS },
@@ -335,6 +319,7 @@ COMMAND command_table[] = {
{ "tie", cm_tie, BRACE_ARGS },
{ "tieaccent", cm_accent, MAYBE_BRACE_ARGS },
{ "tindex", cm_tindex, NO_BRACE_ARGS },
+ { "title", cm_titlepage_cmds, NO_BRACE_ARGS },
{ "titlefont", cm_titlefont, BRACE_ARGS },
{ "titlepage", cm_titlepage, NO_BRACE_ARGS },
{ "today", cm_today, BRACE_ARGS },
@@ -348,7 +333,7 @@ COMMAND command_table[] = {
{ "unnumberedsubsec", cm_unnumberedsubsec, NO_BRACE_ARGS },
{ "unnumberedsubsubsec", cm_unnumberedsubsubsec, NO_BRACE_ARGS },
{ "uref", cm_uref, BRACE_ARGS },
- { "url", cm_url, BRACE_ARGS },
+ { "url", cm_uref, BRACE_ARGS },
{ "v", cm_accent, MAYBE_BRACE_ARGS },
{ "value", cm_value, BRACE_ARGS },
{ "var", cm_var, BRACE_ARGS },
@@ -357,8 +342,9 @@ COMMAND command_table[] = {
{ "verbatiminclude", cm_verbatiminclude, NO_BRACE_ARGS },
{ "vindex", cm_vindex, NO_BRACE_ARGS },
{ "vtable", cm_vtable, NO_BRACE_ARGS },
+ { "vskip", cm_ignore_line, NO_BRACE_ARGS },
{ "w", cm_w, BRACE_ARGS },
- { "xml", cm_html, NO_BRACE_ARGS },
+ { "xml", cm_xml, NO_BRACE_ARGS },
{ "xref", cm_xref, BRACE_ARGS },
/* Deprecated commands. These used to be for italics. */
@@ -387,16 +373,14 @@ COMMAND command_table[] = {
/* Commands which insert their own names. */
void
-insert_self (arg)
- int arg;
+insert_self (int arg)
{
if (arg == START)
add_word (command);
}
void
-insert_space (arg)
- int arg;
+insert_space (int arg)
{
if (arg == START)
{
@@ -407,9 +391,19 @@ insert_space (arg)
}
}
+/* Insert a comma. Useful when a literal , would break our parsing of
+ multiple arguments. */
+void
+cm_comma (int arg)
+{
+ if (arg == START)
+ add_char (',');
+}
+
+
/* Force a line break in the output. */
void
-cm_asterisk ()
+cm_asterisk (void)
{
if (html)
add_word ("<br>");
@@ -426,8 +420,7 @@ cm_asterisk ()
/* Insert ellipsis. */
void
-cm_dots (arg)
- int arg;
+cm_dots (int arg)
{
if (arg == START)
{
@@ -436,15 +429,16 @@ cm_dots (arg)
else if (docbook)
xml_insert_entity ("hellip");
else
- add_word (html && !in_fixed_width_font
- ? "<small class=\"dots\">...</small>" : "...");
+ if (html && !in_fixed_width_font)
+ insert_string ("<small class=\"dots\">...</small>");
+ else
+ add_word ("...");
}
}
/* Insert ellipsis for sentence end. */
void
-cm_enddots (arg)
- int arg;
+cm_enddots (int arg)
{
if (arg == START)
{
@@ -456,19 +450,20 @@ cm_enddots (arg)
add_char ('.');
}
else
- add_word (html && !in_fixed_width_font
- ? "<small class=\"enddots\">....</small>" : "....");
+ if (html && !in_fixed_width_font)
+ insert_string ("<small class=\"enddots\">....</small>");
+ else
+ add_word ("....");
}
}
void
-cm_bullet (arg)
- int arg;
+cm_bullet (int arg)
{
if (arg == START)
{
if (html)
- add_word ("&#149;");
+ add_word ("&bull;");
else if (xml && !docbook)
xml_insert_entity ("bullet");
else if (docbook)
@@ -479,36 +474,79 @@ cm_bullet (arg)
}
void
-cm_minus (arg)
- int arg;
+cm_minus (int arg)
{
if (arg == START)
{
if (xml)
xml_insert_entity ("minus");
+ else if (html)
+ add_word ("&minus;");
else
add_char ('-');
}
}
+/* Formatting a dimension unit. */
+void
+cm_dmn (int arg)
+{
+ if (html)
+ insert_html_tag_with_attribute (arg, "span", "class=\"dmn\"");
+ else if (docbook)
+ /* No units in docbook yet. */
+ ;
+ else if (xml)
+ xml_insert_element (DIMENSION, arg);
+}
+
/* Insert "TeX". */
void
-cm_TeX (arg)
- int arg;
+cm_TeX (int arg)
{
+ static int last_position;
+
if (arg == START)
{
- if (xml && ! docbook)
+ if (xml)
xml_insert_entity ("tex");
else
add_word ("TeX");
+
+ last_position = output_paragraph_offset;
+ }
+ else if (last_position != output_paragraph_offset)
+ {
+ warning (_("arguments to @%s ignored"), command);
+ output_paragraph_offset = last_position;
+ }
+}
+
+/* Insert "LaTeX". */
+void
+cm_LaTeX (int arg)
+{
+ static int last_position;
+
+ if (arg == START)
+ {
+ if (xml)
+ xml_insert_entity ("latex");
+ else
+ add_word ("LaTeX");
+
+ last_position = output_paragraph_offset;
+ }
+ else if (last_position != output_paragraph_offset)
+ {
+ warning (_("arguments to @%s ignored"), command);
+ output_paragraph_offset = last_position;
}
}
/* Copyright symbol. */
void
-cm_copyright (arg)
- int arg;
+cm_copyright (int arg)
{
if (arg == START)
{
@@ -523,9 +561,25 @@ cm_copyright (arg)
}
}
+/* Registered symbol. */
+void
+cm_registeredsymbol (int arg)
+{
+ if (arg == START)
+ {
+ if (html)
+ add_word ("&reg;");
+ else if (docbook)
+ xml_insert_entity ("reg");
+ else if (xml && !docbook)
+ xml_insert_entity ("registered");
+ else
+ add_word ("(R)");
+ }
+}
+
void
-cm_today (arg)
- int arg;
+cm_today (int arg)
{
static char *months[12] =
{ N_("January"), N_("February"), N_("March"), N_("April"), N_("May"),
@@ -541,18 +595,191 @@ cm_today (arg)
}
void
-cm_acronym (arg)
- int arg;
+cm_comment (void)
+{
+ /* For HTML, do not output comments before HTML header is written,
+ otherwise comments before @settitle cause an empty <title> in the
+ header. */
+ if ((html && html_output_head_p) || xml)
+ {
+ char *line;
+ get_rest_of_line (0, &line);
+
+ if (strlen (line) > 0)
+ {
+ int save_inhibit_indentation = inhibit_paragraph_indentation;
+ int save_paragraph_is_open = paragraph_is_open;
+ int save_escape_html = escape_html;
+ int save_xml_no_para = xml_no_para;
+ int i;
+
+ inhibit_paragraph_indentation = 1;
+ escape_html = 0;
+ xml_no_para = 1;
+
+ /* @c and @comment can appear between @item and @itemx,
+ @deffn and @deffnx. */
+ xml_dont_touch_items_defs++;
+
+ /* Use insert for HTML, and XML when indentation is enabled.
+ For Docbook, use add_char. */
+ if (xml && xml_indentation_increment > 0
+ && output_paragraph[output_paragraph_offset-1] != '\n')
+ insert ('\n');
+
+ /* Crunch double hyphens in comments. */
+ add_html_block_elt ("<!-- ");
+ for (i = 0; i < strlen (line); i++)
+ if (line[i] != '-' || (i && line[i-1] != '-'))
+ add_char (line[i]);
+ add_word (" -->");
+
+ if (html)
+ add_char ('\n');
+
+ inhibit_paragraph_indentation = save_inhibit_indentation;
+ paragraph_is_open = save_paragraph_is_open;
+ escape_html = save_escape_html;
+ xml_no_para = save_xml_no_para;
+ xml_dont_touch_items_defs--;
+ }
+
+ free (line);
+ }
+ else
+ cm_ignore_line ();
+}
+
+
+
+/* We keep acronyms with two arguments around, to be able to refer to them
+ later with only one argument. */
+static ACRONYM_DESC *acronyms_stack = NULL;
+
+static void
+cm_acronym_or_abbr (int arg, int is_abbr)
{
+ char *aa, *description;
+ unsigned len;
+
+ /* We do everything at START. */
+ if (arg == END)
+ return;
+
+ get_until_in_braces (",", &aa);
+ if (input_text[input_text_offset] == ',')
+ input_text_offset++;
+ get_until_in_braces ("}", &description);
+
+ canon_white (aa);
+ canon_white (description);
+
+ /* If not enclosed in braces, strip after comma to be compatible
+ with texinfo.tex. */
+ if (description[0] != '{' && strchr (description, ',') != NULL)
+ {
+ int i = 0;
+ while (description[i] != ',')
+ i++;
+ /* For now, just terminate the string at comma. */
+ description[i] = 0;
+ }
+
+ /* Get description out of braces. */
+ if (description[0] == '{')
+ description++;
+
+ len = strlen (description);
+ if (len && description[len-1] == '}')
+ description[len-1] = 0;
+
+ /* Save new description. */
+ if (strlen (description) > 0)
+ {
+ ACRONYM_DESC *new = xmalloc (sizeof (ACRONYM_DESC));
+
+ new->acronym = xstrdup (aa);
+ new->description = xstrdup (description);
+ new->next = acronyms_stack;
+ acronyms_stack = new;
+ }
+
if (html)
- insert_html_tag (arg, small_tag);
+ {
+ add_word (is_abbr ? "<abbr" : "<acronym");
+
+ if (strlen (description) > 0)
+ add_word_args (" title=\"%s\"", text_expansion (description));
+ else if (acronyms_stack)
+ {
+ /* No second argument, get from previous. Search order is from
+ last to first defined, so we get the most recent version of
+ the description. */
+ ACRONYM_DESC *temp = acronyms_stack;
+
+ while (temp)
+ {
+ if (STREQ (aa, temp->acronym)
+ && strlen (temp->description) > 0)
+ {
+ add_word_args (" title=\"%s\"",
+ text_expansion (temp->description));
+ break;
+ }
+ temp = temp->next;
+ }
+ }
+
+ add_char ('>');
+ execute_string ("%s", aa);
+ add_word (is_abbr ? "</abbr>" : "</acronym>");
+ }
+ else if (docbook)
+ {
+ xml_insert_element (is_abbr ? ABBREV : ACRONYM, START);
+ execute_string ("%s", aa);
+ xml_insert_element (is_abbr ? ABBREV : ACRONYM, END);
+ }
else if (xml)
- xml_insert_element (ACRONYM, arg);
+ {
+ xml_insert_element (is_abbr ? ABBREV : ACRONYM, START);
+
+ xml_insert_element (is_abbr ? ABBREVWORD : ACRONYMWORD, START);
+ execute_string ("%s", aa);
+ xml_insert_element (is_abbr ? ABBREVWORD : ACRONYMWORD, END);
+
+ if (strlen (description) > 0)
+ {
+ xml_insert_element (is_abbr ? ABBREVDESC : ACRONYMDESC, START);
+ execute_string ("%s", description);
+ xml_insert_element (is_abbr ? ABBREVDESC : ACRONYMDESC, END);
+ }
+
+ xml_insert_element (is_abbr ? ABBREV : ACRONYM, END);
+ }
+ else
+ execute_string ("%s", aa);
+
+ /* Put description into parenthesis after the acronym for all outputs
+ except XML. */
+ if (strlen (description) > 0 && (!xml || docbook))
+ add_word_args (" (%s)", description);
}
void
-cm_tt (arg)
- int arg;
+cm_acronym (int arg)
+{
+ cm_acronym_or_abbr (arg, 0);
+}
+
+void
+cm_abbr (int arg)
+{
+ cm_acronym_or_abbr (arg, 1);
+}
+
+void
+cm_tt (int arg)
{
/* @t{} is a no-op in Info. */
if (html)
@@ -562,37 +789,73 @@ cm_tt (arg)
}
void
-cm_code (arg)
- int arg;
+cm_code (int arg)
{
+ if (arg == START)
+ in_fixed_width_font++;
+
if (xml)
- xml_insert_element (CODE, arg);
- else
{
- extern int printing_index;
-
- if (arg == START)
+ if (STREQ (command, "command"))
+ xml_insert_element (COMMAND_TAG, arg);
+ else if (STREQ (command, "env"))
+ xml_insert_element (ENV, arg);
+ else if (STREQ (command, "file"))
+ xml_insert_element (FILE_TAG, arg);
+ else if (STREQ (command, "option"))
+ xml_insert_element (OPTION, arg);
+ else if (STREQ (command, "samp"))
{
- in_fixed_width_font++;
-
- if (html)
- insert_html_tag (arg, "code");
- else if (!printing_index)
- add_char ('`');
+ if (docbook && arg == START)
+ {
+ /* Even though @samp is in_fixed_width_font, it
+ should always start a paragraph. Unfortunately,
+ in_fixed_width_font inhibits that. */
+ xml_start_para ();
+ xml_insert_entity ("lsquo");
+ }
+ xml_insert_element (SAMP, arg);
+ if (docbook && arg == END)
+ xml_insert_entity ("rsquo");
}
- else if (html)
+ else
+ xml_insert_element (CODE, arg);
+ }
+ else if (html)
+ {
+ if (STREQ (command, "code"))
insert_html_tag (arg, "code");
else
+ { /* Use <samp> tag in general to get typewriter. */
+ if (arg == START)
+ { /* If @samp specifically, add quotes a la TeX output. */
+ if (STREQ (command, "samp")) add_char ('`');
+ add_word ("<samp>");
+ }
+ insert_html_tag_with_attribute (arg, "span", "class=\"%s\"",command);
+ if (arg == END)
+ {
+ add_word ("</samp>");
+ if (STREQ (command, "samp")) add_char ('\'');
+ }
+ }
+ }
+ else
+ {
+ extern int printing_index;
+
+ if (!printing_index)
{
- if (!printing_index)
+ if (arg == START)
+ add_char ('`');
+ else
add_meta_char ('\'');
}
}
}
void
-cm_kbd (arg)
- int arg;
+cm_kbd (int arg)
{
if (xml)
xml_insert_element (KBD, arg);
@@ -612,8 +875,9 @@ cm_kbd (arg)
}
}
+/* Just show a url (http://example.org/..., for example), don't link to it. */
void
-cm_url (arg, start, end)
+cm_indicate_url (int arg, int start, int end)
{
if (xml)
xml_insert_element (URL, arg);
@@ -633,8 +897,7 @@ cm_url (arg, start, end)
}
void
-cm_key (arg)
- int arg;
+cm_key (int arg)
{
if (xml)
xml_insert_element (KEY, arg);
@@ -646,8 +909,7 @@ cm_key (arg)
/* Handle a command that switches to a non-fixed-width font. */
void
-not_fixed_width (arg)
- int arg;
+not_fixed_width (int arg)
{
if (arg == START)
in_fixed_width_font = 0;
@@ -655,8 +917,7 @@ not_fixed_width (arg)
/* @var in makeinfo just uppercases the text. */
void
-cm_var (arg, start_pos, end_pos)
- int arg, start_pos, end_pos;
+cm_var (int arg, int start_pos, int end_pos)
{
if (xml)
xml_insert_element (VAR, arg);
@@ -681,51 +942,50 @@ cm_var (arg, start_pos, end_pos)
}
void
-cm_sc (arg, start_pos, end_pos)
- int arg, start_pos, end_pos;
+cm_sc (int arg, int start_pos, int end_pos)
{
if (xml)
xml_insert_element (SC, arg);
else
{
- not_fixed_width (arg);
-
- if (arg == START)
- {
- if (html)
- insert_html_tag (arg, small_tag);
- }
- else
- {
- int all_upper;
+ not_fixed_width (arg);
- if (html)
- start_pos += sizeof (small_tag) + 2 - 1; /* skip <small> */
+ if (arg == START)
+ {
+ if (html)
+ insert_html_tag_with_attribute (arg, "span", "class=\"sc\"");
+ }
+ else
+ {
+ int all_upper;
- /* Avoid the warning below if there's no text inside @sc{}, or
- when processing menus under --no-headers. */
- all_upper = start_pos < end_pos;
+ if (html)
+ start_pos += sizeof ("<span class=\"sc\">") - 1; /* skip <span> */
+
+ /* Avoid the warning below if there's no text inside @sc{}, or
+ when processing menus under --no-headers. */
+ all_upper = start_pos < end_pos;
+
+ while (start_pos < end_pos)
+ {
+ unsigned char c = output_paragraph[start_pos];
+ if (!isupper (c))
+ all_upper = 0;
+ if (!html)
+ output_paragraph[start_pos] = coerce_to_upper (c);
+ start_pos++;
+ }
+ if (all_upper)
+ warning (_("@sc argument all uppercase, thus no effect"));
- while (start_pos < end_pos)
- {
- unsigned char c = output_paragraph[start_pos];
- if (!isupper (c))
- all_upper = 0;
- output_paragraph[start_pos] = coerce_to_upper (c);
- start_pos++;
+ if (html)
+ insert_html_tag (arg, "span");
}
- if (all_upper)
- warning (_("@sc argument all uppercase, thus no effect"));
-
- if (html)
- insert_html_tag (arg, small_tag);
- }
}
}
void
-cm_dfn (arg, position)
- int arg, position;
+cm_dfn (int arg, int position)
{
if (xml)
xml_insert_element (DFN, arg);
@@ -741,8 +1001,7 @@ cm_dfn (arg, position)
}
void
-cm_emph (arg)
- int arg;
+cm_emph (int arg)
{
if (xml)
xml_insert_element (EMPH, arg);
@@ -753,11 +1012,10 @@ cm_emph (arg)
}
void
-cm_verb (arg)
- int arg;
+cm_verb (int arg)
{
int character;
- int delimiter;
+ int delimiter = 0; /* avoid warning */
int seen_end = 0;
in_fixed_width_font++;
@@ -799,7 +1057,7 @@ cm_verb (arg)
else if (html && character == '&')
add_word ("&amp;");
- else if (character == delimiter)
+ else if (character == delimiter && input_text[input_text_offset+1] == '}')
{ /* Assume no newlines in END_VERBATIM. */
seen_end = 1;
input_text_offset++;
@@ -832,20 +1090,33 @@ cm_verb (arg)
void
-cm_strong (arg, position)
- int arg, position;
+cm_strong (int arg, int start_pos, int end_pos)
{
- if (xml)
+ if (docbook && arg == START)
+ xml_insert_element_with_attribute (B, arg, "role=\"bold\"");
+ else if (xml)
xml_insert_element (STRONG, arg);
else if (html)
insert_html_tag (arg, "strong");
else
add_char ('*');
+
+ if (!xml && !html && !docbook && !no_headers
+ && arg == END
+ && end_pos - start_pos >= 6
+ && (STRNCASEEQ ((char *) output_paragraph + start_pos, "*Note:", 6)
+ || STRNCASEEQ ((char *) output_paragraph + start_pos, "*Note ", 6)))
+ {
+ /* Translators: "Note:" is literal here and should not be
+ translated. @strong{Nota}, say, does not cause the problem. */
+ warning (_("@strong{Note...} produces a spurious cross-reference in Info; reword to avoid that"));
+ /* Adjust the output to avoid writing the bad xref. */
+ output_paragraph[start_pos + 5] = '_';
+ }
}
void
-cm_cite (arg, position)
- int arg, position;
+cm_cite (int arg, int position)
{
if (xml)
xml_insert_element (CITE, arg);
@@ -862,8 +1133,7 @@ cm_cite (arg, position)
/* No highlighting, but argument switches fonts. */
void
-cm_not_fixed_width (arg, start, end)
- int arg, start, end;
+cm_not_fixed_width (int arg, int start, int end)
{
if (xml)
xml_insert_element (NOTFIXEDWIDTH, arg);
@@ -871,10 +1141,14 @@ cm_not_fixed_width (arg, start, end)
}
void
-cm_i (arg)
- int arg;
+cm_i (int arg)
{
- if (xml)
+ /* Make use of <lineannotation> of Docbook, if we are
+ inside an @example or similar. */
+ extern int printing_index;
+ if (docbook && !filling_enabled && !printing_index)
+ xml_insert_element (LINEANNOTATION, arg);
+ else if (xml)
xml_insert_element (I, arg);
else if (html)
insert_html_tag (arg, "i");
@@ -883,10 +1157,31 @@ cm_i (arg)
}
void
-cm_b (arg)
- int arg;
+cm_slanted (int arg)
{
- if (xml)
+ /* Make use of <lineannotation> of Docbook, if we are
+ inside an @example or similar. */
+ extern int printing_index;
+ if (docbook && !filling_enabled && !printing_index)
+ xml_insert_element (LINEANNOTATION, arg);
+ else if (xml)
+ xml_insert_element (SLANTED, arg);
+ else if (html)
+ insert_html_tag (arg, "i");
+ else
+ not_fixed_width (arg);
+}
+
+void
+cm_b (int arg)
+{
+ /* See cm_i comments. */
+ extern int printing_index;
+ if (docbook && !filling_enabled && !printing_index)
+ xml_insert_element (LINEANNOTATION, arg);
+ else if (docbook && arg == START)
+ xml_insert_element_with_attribute (B, arg, "role=\"bold\"");
+ else if (xml)
xml_insert_element (B, arg);
else if (html)
insert_html_tag (arg, "b");
@@ -895,23 +1190,37 @@ cm_b (arg)
}
void
-cm_r (arg)
- int arg;
+cm_r (int arg)
{
- if (xml)
+ /* See cm_i comments. */
+ extern int printing_index;
+ if (docbook && !filling_enabled && !printing_index)
+ xml_insert_element (LINEANNOTATION, arg);
+ else if (xml)
xml_insert_element (R, arg);
+ else if (html)
+ insert_html_tag_with_attribute (arg, "span", "class=\"roman\"");
else
- {
- if (html)
- insert_html_tag (arg, "");
+ not_fixed_width (arg);
+}
- not_fixed_width (arg);
- }
+void
+cm_sansserif (int arg)
+{
+ /* See cm_i comments. */
+ extern int printing_index;
+ if (docbook && !filling_enabled && !printing_index)
+ xml_insert_element (LINEANNOTATION, arg);
+ else if (xml)
+ xml_insert_element (SANSSERIF, arg);
+ else if (html)
+ insert_html_tag_with_attribute (arg, "span", "class=\"sansserif\"");
+ else
+ not_fixed_width (arg);
}
void
-cm_titlefont (arg)
- int arg;
+cm_titlefont (int arg)
{
if (xml)
xml_insert_element (TITLEFONT, arg);
@@ -929,26 +1238,26 @@ cm_titlefont (arg)
}
}
-int titlepage_cmd_present = 0;
+/* Unfortunately, we cannot interpret @math{} contents like TeX does. We just
+ pass them through. */
void
-cm_titlepage (arg)
- int arg;
+cm_math (int arg)
{
- titlepage_cmd_present = 1;
- command_name_condition ();
+ if (xml && !docbook)
+ xml_insert_element (MATH, arg);
}
/* Various commands are no-op's. */
void
-cm_no_op ()
+cm_no_op (void)
{
}
/* For proofing single chapters, etc. */
void
-cm_novalidate ()
+cm_novalidate (void)
{
validating = 0;
}
@@ -956,13 +1265,19 @@ cm_novalidate ()
/* Prevent the argument from being split across two lines. */
void
-cm_w (arg, start, end)
- int arg, start, end;
+cm_w (int arg)
{
if (arg == START)
non_splitting_words++;
else
- non_splitting_words--;
+ {
+ if (docbook || html || xml)
+ /* This is so @w{$}Log$ doesn't end up as <dollar>Log<dollar>
+ in the output. */
+ insert_string ("<!-- /@w -->");
+
+ non_splitting_words--;
+ }
}
@@ -970,8 +1285,7 @@ cm_w (arg, start, end)
for TeX (the space stretches and stretches, and does not inhibit
hyphenation). */
void
-cm_tie (arg)
- int arg;
+cm_tie (int arg)
{
if (arg == START)
{
@@ -985,8 +1299,7 @@ cm_tie (arg)
/* Explain that this command is obsolete, thus the user shouldn't
do anything with it. */
static void
-cm_obsolete (arg, start, end)
- int arg, start, end;
+cm_obsolete (int arg, int start, int end)
{
if (arg == START)
warning (_("%c%s is obsolete"), COMMAND_PREFIX, command);
@@ -996,17 +1309,44 @@ cm_obsolete (arg, start, end)
/* Inhibit the indentation of the next paragraph, but not of following
paragraphs. */
void
-cm_noindent ()
+cm_noindent (void)
{
if (!inhibit_paragraph_indentation)
inhibit_paragraph_indentation = -1;
}
+void
+cm_noindent_cmd (void)
+{
+ cm_noindent ();
+ xml_no_indent = 1;
+ skip_whitespace_and_newlines();
+
+ if (xml)
+ xml_start_para ();
+ else if (html && !paragraph_is_open)
+ add_html_block_elt ("<p class=\"noindent\">");
+ else
+ {
+ paragraph_is_open = 0;
+ start_paragraph ();
+ }
+}
+
/* Force indentation of the next paragraph. */
void
-cm_indent ()
+cm_indent (void)
{
inhibit_paragraph_indentation = 0;
+ xml_no_indent = 0;
+ skip_whitespace_and_newlines();
+
+ if (xml)
+ xml_start_para ();
+ else if (html && !paragraph_is_open)
+ add_html_block_elt ("<p class=\"indent\">");
+ else
+ start_paragraph ();
}
/* I don't know exactly what to do with this. Should I allow
@@ -1016,7 +1356,7 @@ cm_indent ()
switch files. Finally, complain, or at least warn. It doesn't
really matter, anyway, since this doesn't get executed. */
void
-cm_setfilename ()
+cm_setfilename (void)
{
char *filename;
get_rest_of_line (1, &filename);
@@ -1027,7 +1367,7 @@ cm_setfilename ()
}
void
-cm_settitle ()
+cm_settitle (void)
{
if (xml)
{
@@ -1038,11 +1378,6 @@ cm_settitle ()
execute_string ("%s", title);
xml_in_book_title = 0;
xml_insert_element (SETTITLE, END);
- if (docbook && !xml_in_bookinfo)
- {
- xml_insert_element (BOOKINFO, START);
- xml_in_bookinfo = 1;
- }
}
else
get_rest_of_line (0, &title);
@@ -1051,8 +1386,7 @@ cm_settitle ()
/* Ignore argument in braces. */
void
-cm_ignore_arg (arg, start_pos, end_pos)
- int arg, start_pos, end_pos;
+cm_ignore_arg (int arg, int start_pos, int end_pos)
{
if (arg == END)
output_paragraph_offset = start_pos;
@@ -1060,19 +1394,21 @@ cm_ignore_arg (arg, start_pos, end_pos)
/* Ignore argument on rest of line. */
void
-cm_ignore_line ()
+cm_ignore_line (void)
{
discard_until ("\n");
}
/* Insert the number of blank lines passed as argument. */
void
-cm_sp ()
+cm_sp (void)
{
int lines;
char *line;
- get_rest_of_line (1, &line);
+ /* Due to tricky stuff in execute_string(), @value{} can't be expanded.
+ So there is really no reason to enable expansion for @sp parameters. */
+ get_rest_of_line (0, &line);
if (sscanf (line, "%d", &lines) != 1 || lines <= 0)
line_error (_("@sp requires a positive numeric argument, not `%s'"), line);
@@ -1080,41 +1416,45 @@ cm_sp ()
{
if (xml)
{
+ /* @sp can appear between @item and @itemx, @deffn and @deffnx. */
+ xml_dont_touch_items_defs++;
xml_insert_element_with_attribute (SP, START, "lines=\"%s\"", line);
/* insert_string (line);*/
xml_insert_element (SP, END);
+ xml_dont_touch_items_defs--;
}
else
- {
- /* Must disable filling since otherwise multiple newlines is like
- multiple spaces. Must close paragraph since that's what the
- manual says and that's what TeX does. */
- int save_filling_enabled = filling_enabled;
- filling_enabled = 0;
-
- /* close_paragraph generates an extra blank line. */
- close_single_paragraph ();
+ {
+ /* Must disable filling since otherwise multiple newlines is like
+ multiple spaces. Must close paragraph since that's what the
+ manual says and that's what TeX does. */
+ int save_filling_enabled = filling_enabled;
+ filling_enabled = 0;
- if (lines && html && !executing_string)
- html_output_head ();
+ /* close_paragraph generates an extra blank line. */
+ close_single_paragraph ();
- while (lines--)
- {
- if (html)
- insert_string ("<br><p>\n");
- else
- add_char ('\n');
- }
+ if (lines && html && !executing_string)
+ html_output_head ();
- filling_enabled = save_filling_enabled;
- }
+ if (html)
+ add_html_block_elt ("<pre class=\"sp\">\n");
+
+ while (lines--)
+ add_char ('\n');
+
+ if (html)
+ add_html_block_elt ("</pre>\n");
+
+ filling_enabled = save_filling_enabled;
+ }
}
free (line);
}
/* @dircategory LINE outputs INFO-DIR-SECTION LINE, unless --no-headers. */
void
-cm_dircategory ()
+cm_dircategory (void)
{
char *line;
@@ -1148,77 +1488,79 @@ cm_dircategory ()
Then center the line of text.
*/
void
-cm_center ()
+cm_center (void)
{
if (xml)
{
- unsigned char *line;
+ char *line;
xml_insert_element (CENTER, START);
- get_rest_of_line (0, (char **)&line);
- execute_string ("%s", (char *)line);
+ get_rest_of_line (0, &line);
+ execute_string ("%s", line);
free (line);
xml_insert_element (CENTER, END);
}
else
{
- int i, start, length;
- unsigned char *line;
- int save_indented_fill = indented_fill;
- int save_filling_enabled = filling_enabled;
- int fudge_factor = 1;
+ int i, start, length;
+ char *line;
+ int save_indented_fill = indented_fill;
+ int save_filling_enabled = filling_enabled;
+ int fudge_factor = 1;
- filling_enabled = indented_fill = 0;
- cm_noindent ();
- start = output_paragraph_offset;
+ filling_enabled = indented_fill = 0;
+ cm_noindent ();
+ start = output_paragraph_offset;
- if (html)
- add_word ("<div align=\"center\">");
+ if (html)
+ add_html_block_elt ("<div align=\"center\">");
- inhibit_output_flushing ();
- get_rest_of_line (0, (char **)&line);
- execute_string ("%s", (char *)line);
- free (line);
- uninhibit_output_flushing ();
- if (html)
- add_word ("</div>");
+ inhibit_output_flushing ();
+ get_rest_of_line (0, &line);
+ execute_string ("%s", line);
+ free (line);
+ uninhibit_output_flushing ();
+ if (html)
+ add_html_block_elt ("</div>");
- else
- {
- i = output_paragraph_offset - 1;
- while (i > (start - 1) && output_paragraph[i] == '\n')
- i--;
+ else
+ {
+ i = output_paragraph_offset - 1;
+ while (i > (start - 1) && output_paragraph[i] == '\n')
+ i--;
- output_paragraph_offset = ++i;
- length = output_paragraph_offset - start;
+ output_paragraph_offset = ++i;
+ length = output_paragraph_offset - start;
- if (length < (fill_column - fudge_factor))
- {
- line = xmalloc (1 + length);
- memcpy (line, (char *)(output_paragraph + start), length);
+ if (length < (fill_column - fudge_factor))
+ {
+ line = xmalloc (1 + length);
+ memcpy (line, (char *)(output_paragraph + start), length);
- i = (fill_column - fudge_factor - length) / 2;
- output_paragraph_offset = start;
+ i = (fill_column - fudge_factor - length) / 2;
+ output_paragraph_offset = start;
- while (i--)
- insert (' ');
+ while (i--)
+ insert (' ');
- for (i = 0; i < length; i++)
- insert (line[i]);
+ for (i = 0; i < length; i++)
+ insert (line[i]);
- free (line);
- }
- }
+ free (line);
+ }
+ }
- insert ('\n');
- filling_enabled = save_filling_enabled;
- indented_fill = save_indented_fill;
+ insert ('\n');
+ filling_enabled = save_filling_enabled;
+ indented_fill = save_indented_fill;
+ close_single_paragraph ();
+ if (looking_at("\n"))
+ insert ('\n');
}
}
/* Show what an expression returns. */
void
-cm_result (arg)
- int arg;
+cm_result (int arg)
{
if (arg == END)
add_word (html ? "=&gt;" : "=>");
@@ -1226,8 +1568,7 @@ cm_result (arg)
/* What an expression expands to. */
void
-cm_expansion (arg)
- int arg;
+cm_expansion (int arg)
{
if (arg == END)
add_word (html ? "==&gt;" : "==>");
@@ -1235,8 +1576,7 @@ cm_expansion (arg)
/* Indicates two expressions are equivalent. */
void
-cm_equiv (arg)
- int arg;
+cm_equiv (int arg)
{
if (arg == END)
add_word ("==");
@@ -1244,8 +1584,7 @@ cm_equiv (arg)
/* What an expression may print. */
void
-cm_print (arg)
- int arg;
+cm_print (int arg)
{
if (arg == END)
add_word ("-|");
@@ -1253,8 +1592,7 @@ cm_print (arg)
/* An error signaled. */
void
-cm_error (arg)
- int arg;
+cm_error (int arg)
{
if (arg == END)
add_word (html ? "error--&gt;" : "error-->");
@@ -1262,8 +1600,7 @@ cm_error (arg)
/* The location of point in an example of a buffer. */
void
-cm_point (arg)
- int arg;
+cm_point (int arg)
{
if (arg == END)
add_word ("-!-");
@@ -1272,7 +1609,7 @@ cm_point (arg)
/* @exdent: Start a new line with just this text on it.
The text is outdented one level if possible. */
void
-cm_exdent ()
+cm_exdent (void)
{
char *line;
int save_indent = current_indent;
@@ -1294,6 +1631,10 @@ cm_exdent ()
if (html)
add_word ("<br>");
+ else if (docbook)
+ xml_insert_element (LINEANNOTATION, START);
+ else if (xml)
+ xml_insert_element (EXDENT, START);
/* Can't close_single_paragraph, then we lose preceding blank lines. */
flush_output ();
@@ -1302,11 +1643,18 @@ cm_exdent ()
if (html)
add_word ("<br>");
+ else if (xml)
+ {
+ xml_insert_element (docbook ? LINEANNOTATION : EXDENT, END);
+ insert ('\n');
+ }
+
close_single_paragraph ();
current_indent = save_indent;
in_fixed_width_font = save_in_fixed_width_font;
- start_paragraph ();
+ if (!xml)
+ start_paragraph ();
}
/*
@@ -1315,15 +1663,16 @@ cm_exdent ()
verbatim_include != 0: process through handle_verbatim_environment
*/
static void
-handle_include (verbatim_include)
- int verbatim_include;
+handle_include (int verbatim_include)
{
char *arg, *filename;
if (macro_expansion_output_stream && !executing_string)
me_append_before_this_command ();
- close_paragraph ();
+ if (!insertion_stack)
+ close_paragraph (); /* No blank lines etc. if not at outer level. */
+
get_rest_of_line (0, &arg);
/* We really only want to expand @value, but it's easier to just do
everything. TeX will only work with @value. */
@@ -1350,7 +1699,7 @@ handle_include (verbatim_include)
fflush (stdout);
}
- if (!find_and_load (filename))
+ if (!find_and_load (filename, 1))
{
popfile ();
line_number--;
@@ -1379,7 +1728,7 @@ handle_include (verbatim_include)
/* Include file as if put in @verbatim environment */
void
-cm_verbatiminclude ()
+cm_verbatiminclude (void)
{
handle_include (1);
}
@@ -1387,7 +1736,7 @@ cm_verbatiminclude ()
/* Remember this file, and move onto the next. */
void
-cm_include ()
+cm_include (void)
{
handle_include (0);
}
@@ -1396,17 +1745,16 @@ cm_include ()
/* @bye: Signals end of processing. Easy to make this happen. */
void
-cm_bye ()
+cm_bye (void)
{
discard_braces (); /* should not have any unclosed braces left */
- flush_output ();
input_text_offset = input_text_length;
}
/* @paragraphindent */
static void
-cm_paragraphindent ()
+cm_paragraphindent (void)
{
char *arg;
@@ -1420,26 +1768,28 @@ cm_paragraphindent ()
/* @exampleindent: change indentation of example-like environments. */
static int
-set_default_indentation_increment (string)
- char *string;
+set_example_indentation_increment (char *string)
{
if (strcmp (string, "asis") == 0 || strcmp (string, _("asis")) == 0)
;
else if (strcmp (string, "none") == 0 || strcmp (string, _("none")) == 0)
- default_indentation_increment = 0;
- else if (sscanf (string, "%d", &default_indentation_increment) != 1)
+ example_indentation_increment = 0;
+ else if (sscanf (string, "%d", &example_indentation_increment) != 1)
return -1;
return 0;
}
static void
-cm_exampleindent ()
+cm_exampleindent (void)
{
char *arg;
get_rest_of_line (1, &arg);
- if (set_default_indentation_increment (arg) != 0)
- line_error (_("Bad argument to %c%s"), COMMAND_PREFIX, command);
+ if (set_example_indentation_increment (arg) != 0)
+ line_error (_("Bad argument to @%s"), command);
+
+ if (input_text[input_text_offset] == '\n')
+ close_single_paragraph ();
free (arg);
}
@@ -1448,8 +1798,7 @@ cm_exampleindent ()
/* @firstparagraphindent: suppress indentation in first paragraphs after
headings. */
static int
-set_firstparagraphindent (string)
- char *string;
+set_firstparagraphindent (char *string)
{
if (STREQ (string, "insert") || STREQ (string, _("insert")))
do_first_par_indent = 1;
@@ -1461,7 +1810,7 @@ set_firstparagraphindent (string)
}
static void
-cm_firstparagraphindent ()
+cm_firstparagraphindent (void)
{
char *arg;
@@ -1471,3 +1820,64 @@ cm_firstparagraphindent ()
free (arg);
}
+
+/* For DocBook and XML, produce &period; for `.@:'. This gives the processing
+ software a fighting chance to treat it specially by not adding extra space.
+
+ Do this also for ?, !, and :. */
+void
+cm_colon (void)
+{
+ if (xml)
+ {
+ if (strchr (".?!:", input_text[input_text_offset-3]) != NULL)
+ {
+ /* Erase literal character that's there, except `>', which is
+ part of the XML tag. */
+ if (output_paragraph[output_paragraph_offset-1] != '>')
+ output_paragraph_offset--;
+
+ switch (input_text[input_text_offset-3])
+ {
+ case '.':
+ xml_insert_entity ("period");
+ break;
+ case '?':
+ xml_insert_entity ("quest");
+ break;
+ case '!':
+ xml_insert_entity ("excl");
+ break;
+ case ':':
+ xml_insert_entity ("colon");
+ break;
+ }
+ }
+ }
+}
+
+/* Ending sentences explicitly. Currently, only outputs entities for XML
+ output, for other formats it calls insert_self. */
+void
+cm_punct (int arg)
+{
+ if (xml && !docbook)
+ {
+ switch (input_text[input_text_offset-1])
+ {
+ case '.':
+ xml_insert_entity ("eosperiod");
+ break;
+ case '?':
+ xml_insert_entity ("eosquest");
+ break;
+ case '!':
+ xml_insert_entity ("eosexcl");
+ break;
+ }
+ }
+ else
+ {
+ insert_self (arg);
+ }
+}