/* $NetBSD: insertion.c,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $ */ /* insertion.c -- insertions for Texinfo. Id: insertion.c,v 1.55 2004/11/11 18:34:28 karl Exp 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 it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "system.h" #include "cmds.h" #include "defun.h" #include "float.h" #include "html.h" #include "insertion.h" #include "macro.h" #include "makeinfo.h" #include "multi.h" #include "xml.h" /* Must match list in insertion.h. */ static char *insertion_type_names[] = { "cartouche", "copying", "defcv", "deffn", "defivar", "defmac", "defmethod", "defop", "defopt", "defspec", "deftp", "deftypecv", "deftypefn", "deftypefun", "deftypeivar", "deftypemethod", "deftypeop", "deftypevar", "deftypevr", "defun", "defvar", "defvr", "detailmenu", "direntry", "display", "documentdescription", "enumerate", "example", "float", "flushleft", "flushright", "format", "ftable", "group", "ifclear", "ifdocbook", "ifhtml", "ifinfo", "ifnotdocbook", "ifnothtml", "ifnotinfo", "ifnotplaintext", "ifnottex", "ifnotxml", "ifplaintext", "ifset", "iftex", "ifxml", "itemize", "lisp", "menu", "multitable", "quotation", "rawdocbook", "rawhtml", "rawtex", "rawxml", "smalldisplay", "smallexample", "smallformat", "smalllisp", "verbatim", "table", "tex", "vtable", "titlepage", "bad_type" }; /* All nested environments. */ INSERTION_ELT *insertion_stack = NULL; /* How deeply we're nested. */ int insertion_level = 0; /* Set to 1 if we've processed (commentary) text in a @menu that wasn't part of a menu item. */ int had_menu_commentary; /* How to examine menu lines. */ int in_detailmenu = 0; /* Whether to examine menu lines. */ int in_menu = 0; /* Set to 1 if
is written in normal context. Used for menu and itemize. */ int in_paragraph = 0; /* Since an insertion is already in the stack before we reach the switch statement, we cannot use is_in_insertion_of_type (always returns true.) Also making it return the level found, and comparing it with the current level is no use, due to the order of stack. */ static int float_active = 0; /* Unsetting escape_html blindly causes text inside @html/etc. to be escaped if used within a rmacro. */ static int raw_output_block = 0; /* Non-zero if a
\n"); else { /* with close_single_paragraph, we get no blank line above within @copying. */ close_paragraph (); last_char_was_newline = no_indent = 0; indented_fill = filling_enabled = 1; inhibit_paragraph_indentation = 1; } current_indent += default_indentation_increment; if (xml) xml_insert_quotation (insertion_stack->item_function, START); else if (strlen(insertion_stack->item_function)) execute_string ("@b{%s:} ", insertion_stack->item_function); break; case example: case smallexample: case lisp: case smalllisp: in_fixed_width_font++; /* fall through */ /* Like @example but no fixed width font. */ case display: case smalldisplay: /* Like @display but without indentation. */ case smallformat: case format: close_single_paragraph (); inhibit_paragraph_indentation = 1; filling_enabled = 0; last_char_was_newline = 0; if (html) /* Kludge alert: if\n" : "\n"); } /* The ending of one of these insertions always marks the start of a new paragraph, except for the XML output. */ if (!xml || docbook) close_insertion_paragraph (); /* closes paragraph without messing with . */ if (html && type != quotation) paragraph_is_open = 0; break; case table: case ftable: case vtable: current_indent -= default_indentation_increment; if (html) add_html_block_elt ("is followed by a newline, IE3, mozilla, maybe others render an extra blank line before the pre-formatted block. So don't output a newline. */ add_html_block_elt_args ("", command); if (type != format && type != smallformat) { current_indent += example_indentation_increment; if (html) { /* Since we didn't put \n after, we need to insert the indentation by hand. */ int i; for (i = current_indent; i > 0; i--) add_char (' '); } } break; case multitable: do_multitable (); break; case table: case ftable: case vtable: case itemize: close_single_paragraph (); current_indent += default_indentation_increment; filling_enabled = indented_fill = 1; #if defined (INDENT_PARAGRAPHS_IN_TABLE) inhibit_paragraph_indentation = 0; #else inhibit_paragraph_indentation = 1; #endif /* !INDENT_PARAGRAPHS_IN_TABLE */ /* Make things work for losers who forget the itemize syntax. */ if (type == itemize) { if (!(*insertion_stack->item_function)) { free (insertion_stack->item_function); insertion_stack->item_function = xstrdup ("@bullet"); } } if (!*insertion_stack->item_function) { line_error (_("%s requires an argument: the formatter for %citem"), insertion_type_pname (type), COMMAND_PREFIX); } if (html) { if (type == itemize) { add_html_block_elt ("\n"); in_paragraph = 0; } else { /* We are just starting, so this
has no
- children yet. */ html_deflist_has_term = 0; add_html_block_elt ("
\n"); } } if (xml) xml_begin_table (type, insertion_stack->item_function); while (input_text[input_text_offset] == '\n' && input_text[input_text_offset+1] == '\n') { line_number++; input_text_offset++; } break; case enumerate: close_single_paragraph (); no_indent = 0; #if defined (INDENT_PARAGRAPHS_IN_TABLE) inhibit_paragraph_indentation = 0; #else inhibit_paragraph_indentation = 1; #endif /* !INDENT_PARAGRAPHS_IN_TABLE */ current_indent += default_indentation_increment; filling_enabled = indented_fill = 1; if (html) { enum_html (); in_paragraph = 0; } if (xml) xml_begin_enumerate (enumeration_arg); if (isdigit (*enumeration_arg)) start_enumerating (atoi (enumeration_arg), ENUM_DIGITS); else start_enumerating (*enumeration_arg, ENUM_ALPHA); break; /* @group produces no output in info. */ case group: /* Only close the paragraph if we are not inside of an @example-like environment. */ if (xml) xml_insert_element (GROUP, START); else if (!insertion_stack->next || (insertion_stack->next->insertion != display && insertion_stack->next->insertion != smalldisplay && insertion_stack->next->insertion != example && insertion_stack->next->insertion != smallexample && insertion_stack->next->insertion != lisp && insertion_stack->next->insertion != smalllisp && insertion_stack->next->insertion != format && insertion_stack->next->insertion != smallformat && insertion_stack->next->insertion != flushleft && insertion_stack->next->insertion != flushright)) close_single_paragraph (); break; case cartouche: if (html) add_html_block_elt ("
\n"); close_insertion_paragraph (); break; case group: if (!xml || docbook) close_insertion_paragraph (); break; case floatenv: if (xml) xml_insert_element (FLOAT, END); else { if (html) add_html_block_elt ("
\n"); if (in_menu) no_discard++; break; case floatenv: /* Cannot nest floats, so complain. */ if (float_active) { line_error (_("%cfloat environments cannot be nested"), COMMAND_PREFIX); pop_insertion (); break; } float_active++; { /* Collect data about this float. */ /* Example: @float [FLOATTYPE][,XREFLABEL][,POSITION] */ char floattype[200] = ""; char xreflabel[200] = ""; char position[200] = ""; char *text; char *caption; char *shortcaption; int start_of_end; int save_line_number = line_number; int save_input_text_offset = input_text_offset; int i; if (strlen (insertion_stack->item_function) > 0) { int i = 0, t = 0, c = 0; while (insertion_stack->item_function[i]) { if (insertion_stack->item_function[i] == ',') { switch (t) { case 0: floattype[c] = '\0'; break; case 1: xreflabel[c] = '\0'; break; case 2: position[c] = '\0'; break; } c = 0; t++; i++; continue; } switch (t) { case 0: floattype[c] = insertion_stack->item_function[i]; break; case 1: xreflabel[c] = insertion_stack->item_function[i]; break; case 2: position[c] = insertion_stack->item_function[i]; break; } c++; i++; } } skip_whitespace_and_newlines (); start_of_end = get_until ("\n@end float", &text); /* Get also the @caption. */ i = search_forward_until_pos ("\n@caption{", save_input_text_offset, start_of_end); if (i > -1) { input_text_offset = i + sizeof ("\n@caption{") - 1; get_until_in_braces ("\n@end float", &caption); input_text_offset = save_input_text_offset; } else caption = ""; /* ... and the @shortcaption. */ i = search_forward_until_pos ("\n@shortcaption{", save_input_text_offset, start_of_end); if (i > -1) { input_text_offset = i + sizeof ("\n@shortcaption{") - 1; get_until_in_braces ("\n@end float", &shortcaption); input_text_offset = save_input_text_offset; } else shortcaption = ""; canon_white (xreflabel); canon_white (floattype); canon_white (position); canon_white (caption); canon_white (shortcaption); add_new_float (xstrdup (xreflabel), xstrdup (caption), xstrdup (shortcaption), xstrdup (floattype), xstrdup (position)); /* Move to the start of the @float so the contents get processed as usual. */ input_text_offset = save_input_text_offset; line_number = save_line_number; } if (html) add_html_block_elt (" \n"); else if (docbook) xml_insert_element (FLOAT, START); else if (xml) { xml_insert_element_with_attribute (FLOAT, START, "name=\"%s\"", current_float_id ()); xml_insert_element (FLOATTYPE, START); execute_string ("%s", current_float_type ()); xml_insert_element (FLOATTYPE, END); xml_insert_element (FLOATPOS, START); execute_string ("%s", current_float_position ()); xml_insert_element (FLOATPOS, END); } else { /* Info */ close_single_paragraph (); inhibit_paragraph_indentation = 1; } /* Anchor now. Note that XML documents get their anchors withtag. */ if ((!xml || docbook) && strlen (current_float_id ()) > 0) execute_string ("@anchor{%s}", current_float_id ()); break; /* Insertions that are no-ops in info, but do something in TeX. */ case ifclear: case ifdocbook: case ifhtml: case ifinfo: case ifnotdocbook: case ifnothtml: case ifnotinfo: case ifnotplaintext: case ifnottex: case ifnotxml: case ifplaintext: case ifset: case iftex: case ifxml: case rawtex: if (in_menu) no_discard++; break; case rawdocbook: case rawhtml: case rawxml: raw_output_block++; if (raw_output_block > 0) { xml_no_para = 1; escape_html = 0; xml_keep_space++; } { /* Some deuglification for improved readability. */ extern int xml_in_para; if (xml && !xml_in_para && xml_indentation_increment > 0) add_char ('\n'); } break; case defcv: case deffn: case defivar: case defmac: case defmethod: case defop: case defopt: case defspec: case deftp: case deftypecv: case deftypefn: case deftypefun: case deftypeivar: case deftypemethod: case deftypeop: case deftypevar: case deftypevr: case defun: case defvar: case defvr: inhibit_paragraph_indentation = 1; filling_enabled = indented_fill = 1; current_indent += default_indentation_increment; no_indent = 0; if (xml) xml_begin_definition (); break; case flushleft: close_single_paragraph (); inhibit_paragraph_indentation = 1; filling_enabled = indented_fill = no_indent = 0; if (html) add_html_block_elt (" "); break; case flushright: close_single_paragraph (); filling_enabled = indented_fill = no_indent = 0; inhibit_paragraph_indentation = 1; force_flush_right++; if (html) add_html_block_elt (""); break; case titlepage: xml_insert_element (TITLEPAGE, START); break; default: line_error ("begin_insertion internal error: type=%d", type); } if (!no_discard) discard_until ("\n"); } /* Try to end the insertion with the specified TYPE. With a value of `bad_type', TYPE gets translated to match the value currently on top of the stack. Otherwise, if TYPE doesn't match the top of the insertion stack, give error. */ static void end_insertion (int type) { int temp_type; if (!insertion_level) return; temp_type = current_insertion_type (); if (type == bad_type) type = temp_type; if (type != temp_type) { line_error (_("`@end' expected `%s', but saw `%s'"), insertion_type_pname (temp_type), insertion_type_pname (type)); return; } pop_insertion (); if (xml) { switch (type) { case ifinfo: case documentdescription: break; case quotation: xml_insert_quotation ("", END); break; case example: xml_insert_element (EXAMPLE, END); if (docbook && current_insertion_type () == floatenv) xml_insert_element (FLOATEXAMPLE, END); break; case smallexample: xml_insert_element (SMALLEXAMPLE, END); if (docbook && current_insertion_type () == floatenv) xml_insert_element (FLOATEXAMPLE, END); break; case lisp: xml_insert_element (LISP, END); if (docbook && current_insertion_type () == floatenv) xml_insert_element (FLOATEXAMPLE, END); break; case smalllisp: xml_insert_element (SMALLLISP, END); if (docbook && current_insertion_type () == floatenv) xml_insert_element (FLOATEXAMPLE, END); break; case cartouche: xml_insert_element (CARTOUCHE, END); break; case format: if (docbook && xml_in_bookinfo && xml_in_abstract) { xml_insert_element (ABSTRACT, END); xml_in_abstract = 0; } else xml_insert_element (FORMAT, END); break; case smallformat: xml_insert_element (SMALLFORMAT, END); break; case display: xml_insert_element (DISPLAY, END); break; case smalldisplay: xml_insert_element (SMALLDISPLAY, END); break; case table: case ftable: case vtable: case itemize: xml_end_table (type); break; case enumerate: xml_end_enumerate (); break; case group: xml_insert_element (GROUP, END); break; case titlepage: xml_insert_element (TITLEPAGE, END); break; } } switch (type) { /* Insertions which have no effect on paragraph formatting. */ case copying: line_number--; break; case ifclear: case ifdocbook: case ifinfo: case ifhtml: case ifnotdocbook: case ifnothtml: case ifnotinfo: case ifnotplaintext: case ifnottex: case ifnotxml: case ifplaintext: case ifset: case iftex: case ifxml: case rawtex: case titlepage: break; case rawdocbook: case rawhtml: case rawxml: raw_output_block--; if (raw_output_block <= 0) { xml_no_para = 0; escape_html = 1; xml_keep_space--; } if ((xml || html) && output_paragraph[output_paragraph_offset-1] == '\n') output_paragraph_offset--; break; case detailmenu: if (xml) xml_insert_element (DETAILMENU, END); in_detailmenu--; /* No longer hacking menus. */ if (!in_menu) { if (!no_headers) close_insertion_paragraph (); } break; case direntry: /* Eaten if html. */ insert_string ("END-INFO-DIR-ENTRY\n\n"); close_insertion_paragraph (); break; case documentdescription: if (xml) insert_string (document_description); xml_insert_element (DOCUMENTDESCRIPTION, END); break; case menu: in_menu--; /* No longer hacking menus. */ if (html && !no_headers) add_html_block_elt ("\n"); else if (!no_headers && !xml) close_insertion_paragraph (); break; case multitable: end_multitable (); break; case enumerate: stop_enumerating (); close_insertion_paragraph (); current_indent -= default_indentation_increment; if (html) add_html_block_elt ("\n"); break; case flushleft: if (html) add_html_block_elt ("\n"); close_insertion_paragraph (); break; case cartouche: if (html) add_html_block_elt (""); else close_paragraph (); no_indent = 1; /* Legend: 1) @float Foo,lbl & no caption: Foo 1.1 2) @float Foo & no caption: Foo 3) @float ,lbl & no caption: 1.1 4) @float & no caption: */ if (!xml && !html) indent (current_indent); if (strlen (current_float_type ())) execute_string ("%s", current_float_type ()); if (strlen (current_float_id ()) > 0) { if (strlen (current_float_type ()) > 0) add_char (' '); add_word (current_float_number ()); } if (strlen (current_float_title ()) > 0) { if (strlen (current_float_type ()) > 0 || strlen (current_float_id ()) > 0) insert_string (": "); execute_string ("%s", current_float_title ()); } /* Indent the following paragraph. */ inhibit_paragraph_indentation = 0; if (html) add_word ("
\n"); else close_paragraph (); } float_active--; break; case format: case smallformat: case display: case smalldisplay: case example: case smallexample: case lisp: case smalllisp: case quotation: /* @format and @smallformat are the only fixed_width insertion without a change in indentation. */ if (type != format && type != smallformat && type != quotation) current_indent -= example_indentation_increment; else if (type == quotation) current_indent -= default_indentation_increment; if (html) { /* The complex code in close_paragraph that kills whitespace does not function here, since we've inserted non-whitespace (the ) before it. The indentation already got inserted at the end of the last example line, so we have to delete it, or browsers wind up showing an extra blank line. */ kill_self_indent (default_indentation_increment); add_html_block_elt (type == quotation ? "
(don't ask me). So, wipe them out for
cleanliness, and re-insert. */
int i;
kill_self_indent (default_indentation_increment);
add_html_block_elt ("");
for (i = current_indent; i > 0; i--)
add_char (' ');
}
else if (xml)
{
xml_insert_element (VERBATIM, START);
escape_html = 0;
add_word (" sizeof (END_VERBATIM))
&& !strncmp (&input_text[input_text_offset+1], END_VERBATIM,
sizeof (END_VERBATIM)-1))
{
input_text_offset += sizeof (END_VERBATIM);
seen_end = 1;
break;
}
if (html && character == '&' && escape_html)
add_word ("&");
else if (html && character == '<' && escape_html)
add_word ("<");
else
add_char (character);
input_text_offset++;
}
if (find_end_verbatim && !seen_end)
warning (_("end of file inside verbatim block"));
if (html)
{ /* See comments in example case above. */
kill_self_indent (default_indentation_increment);
add_word ("");
}
else if (xml)
{
add_word ("]]>");
xml_insert_element (VERBATIM, END);
escape_html = save_escape_html;
}
in_fixed_width_font--;
filling_enabled = save_filling_enabled;
inhibit_paragraph_indentation = save_inhibit_paragraph_indentation;
}
void
cm_verbatim (void)
{
handle_verbatim_environment (1);
}
void
cm_table (void)
{
begin_insertion (table);
}
void
cm_multitable (void)
{
begin_insertion (multitable); /* @@ */
}
void
cm_ftable (void)
{
begin_insertion (ftable);
}
void
cm_vtable (void)
{
begin_insertion (vtable);
}
void
cm_group (void)
{
begin_insertion (group);
}
/* Insert raw HTML (no escaping of `<' etc.). */
void
cm_html (int arg)
{
if (process_html)
begin_insertion (rawhtml);
else
command_name_condition ();
}
void
cm_xml (int arg)
{
if (process_xml)
begin_insertion (rawxml);
else
command_name_condition ();
}
void
cm_docbook (int arg)
{
if (process_docbook)
begin_insertion (rawdocbook);
else
command_name_condition ();
}
void
cm_ifdocbook (void)
{
if (process_docbook)
begin_insertion (ifdocbook);
else
command_name_condition ();
}
void
cm_ifnotdocbook (void)
{
if (!process_docbook)
begin_insertion (ifnotdocbook);
else
command_name_condition ();
}
void
cm_ifhtml (void)
{
if (process_html)
begin_insertion (ifhtml);
else
command_name_condition ();
}
void
cm_ifnothtml (void)
{
if (!process_html)
begin_insertion (ifnothtml);
else
command_name_condition ();
}
void
cm_ifinfo (void)
{
if (process_info)
begin_insertion (ifinfo);
else
command_name_condition ();
}
void
cm_ifnotinfo (void)
{
if (!process_info)
begin_insertion (ifnotinfo);
else
command_name_condition ();
}
void
cm_ifplaintext (void)
{
if (process_plaintext)
begin_insertion (ifplaintext);
else
command_name_condition ();
}
void
cm_ifnotplaintext (void)
{
if (!process_plaintext)
begin_insertion (ifnotplaintext);
else
command_name_condition ();
}
void
cm_tex (void)
{
if (process_tex)
begin_insertion (rawtex);
else
command_name_condition ();
}
void
cm_iftex (void)
{
if (process_tex)
begin_insertion (iftex);
else
command_name_condition ();
}
void
cm_ifnottex (void)
{
if (!process_tex)
begin_insertion (ifnottex);
else
command_name_condition ();
}
void
cm_ifxml (void)
{
if (process_xml)
begin_insertion (ifxml);
else
command_name_condition ();
}
void
cm_ifnotxml (void)
{
if (!process_xml)
begin_insertion (ifnotxml);
else
command_name_condition ();
}
/* Generic xrefable block with a caption. */
void
cm_float (void)
{
begin_insertion (floatenv);
}
void
cm_caption (int arg)
{
char *temp;
/* This is a no_op command for most formats, as we handle it during @float
insertion. For XML though, we handle it here to keep document structure
as close as possible, to the Texinfo source. */
/* Everything is already handled at START. */
if (arg == END)
return;
/* Check if it's mislocated. */
if (current_insertion_type () != floatenv)
line_error (_("@%s not meaningful outside `@float' environment"), command);
get_until_in_braces ("\n@end float", &temp);
if (xml)
{
int elt = STREQ (command, "shortcaption") ? SHORTCAPTION : CAPTION;
xml_insert_element (elt, START);
if (!docbook)
execute_string ("%s", temp);
xml_insert_element (elt, END);
}
free (temp);
}
/* Begin an insertion where the lines are not filled or indented. */
void
cm_flushleft (void)
{
begin_insertion (flushleft);
}
/* Begin an insertion where the lines are not filled, and each line is
forced to the right-hand side of the page. */
void
cm_flushright (void)
{
begin_insertion (flushright);
}
void
cm_menu (void)
{
if (current_node == NULL && !macro_expansion_output_stream)
{
warning (_("@menu seen before first @node, creating `Top' node"));
warning (_("perhaps your @top node should be wrapped in @ifnottex rather than @ifinfo?"));
/* Include @top command so we can construct the implicit node tree. */
execute_string ("@node top\n@top Top\n");
}
begin_insertion (menu);
}
void
cm_detailmenu (void)
{
if (current_node == NULL && !macro_expansion_output_stream)
{ /* Problems anyway, @detailmenu should always be inside @menu. */
warning (_("@detailmenu seen before first node, creating `Top' node"));
execute_string ("@node top\n@top Top\n");
}
begin_insertion (detailmenu);
}
/* Title page commands. */
void
cm_titlepage (void)
{
titlepage_cmd_present = 1;
if (xml && !docbook)
begin_insertion (titlepage);
else
command_name_condition ();
}
void
cm_author (void)
{
char *rest;
get_rest_of_line (1, &rest);
if (is_in_insertion_of_type (quotation))
{
if (html)
add_word_args ("— %s", rest);
else if (docbook)
{
/* FIXME Ideally, we should use an attribution element,
but they are supposed to be at the start of quotation
blocks. So to avoid looking ahead mess, let's just
use mdash like HTML for now. */
xml_insert_entity ("mdash");
add_word (rest);
}
else if (xml)
{
xml_insert_element (AUTHOR, START);
add_word (rest);
xml_insert_element (AUTHOR, END);
}
else
add_word_args ("-- %s", rest);
}
else if (is_in_insertion_of_type (titlepage))
{
if (xml && !docbook)
{
xml_insert_element (AUTHOR, START);
add_word (rest);
xml_insert_element (AUTHOR, END);
}
}
else
line_error (_("@%s not meaningful outside `@titlepage' and `@quotation' environments"),
command);
free (rest);
}
void
cm_titlepage_cmds (void)
{
char *rest;
get_rest_of_line (1, &rest);
if (!is_in_insertion_of_type (titlepage))
line_error (_("@%s not meaningful outside `@titlepage' environment"),
command);
if (xml && !docbook)
{
int elt = 0;
if (STREQ (command, "title"))
elt = BOOKTITLE;
else if (STREQ (command, "subtitle"))
elt = BOOKSUBTITLE;
xml_insert_element (elt, START);
add_word (rest);
xml_insert_element (elt, END);
}
free (rest);
}
/* End existing insertion block. */
void
cm_end (void)
{
char *temp;
int type;
get_rest_of_line (0, &temp);
if (!insertion_level)
{
line_error (_("Unmatched `%c%s'"), COMMAND_PREFIX, command);
return;
}
if (temp[0] == 0)
line_error (_("`%c%s' needs something after it"), COMMAND_PREFIX, command);
type = find_type_from_name (temp);
if (type == bad_type)
{
line_error (_("Bad argument `%s' to `@%s', using `%s'"),
temp, command, insertion_type_pname (current_insertion_type ()));
}
if (xml && type == menu) /* fixme */
{
xml_end_menu ();
}
end_insertion (type);
free (temp);
}
/* @itemx, @item. */
static int itemx_flag = 0;
/* Return whether CMD takes a brace-delimited {arg}. */
int
command_needs_braces (char *cmd)
{
int i;
for (i = 0; command_table[i].name; i++)
{
if (STREQ (command_table[i].name, cmd))
return command_table[i].argument_in_braces == BRACE_ARGS;
}
return 0; /* macro or alias */
}
void
cm_item (void)
{
char *rest_of_line, *item_func;
/* Can only hack "@item" while inside of an insertion. */
if (insertion_level)
{
INSERTION_ELT *stack = insertion_stack;
int original_input_text_offset;
skip_whitespace ();
original_input_text_offset = input_text_offset;
get_rest_of_line (0, &rest_of_line);
item_func = current_item_function ();
/* Do the right thing depending on which insertion function is active. */
switch_top:
switch (stack->insertion)
{
case multitable:
multitable_item ();
/* Support text directly after the @item. */
if (*rest_of_line)
{
line_number--;
input_text_offset = original_input_text_offset;
}
break;
case ifclear:
case ifhtml:
case ifinfo:
case ifnothtml:
case ifnotinfo:
case ifnotplaintext:
case ifnottex:
case ifnotxml:
case ifplaintext:
case ifset:
case iftex:
case ifxml:
case rawdocbook:
case rawhtml:
case rawxml:
case rawtex:
case tex:
case cartouche:
stack = stack->next;
if (!stack)
goto no_insertion;
else
goto switch_top;
break;
case menu:
case quotation:
case example:
case smallexample:
case lisp:
case smalllisp:
case format:
case smallformat:
case display:
case smalldisplay:
case group:
line_error (_("@%s not meaningful inside `@%s' block"),
command,
insertion_type_pname (current_insertion_type ()));
break;
case itemize:
case enumerate:
if (itemx_flag)
{
line_error (_("@itemx not meaningful inside `%s' block"),
insertion_type_pname (current_insertion_type ()));
}
else
{
if (html)
add_html_block_elt ("