summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/makeinfo/cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/texinfo/makeinfo/cmds.c')
-rw-r--r--contrib/texinfo/makeinfo/cmds.c351
1 files changed, 297 insertions, 54 deletions
diff --git a/contrib/texinfo/makeinfo/cmds.c b/contrib/texinfo/makeinfo/cmds.c
index 65d382e..968bc8f 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.57 1999/09/19 16:39:35 karl Exp $
+ $Id: cmds.c,v 1.69 2002/02/09 00:54:51 karl Exp $
- Copyright (C) 1998, 99 Free Software Foundation, Inc.
+ Copyright (C) 1998, 99, 2000, 01 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
@@ -29,6 +29,7 @@
#include "node.h"
#include "sectioning.h"
#include "toc.h"
+#include "xml.h"
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
@@ -45,7 +46,8 @@ void
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_strong (), cm_var (), cm_sc (), cm_w (), cm_email (), cm_url (),
+ cm_verb (), cm_documentdescription ();
void
cm_anchor (), cm_node (), cm_menu (), cm_xref (), cm_ftable (),
@@ -61,7 +63,8 @@ void
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_tt ();
+ cm_multitable (), cm_settitle (), cm_titlefont (), cm_tt (),
+ cm_verbatim (), cm_verbatiminclude (), cm_titlepage ();
/* Conditionals. */
void cm_set (), cm_clear (), cm_ifset (), cm_ifclear ();
@@ -80,7 +83,7 @@ static const char small_tag[] = "small";
COMMAND command_table[] = {
{ "\t", insert_space, NO_BRACE_ARGS },
{ "\n", insert_space, NO_BRACE_ARGS },
- { " ", insert_self, NO_BRACE_ARGS },
+ { " ", insert_space, NO_BRACE_ARGS },
{ "!", insert_self, NO_BRACE_ARGS },
{ "\"", cm_accent_umlaut, MAYBE_BRACE_ARGS },
{ "'", cm_accent_acute, MAYBE_BRACE_ARGS },
@@ -108,7 +111,10 @@ COMMAND command_table[] = {
{ "aa", cm_special_char, BRACE_ARGS },
{ "acronym", cm_acronym, BRACE_ARGS },
{ "ae", cm_special_char, BRACE_ARGS },
+ { "afivepaper", cm_ignore_line, NO_BRACE_ARGS },
+ { "afourlatex", cm_ignore_line, NO_BRACE_ARGS },
{ "afourpaper", cm_ignore_line, NO_BRACE_ARGS },
+ { "afourwide", cm_ignore_line, NO_BRACE_ARGS },
{ "alias", cm_alias, NO_BRACE_ARGS },
{ "anchor", cm_anchor, BRACE_ARGS },
{ "appendix", cm_appendix, NO_BRACE_ARGS },
@@ -182,6 +188,7 @@ COMMAND command_table[] = {
{ "direntry", cm_direntry, NO_BRACE_ARGS },
{ "display", cm_display, NO_BRACE_ARGS },
{ "dmn", cm_no_op, BRACE_ARGS },
+ { "documentdescription", cm_documentdescription, NO_BRACE_ARGS },
{ "documentencoding", cm_documentencoding, NO_BRACE_ARGS },
{ "documentlanguage", cm_documentlanguage, NO_BRACE_ARGS },
{ "dotaccent", cm_accent, MAYBE_BRACE_ARGS },
@@ -294,7 +301,7 @@ COMMAND command_table[] = {
{ "subsection", cm_subsection, NO_BRACE_ARGS },
{ "subsubheading", cm_subsubheading, NO_BRACE_ARGS },
{ "subsubsection", cm_subsubsection, NO_BRACE_ARGS },
- { "summarycontents", cm_no_op, NO_BRACE_ARGS },
+ { "summarycontents", cm_shortcontents, NO_BRACE_ARGS },
{ "syncodeindex", cm_synindex, NO_BRACE_ARGS },
{ "synindex", cm_synindex, NO_BRACE_ARGS },
{ "t", cm_tt, BRACE_ARGS },
@@ -320,6 +327,9 @@ COMMAND command_table[] = {
{ "v", cm_accent, MAYBE_BRACE_ARGS },
{ "value", cm_value, BRACE_ARGS },
{ "var", cm_var, BRACE_ARGS },
+ { "verb", cm_verb, NO_BRACE_ARGS },
+ { "verbatim", cm_verbatim, NO_BRACE_ARGS },
+ { "verbatiminclude", cm_verbatiminclude, NO_BRACE_ARGS },
{ "vindex", cm_vindex, NO_BRACE_ARGS },
{ "vtable", cm_vtable, NO_BRACE_ARGS },
{ "w", cm_w, BRACE_ARGS },
@@ -363,7 +373,12 @@ insert_space (arg)
int arg;
{
if (arg == START)
- add_char (' ');
+ {
+ if (xml && !docbook)
+ xml_insert_entity ("space");
+ else
+ add_char (' ');
+ }
}
/* Force a line break in the output. */
@@ -372,6 +387,10 @@ cm_asterisk ()
{
if (html)
add_word ("<br>");
+ else if (xml && !docbook)
+ xml_insert_entity ("linebreak");
+ else if (docbook)
+ xml_asterisk ();
else
{
close_single_paragraph ();
@@ -385,7 +404,14 @@ cm_dots (arg)
int arg;
{
if (arg == START)
- add_word (html ? "<small>...</small>" : "...");
+ {
+ if (xml && !docbook)
+ xml_insert_entity ("dots");
+ else if (docbook)
+ xml_insert_entity ("hellip");
+ else
+ add_word (html ? "<small>...</small>" : "...");
+ }
}
/* Insert ellipsis for sentence end. */
@@ -394,7 +420,17 @@ cm_enddots (arg)
int arg;
{
if (arg == START)
- add_word (html ? "<small>...</small>." : "....");
+ {
+ if (xml && !docbook)
+ xml_insert_entity ("enddots");
+ else if (docbook)
+ {
+ xml_insert_entity ("hellip");
+ add_char ('.');
+ }
+ else
+ add_word (html ? "<small>...</small>." : "....");
+ }
}
void
@@ -405,6 +441,10 @@ cm_bullet (arg)
{
if (html)
add_word ("&#149;");
+ else if (xml && !docbook)
+ xml_insert_entity ("bullet");
+ else if (docbook)
+ xml_insert_entity ("bull");
else
add_char ('*');
}
@@ -415,7 +455,12 @@ cm_minus (arg)
int arg;
{
if (arg == START)
- add_char ('-');
+ {
+ if (xml)
+ xml_insert_entity ("minus");
+ else
+ add_char ('-');
+ }
}
/* Insert "TeX". */
@@ -424,7 +469,12 @@ cm_TeX (arg)
int arg;
{
if (arg == START)
- add_word ("TeX");
+ {
+ if (xml && ! docbook)
+ xml_insert_entity ("tex");
+ else
+ add_word ("TeX");
+ }
}
/* Copyright symbol. */
@@ -433,10 +483,16 @@ cm_copyright (arg)
int arg;
{
if (arg == START)
+ {
if (html)
add_word ("&copy;");
+ else if (xml && !docbook)
+ xml_insert_entity ("copyright");
+ else if (docbook)
+ xml_insert_entity ("copy");
else
add_word ("(C)");
+ }
}
void
@@ -462,6 +518,8 @@ cm_acronym (arg)
{
if (html)
insert_html_tag (arg, small_tag);
+ else if (xml)
+ xml_insert_element (ACRONYM, arg);
}
void
@@ -471,12 +529,18 @@ cm_tt (arg)
/* @t{} is a no-op in Info. */
if (html)
insert_html_tag (arg, "tt");
+ else if (xml)
+ xml_insert_element (TT, arg);
}
void
cm_code (arg)
int arg;
{
+ if (xml)
+ xml_insert_element (CODE, arg);
+ else
+ {
extern int printing_index;
if (arg == START)
@@ -495,13 +559,16 @@ cm_code (arg)
if (!printing_index)
add_meta_char ('\'');
}
+ }
}
void
cm_kbd (arg)
int arg;
{
- if (html)
+ if (xml)
+ xml_insert_element (KBD, arg);
+ else if (html)
{ /* Seems like we should increment in_fixed_width_font for Info
format too, but then the quote-omitting special case gets
confused. Punt. */
@@ -520,7 +587,9 @@ cm_kbd (arg)
void
cm_url (arg, start, end)
{
- if (html)
+ if (xml)
+ xml_insert_element (URL, arg);
+ else if (html)
{
if (arg == START)
add_word ("&lt;<code>");
@@ -538,7 +607,9 @@ void
cm_key (arg)
int arg;
{
- if (html)
+ if (xml)
+ xml_insert_element (KEY, arg);
+ else if (html)
add_word (arg == START ? "&lt;" : "&gt;");
else
add_char (arg == START ? '<' : '>');
@@ -558,6 +629,10 @@ void
cm_var (arg, start_pos, end_pos)
int arg, start_pos, end_pos;
{
+ if (xml)
+ xml_insert_element (VAR, arg);
+ else
+ {
not_fixed_width (arg);
if (html)
@@ -573,12 +648,17 @@ cm_var (arg, start_pos, end_pos)
start_pos++;
}
}
+ }
}
void
cm_sc (arg, start_pos, end_pos)
int arg, start_pos, end_pos;
{
+ if (xml)
+ xml_insert_element (SC, arg);
+ else
+ {
not_fixed_width (arg);
if (arg == START)
@@ -588,11 +668,15 @@ cm_sc (arg, start_pos, end_pos)
}
else
{
- int all_upper = 1;
+ int all_upper;
if (html)
start_pos += sizeof (small_tag) + 2 - 1; /* skip <small> */
+ /* 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];
@@ -607,35 +691,111 @@ cm_sc (arg, start_pos, end_pos)
if (html)
insert_html_tag (arg, small_tag);
}
+ }
}
void
cm_dfn (arg, position)
int arg, position;
{
+ if (xml)
+ xml_insert_element (DFN, arg);
+ else
+ {
if (html)
insert_html_tag (arg, "dfn");
else if (arg == START)
add_char ('"');
else
add_meta_char ('"');
+ }
}
void
cm_emph (arg)
int arg;
{
- if (html)
+ if (xml)
+ xml_insert_element (EMPH, arg);
+ else if (html)
insert_html_tag (arg, "em");
else
add_char ('_');
}
void
+cm_verb (arg)
+ int arg;
+{
+ int character;
+ int delimiter;
+ int seen_end = 0;
+
+ in_fixed_width_font++;
+ /* are these necessary ? */
+ last_char_was_newline = 0;
+
+ if (html)
+ add_word ("<pre>");
+
+ if (input_text_offset < input_text_length)
+ {
+ character = curchar ();
+ if (character == '{')
+ input_text_offset++;
+ else
+ line_error (_("`{' expected, but saw `%c'"), character);
+ }
+
+ if (input_text_offset < input_text_length)
+ {
+ delimiter = curchar ();
+ input_text_offset++;
+ }
+
+ while (input_text_offset < input_text_length)
+ {
+ character = curchar ();
+
+ if (character == '\n')
+ line_number++;
+ /*
+ Assume no newlines in END_VERBATIM
+ */
+ else if (character == delimiter)
+ {
+ seen_end = 1;
+ input_text_offset++;
+ break;
+ }
+
+ add_char (character);
+ input_text_offset++;
+ }
+
+ if (!seen_end)
+ warning (_("end of file inside verb block"));
+
+ if (input_text_offset < input_text_length)
+ {
+ character = curchar ();
+ if (character == '}')
+ input_text_offset++;
+ else
+ line_error (_("`}' expected, but saw `%c'"), character);
+ }
+
+ if (html)
+ add_word ("</pre>");
+}
+
+void
cm_strong (arg, position)
int arg, position;
{
- if (html)
+ if (xml)
+ xml_insert_element (STRONG, arg);
+ else if (html)
insert_html_tag (arg, "strong");
else
add_char ('*');
@@ -645,7 +805,9 @@ void
cm_cite (arg, position)
int arg, position;
{
- if (html)
+ if (xml)
+ xml_insert_element (CITE, arg);
+ else if (html)
insert_html_tag (arg, "cite");
else
{
@@ -661,6 +823,8 @@ void
cm_not_fixed_width (arg, start, end)
int arg, start, end;
{
+ if (xml)
+ xml_insert_element (NOTFIXEDWIDTH, arg);
not_fixed_width (arg);
}
@@ -668,7 +832,9 @@ void
cm_i (arg)
int arg;
{
- if (html)
+ if (xml)
+ xml_insert_element (I, arg);
+ else if (html)
insert_html_tag (arg, "i");
else
not_fixed_width (arg);
@@ -678,7 +844,9 @@ void
cm_b (arg)
int arg;
{
- if (html)
+ if (xml)
+ xml_insert_element (B, arg);
+ else if (html)
insert_html_tag (arg, "b");
else
not_fixed_width (arg);
@@ -688,32 +856,40 @@ void
cm_r (arg)
int arg;
{
- extern int printing_index;
-
- /* People use @r{} in index entries like this:
-
- @findex foo@r{, some text}
-
- This is supposed to produce output as if the entry were saying
- "@code{foo}, some text", since the "fn" index is typeset as
- @code. The following attempts to do the same in HTML. Note that
- this relies on the fact that only @code bumps up the variable
- in_fixed_width_font while processing index entries in HTML mode. */
- if (html && printing_index)
+ if (xml)
+ xml_insert_element (R, arg);
+ else
{
- int level = in_fixed_width_font;
+ extern int printing_index;
- while (level--)
- insert_html_tag (arg == START ? END : START, "code");
+ /* People use @r{} in index entries like this:
+
+ @findex foo@r{, some text}
+
+ This is supposed to produce output as if the entry were saying
+ "@code{foo}, some text", since the "fn" index is typeset as
+ @code. The following attempts to do the same in HTML. Note that
+ this relies on the fact that only @code bumps up the variable
+ in_fixed_width_font while processing index entries in HTML mode. */
+ if (html && printing_index)
+ {
+ int level = in_fixed_width_font;
+
+ while (level--)
+ insert_html_tag (arg == START ? END : START, "code");
+ }
+
+ not_fixed_width (arg);
}
-
- not_fixed_width (arg);
}
void
cm_titlefont (arg)
int arg;
{
+ if (xml)
+ xml_insert_element (TITLEFONT, arg);
+ else
not_fixed_width (arg);
}
@@ -776,15 +952,27 @@ cm_setfilename ()
char *filename;
get_rest_of_line (1, &filename);
/* warning ("`@%s %s' encountered and ignored", command, filename); */
+ if (xml)
+ add_word_args ("<setfilename>%s</setfilename>", filename);
free (filename);
}
void
cm_settitle ()
{
- get_rest_of_line (0, &title);
+ if (xml)
+ {
+ xml_begin_document ();
+ xml_insert_element (SETTITLE, START);
+ get_rest_of_line (0, &title);
+ execute_string ("%s", title);
+ xml_insert_element (SETTITLE, END);
+ }
+ else
+ get_rest_of_line (0, &title);
}
+
/* Ignore argument in braces. */
void
cm_ignore_arg (arg, start_pos, end_pos)
@@ -813,7 +1001,16 @@ cm_sp ()
if (sscanf (line, "%d", &lines) != 1 || lines <= 0)
line_error (_("@sp requires a positive numeric argument, not `%s'"), line);
else
- { /* Must disable filling since otherwise multiple newlines is like
+ {
+ if (xml)
+ {
+ xml_insert_element_with_attribute (SP, START, "lines=\"%s\"", line);
+ /* insert_string (line);*/
+ xml_insert_element (SP, END);
+ }
+ 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;
@@ -821,6 +1018,9 @@ cm_sp ()
close_paragraph ();
+ if (lines && html && !executing_string)
+ html_output_head ();
+
while (lines--)
{
if (html)
@@ -831,6 +1031,7 @@ cm_sp ()
filling_enabled = save_filling_enabled;
}
+ }
free (line);
}
@@ -840,8 +1041,16 @@ cm_dircategory ()
{
char *line;
- if (html)
+ if (html || docbook)
cm_ignore_line ();
+ else if (xml)
+ {
+ xml_insert_element (DIRCATEGORY, START);
+ get_rest_of_line (1, &line);
+ insert_string (line);
+ free (line);
+ xml_insert_element (DIRCATEGORY, END);
+ }
else
{
get_rest_of_line (1, &line);
@@ -860,23 +1069,33 @@ cm_dircategory ()
/* Start a new line with just this text on it.
Then center the line of text.
- This always ends the current paragraph. */
+ */
void
cm_center ()
{
+ if (xml)
+ {
+ unsigned char *line;
+ xml_insert_element (CENTER, START);
+ get_rest_of_line (0, (char **)&line);
+ execute_string ("%s", (char *)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;
- close_paragraph ();
filling_enabled = indented_fill = 0;
cm_noindent ();
start = output_paragraph_offset;
if (html)
- add_word ("<p align=\"center\">");
+ add_word ("<div align=\"center\">");
inhibit_output_flushing ();
get_rest_of_line (0, (char **)&line);
@@ -884,7 +1103,7 @@ cm_center ()
free (line);
uninhibit_output_flushing ();
if (html)
- add_word ("</p>");
+ add_word ("</div>");
else
{
@@ -914,9 +1133,9 @@ cm_center ()
}
insert ('\n');
- close_paragraph ();
filling_enabled = save_filling_enabled;
indented_fill = save_indented_fill;
+ }
}
/* Show what an expression returns. */
@@ -1012,10 +1231,14 @@ cm_exdent ()
in_fixed_width_font = save_in_fixed_width_font;
}
-
-/* Remember this file, and move onto the next. */
-void
-cm_include ()
+/*
+ Read include-filename, process the include-file:
+ verbatim_include == 0: process through reader_loop
+ verbatim_include != 0: process through handle_verbatim_environment
+ */
+static void
+handle_include (verbatim_include)
+ int verbatim_include;
{
char *filename;
@@ -1041,7 +1264,7 @@ cm_include ()
i *= 2;
printf ("%*s", i, "");
- printf ("%c%s %s\n", COMMAND_PREFIX, command, filename);
+ printf ("%c%s `%s'\n", COMMAND_PREFIX, command, filename);
fflush (stdout);
}
@@ -1052,8 +1275,8 @@ cm_include ()
popfile ();
line_number--;
- /* Cannot "@include foo", in line 5 of "/wh/bar". */
- line_error ("%c%s %s: %s", COMMAND_PREFIX, command, filename,
+ /* /wh/bar:5: @include/@verbatiminclude `foo': No such file or dir */
+ line_error ("%c%s `%s': %s", COMMAND_PREFIX, command, filename,
strerror (errno));
free (filename);
@@ -1062,14 +1285,34 @@ cm_include ()
else
{
if (macro_expansion_output_stream && !executing_string)
- remember_itext (input_text, input_text_offset);
- reader_loop ();
+ remember_itext (input_text, input_text_offset);
+
+ if (!verbatim_include)
+ reader_loop ();
+ else
+ handle_verbatim_environment (0);
}
free (filename);
popfile ();
}
+/* Include file as if put in @verbatim environment */
+void
+cm_verbatiminclude ()
+{
+ handle_include (1);
+}
+
+
+/* Remember this file, and move onto the next. */
+void
+cm_include ()
+{
+ handle_include (0);
+}
+
+
/* @bye: Signals end of processing. Easy to make this happen. */
void
OpenPOWER on IntegriCloud