summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/texinfo/makeinfo
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2002-06-10 13:21:50 +0000
committerMarc Espie <espie@cvs.openbsd.org>2002-06-10 13:21:50 +0000
commit0766fc34a2525ed5b1d084ea33b198382d10e7d5 (patch)
tree416bbb9ee74fd1267a31ae8f52a3127d1815f23f /gnu/usr.bin/texinfo/makeinfo
parente9d84711c304eca76d998c83ddae54ec5ec7e5fb (diff)
TeXinfo 4.2, much more robust html (and other formats) output, and a few
features that new FSF programs will need (e.g., gcc snapshots). looked at by fgs@, thanks.
Diffstat (limited to 'gnu/usr.bin/texinfo/makeinfo')
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/docbook.c492
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/docbook.h81
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/accent33
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/accent-text.txi64
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/accent.txi10
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/accentenc19
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/accentenc.txi11
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc12
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc.txi14
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/macro-at7
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/tests/macro-at.txi38
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/texinfo.dtd337
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/texinfo.xsl242
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/xml.c1430
-rw-r--r--gnu/usr.bin/texinfo/makeinfo/xml.h81
15 files changed, 2871 insertions, 0 deletions
diff --git a/gnu/usr.bin/texinfo/makeinfo/docbook.c b/gnu/usr.bin/texinfo/makeinfo/docbook.c
new file mode 100644
index 00000000000..7301341e2f5
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/docbook.c
@@ -0,0 +1,492 @@
+/* docbook.c -- docbook output.
+ $Id: docbook.c,v 1.1 2002/06/10 13:21:15 espie Exp $
+
+ Copyright (C) 2001 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 "docbook.h"
+#include "insertion.h"
+#include "lang.h"
+#include "makeinfo.h"
+#include "macro.h"
+#include "sectioning.h"
+
+int docbook_version_inserted = 0;
+int docbook_first_chapter_found = 0;
+int docbook_must_insert_node_anchor = 0;
+int docbook_begin_book_p = 0;
+int docbook_no_new_paragraph = 0;
+
+static int section_level = -1;
+static int in_docbook_paragraph = 0;
+static int in_list = 0;
+
+static int in_table = 0;
+static int in_term = 0;
+static int in_entry = 0;
+static int in_varlistitem = 0;
+
+static int in_example = 0;
+
+void
+docbook_begin_section (level, cmd)
+ int level;
+ char *cmd;
+{
+ int i, old_no_indent;
+ char *temp, *tem;
+ static char *last_chap = NULL;
+
+ close_paragraph ();
+ docbook_first_chapter_found = 1;
+ filling_enabled = indented_fill = 0;
+ old_no_indent = no_indent;
+ no_indent = 1;
+
+ if (!docbook_begin_book_p)
+ docbook_begin_book ();
+
+ if (macro_expansion_output_stream && !executing_string)
+ append_to_expansion_output (input_text_offset + 1);
+
+ get_rest_of_line (0, &temp);
+
+ if (in_docbook_paragraph)
+ {
+ insert_string ("\n</para>\n\n");
+ adjust_braces_following (0, 10);
+ }
+ in_docbook_paragraph = 0;
+ docbook_no_new_paragraph++;
+
+ if (level > section_level + 1)
+ level = section_level + 1;
+
+ for (i = section_level; i >= level ; i--)
+ {
+ if (i == 0)
+ {
+ if (last_chap && strcmp(last_chap, "appendix") == 0)
+ add_word ("</appendix>\n\n");
+ else
+ add_word ("</chapter>\n\n");
+ }
+ else
+ add_word_args ("</sect%d>\n\n", i);
+ }
+
+ section_level = level;
+
+ if (level == 0)
+ {
+ if (strcmp(cmd, "appendix") == 0)
+ add_word ("<appendix");
+ else
+ add_word ("<chapter");
+ last_chap = cmd;
+ }
+ else
+ add_word_args ("<sect%d", level);
+
+ if (docbook_must_insert_node_anchor)
+ {
+ add_word (" id=\"");
+ tem = expansion (current_node, 0);
+ add_escaped_anchor_name (tem, 0);
+ free (tem);
+ add_word ("\"");
+ docbook_must_insert_node_anchor = 0;
+ }
+ add_word (">\n");
+ add_word ("<title>");
+
+ if (macro_expansion_output_stream && !executing_string)
+ {
+ char *temp1 = xmalloc (2 + strlen (temp));
+ sprintf (temp1, "%s", temp);
+ remember_itext (input_text, input_text_offset);
+ me_execute_string (temp1);
+ free (temp1);
+ }
+ else
+ execute_string ("%s", temp);
+
+ free (temp);
+
+ add_word ("</title>\n");
+
+ close_paragraph ();
+ filling_enabled = 1;
+ no_indent = old_no_indent;
+ docbook_no_new_paragraph--;
+ insert_string("\n<para>");
+ in_docbook_paragraph = 1;
+}
+
+void
+docbook_begin_paragraph ()
+{
+ if (!docbook_first_chapter_found)
+ return;
+
+ if (in_example)
+ return;
+
+ if (in_table && !in_term)
+ {
+ if (!in_varlistitem)
+ insert_string ("\n<listitem><para>\n");
+ else
+ insert_string ("\n</para>\n\n<para>\n");
+ in_varlistitem = 1;
+
+ return;
+ }
+ if (in_list)
+ return;
+ if (in_docbook_paragraph)
+ {
+ insert_string ("\n</para>\n\n");
+ adjust_braces_following (0, 10);
+ }
+
+#if 0
+ if (docbook_must_insert_node_anchor)
+ {
+ char *tem;
+ insert_string ("<para id=\"");
+ adjust_braces_following (0, 10);
+ tem = expansion (current_node, 0);
+ add_escaped_anchor_name (tem, 0);
+ free (tem);
+ add_word ("\">\n");
+ docbook_must_insert_node_anchor = 0;
+ }
+ else
+#endif
+ {
+ insert_string ("<para>\n");
+ adjust_braces_following (0, 7);
+ }
+ in_docbook_paragraph = 1;
+}
+
+void
+docbook_begin_book ()
+{
+ if (!docbook_begin_book_p)
+ docbook_begin_book_p = 1;
+ else
+ return;
+
+ ++docbook_no_new_paragraph;
+ add_word_args ("<!DOCTYPE book PUBLIC \"-//Davenport//DTD DocBook V3.0//EN\">\n\
+<book>\n<title>%s</title>\n", title);
+ --docbook_no_new_paragraph;
+}
+
+void
+docbook_end_book ()
+{
+ int i;
+ if (in_docbook_paragraph)
+ {
+ insert_string ("\n</para>\n\n");
+ }
+
+ for (i = section_level; i >= 0 ; i--)
+ {
+ if (i == 0)
+ add_word ("</chapter>\n");
+ else
+ add_word_args ("</sect%d>\n", i);
+ }
+
+ add_word ("</book>\n");
+}
+
+void
+docbook_insert_tag (start_or_end, tag)
+ int start_or_end;
+ char *tag;
+{
+ if (!paragraph_is_open && start_or_end == START)
+ docbook_begin_paragraph ();
+
+ add_char ('<');
+ if (start_or_end == START)
+ add_word (tag);
+ else
+ {
+ add_char ('/');
+ for (; *tag && *tag != ' '; tag++)
+ add_char(*tag);
+ }
+ add_meta_char ('>');
+}
+
+void
+docbook_xref1 (node_name)
+ char *node_name;
+{
+ char *tem;
+ add_word ("<xref linkend=\"");
+ tem = expansion (node_name, 0);
+ add_escaped_anchor_name (tem, 1);
+ free (tem);
+ add_word ("\"/>");
+}
+
+void
+docbook_xref2 (node_name, ref_name)
+ char *node_name;
+ char *ref_name;
+{
+ char *tem;
+ add_word ("<xref linkend=\"");
+ tem = expansion (node_name, 0);
+ add_escaped_anchor_name (tem, 1);
+ free (tem);
+ add_word ("\"/>");
+}
+
+int
+docbook_quote (character)
+ int character;
+{
+ switch (language_code)
+ {
+ case fr:
+ if (character == '`')
+ {
+ add_word ("«&nbsp");
+ return ';';
+ }
+ else
+ {
+ add_word ("&nbsp;");
+ return '»';
+ }
+ break;
+
+ default:
+ if (character == '`')
+ {
+ add_word ("&ldquo");
+ return ';';
+ }
+ else
+ {
+ add_word ("&rdquo");
+ return ';';
+ }
+ break;
+ }
+}
+
+#define IS_BLANK(c) (c == ' ' || c == '\t' || c == '\n')
+
+int
+docbook_is_punctuation (character, next)
+ int character;
+ int next;
+{
+ return ( (character == ';'
+ || character == ':'
+ || character == '?'
+ || character == '!')
+ && IS_BLANK (next));
+}
+
+void
+docbook_punctuation (character)
+ int character;
+{
+ switch (language_code)
+ {
+ case fr:
+ while (output_paragraph[output_paragraph_offset-1] == ' ')
+ output_paragraph_offset--;
+ add_word ("&nbsp;");
+ break;
+ }
+}
+
+static int in_item = 0;
+
+void
+docbook_begin_itemize ()
+{
+ if (in_docbook_paragraph)
+ insert_string ("\n</para>\n");
+
+ in_docbook_paragraph = 0;
+ insert_string ("\n<itemizedlist>\n");
+ in_item = 0;
+ in_list = 1;
+}
+
+void
+docbook_end_itemize ()
+{
+ if (in_item)
+ {
+ insert_string ("\n</para></listitem>\n");
+ in_item = 0;
+ }
+ insert_string ("\n</itemizedlist>\n\n<para>\n");
+ in_docbook_paragraph = 1;
+ in_list = 0;
+}
+
+void
+docbook_begin_enumerate ()
+{
+ if (in_docbook_paragraph)
+ insert_string ("\n</para>\n");
+ in_docbook_paragraph = 0;
+ insert_string ("\n<orderedlist>\n");
+ in_item = 0;
+ in_list = 1;
+}
+
+void
+docbook_end_enumerate ()
+{
+ if (in_item)
+ {
+ insert_string ("\n</para></listitem>\n");
+ in_item = 0;
+ }
+ insert_string ("\n</orderedlist>\n\n<para>\n");
+ in_docbook_paragraph = 1;
+ in_list = 0;
+}
+
+void
+docbook_begin_table ()
+{
+#if 0
+ if (in_docbook_paragraph)
+ insert_string ("\n</para>\n\n");
+ in_docbook_paragraph = 0;
+#endif
+
+ add_word ("\n<variablelist>\n");
+ in_table ++;
+ in_varlistitem = 0;
+ in_entry = 0;
+}
+
+void
+docbook_end_table ()
+{
+ if (!in_varlistitem)
+ docbook_begin_paragraph ();
+ insert_string ("\n</para></listitem>\n</varlistentry>\n\n</variablelist>\n");
+#if 0
+ if (in_table == 1)
+ {
+ insert_string ("\n</para>\n\n");
+ in_docbook_paragraph = 0;
+ }
+ else
+ {
+ insert_string ("\n<para>\n\n");
+ in_docbook_paragraph = 1;
+ }
+#endif
+ in_table --;
+ in_list = 0;
+}
+
+void
+docbook_add_item ()
+{
+ if (in_item)
+ insert_string ("\n</para></listitem>\n");
+ insert_string ("\n<listitem><para>\n");
+ in_docbook_paragraph = 1;
+ in_item = 1;
+}
+
+void
+docbook_add_table_item ()
+{
+ if (in_varlistitem)
+ {
+ insert_string ("\n</para></listitem>\n</varlistentry>\n\n");
+ in_entry = 0;
+ in_varlistitem = 0;
+ }
+ if (!in_entry)
+ {
+ insert_string ("<varlistentry>\n");
+ in_entry = 1;
+ }
+ insert_string ("<term>");
+ in_list = 1;
+ in_term = 1;
+}
+
+void
+docbook_close_table_item ()
+{
+ insert_string ("</term>");
+ in_list = 1;
+ in_term = 0;
+}
+
+void
+docbook_add_anchor (anchor)
+ char *anchor;
+{
+ add_word ("<anchor id=\"");
+ add_anchor_name (anchor, 0);
+ add_word ("\">");
+}
+
+void
+docbook_footnote (note)
+ char *note;
+{
+ /* add_word_args ("<footnote><para>\n%s\n</para></footnote>\n", note); */
+ add_word ("<footnote><para>\n");
+ execute_string("%s", note);
+ add_word("\n</para></footnote>\n");
+}
+
+void
+docbook_begin_index ()
+{
+ add_word ("<variablelist>\n");
+}
+
+void
+docbook_begin_example ()
+{
+ add_word ("\n\n<screen>\n");
+ in_example = 1;
+}
+
+void
+docbook_end_example ()
+{
+ in_example = 0;
+ add_word ("</screen>\n\n");
+}
diff --git a/gnu/usr.bin/texinfo/makeinfo/docbook.h b/gnu/usr.bin/texinfo/makeinfo/docbook.h
new file mode 100644
index 00000000000..e3aa2b05112
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/docbook.h
@@ -0,0 +1,81 @@
+/* docbook.h -- docbook declarations.
+ $Id: docbook.h,v 1.1 2002/06/10 13:21:15 espie Exp $
+
+ Copyright (C) 2001 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. */
+
+#ifndef DOCBOOK_H
+#define DOCBOOK_H
+
+#define DB_B "emphasis role=\"bold\""
+#define DB_CITE "citetitle"
+#define DB_CODE "literal"
+#define DB_COMMAND "command"
+#define DB_DFN "firstterm"
+#define DB_EMPH "emphasis"
+#define DB_ENV "envar"
+#define DB_FILE "filename"
+#define DB_FUNCTION "function"
+#define DB_I "emphasis"
+#define DB_KBD "userinput"
+#define DB_KEY "keycap"
+#define DB_OPTION "option"
+#define DB_STRONG "emphasis role=\"bold\""
+#define DB_TT "literal"
+#define DB_URL "systemitem role=\"sitename\""
+#define DB_VAR "replaceable"
+
+extern int docbook_version_inserted;
+extern int docbook_begin_book_p;
+extern int docbook_first_chapter_found;
+extern int docbook_must_insert_node_anchor;
+extern int docbook_no_new_paragraph;
+
+void docbook_begin_section ();
+void docbook_begin_paragraph ();
+void docbook_begin_book ();
+void docbook_end_book ();
+
+void docbook_insert_tag ();
+
+void docbook_xref1 ();
+void docbook_xref2 ();
+
+int docbook_quote ();
+
+int docbook_is_punctuation ();
+void docbook_punctuation ();
+
+void docbook_begin_itemize ();
+void docbook_end_itemize ();
+void docbook_begin_enumerate ();
+void docbook_end_enumerate ();
+
+void docbook_begin_table ();
+void docbook_end_table ();
+void docbook_add_item ();
+void docbook_add_table_item ();
+void docbook_close_table_item ();
+void docbook_add_anchor ();
+
+void docbook_footnote ();
+
+void docbook_begin_index ();
+
+void docbook_begin_example ();
+void docbook_end_example ();
+
+#endif /* DOCBOOK_H */
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/accent b/gnu/usr.bin/texinfo/makeinfo/tests/accent
new file mode 100644
index 00000000000..dc008683200
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/accent
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Test accent output.
+
+: ${srcdir=.}
+input=`basename $0`.txi
+
+# html
+houtput=`basename $0`.html
+../makeinfo --html --no-split -I$srcdir $srcdir/$input
+hexit_status=$?
+if test $hexit_status = 0; then
+ grep '&igrave;' $houtput >/dev/null \
+ && grep '&acute;i' $houtput >/dev/null \
+ && grep '&Oslash;' $houtput >/dev/null \
+ && grep '/L' $houtput >/dev/null
+ hexit_status=$?
+fi
+
+# info
+ioutput=`basename $0`.info
+../makeinfo --no-split -I$srcdir $srcdir/$input
+iexit_status=$?
+if test $iexit_status = 0; then
+ grep 'i`' $ioutput >/dev/null \
+ && grep 'i"' $ioutput >/dev/null \
+ && grep '/L' $ioutput >/dev/null
+ iexit_status=$?
+fi
+
+rm -f $houtput $ioutput
+
+exit_status=`expr $hexit_status + $iexit_status`
+exit $exit_status
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/accent-text.txi b/gnu/usr.bin/texinfo/makeinfo/tests/accent-text.txi
new file mode 100644
index 00000000000..e1bd2dacbdf
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/accent-text.txi
@@ -0,0 +1,64 @@
+@c args with braces, without braces/following whitespace
+
+should be e`: @`{e} @`e
+
+should be e': @'{e} @'e
+
+should be e^: @^{e} @^e
+
+should be u": @"{u} @"u
+
+should be i`: @`{i} @`i
+
+should be i': @'{i} @'i
+
+should be i^: @^{i} @^i
+
+should be u": @"{u} @"u
+
+should be c,: @,{c} @,c
+
+should be n~: @~{n} @~n
+
+should be e=: @={e} @=e
+
+should be e@w{'}': @H{e} @H e
+
+should be e.: @dotaccent{e} @dotaccent e
+
+should be e*: @ringaccent{e} @ringaccent e
+
+should be ee[: @tieaccent{ee}
+
+should be e(: @u{e} @u e
+
+should be e_: @ubaraccent{e} @ubaraccent e
+
+should be .e: @udotaccent{e} @udotaccent e
+
+should be e<: @v{e} @v e
+
+upside down: @questiondown{} @exclamdown{}
+
+A-with-circle: @aa{},@AA{}
+
+AE, OE ligatures: @ae{} @AE{} @oe{} @OE{}
+
+dotless i, j: @dotless{i} @dotless{j}
+
+Polish suppressed-L: @l{} @L{}
+
+O-with-slash: @o{} @O{}
+
+es-zet or sharp S: @ss{}
+
+pounds sterling: @pounds{}
+
+@c arg is command
+should be dotless i`: @`{@dotless{i}}
+
+should be dotless i': @'{@dotless{i}}
+
+should be dotless i^: @^{@dotless{i}}
+
+should be dotless i": @"{@dotless{i}}
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/accent.txi b/gnu/usr.bin/texinfo/makeinfo/tests/accent.txi
new file mode 100644
index 00000000000..3c52a90bde4
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/accent.txi
@@ -0,0 +1,10 @@
+\input texinfo
+@setfilename accent.info
+@settitle Accent test
+
+@node Top
+@top Accent test top
+
+@include accent-text.txi
+
+@bye
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/accentenc b/gnu/usr.bin/texinfo/makeinfo/tests/accentenc
new file mode 100644
index 00000000000..baf26b60186
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/accentenc
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Test encoded accent info output.
+
+: ${srcdir=.}
+input=`basename $0`.txi
+output=`basename $0`.info
+
+../makeinfo --enable-encoding --no-split -I$srcdir $srcdir/$input
+exit_status=$?
+if test $exit_status = 0; then
+ grep 'ì' $output >/dev/null \
+ && grep 'ï' $output >/dev/null \
+ && grep '/L' $output >/dev/null
+ exit_status=$?
+fi
+
+rm -f $output
+
+exit $exit_status
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/accentenc.txi b/gnu/usr.bin/texinfo/makeinfo/tests/accentenc.txi
new file mode 100644
index 00000000000..b6e209c64fa
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/accentenc.txi
@@ -0,0 +1,11 @@
+\input texinfo
+@setfilename accentenc.info
+@settitle Accent encoding test
+@documentencoding ISO-8859-1
+
+@node Top
+@top Accent encoding test top
+
+@include accent-text.txi
+
+@bye
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc b/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc
new file mode 100644
index 00000000000..59df74e411b
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Test that @documentdescription works.
+
+if ../makeinfo --html --no-split ${srcdir-.}/html-docdesc.txi; then
+ grep 'explicit document description' html-docdesc.html >/dev/null
+ exit_status=$?
+else
+ exit_status=1
+fi
+
+rm -f html-docdesc.html
+exit $exit_status
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc.txi b/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc.txi
new file mode 100644
index 00000000000..0b328dacd2a
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/html-docdesc.txi
@@ -0,0 +1,14 @@
+\input texinfo
+@setfilename html-docdesc.info
+@settitle HTML docdesc test
+
+@documentdescription
+This is the explicit document description.
+@end documentdescription
+
+@node Top
+@top Top of HTML docdesc test
+
+This is the top.
+
+@bye
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/macro-at b/gnu/usr.bin/texinfo/makeinfo/tests/macro-at
new file mode 100644
index 00000000000..90841e89f11
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/macro-at
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Test @@ in macro expansions, etc. --eliz, 14nov99.
+
+: ${srcdir=.}
+../makeinfo $srcdir/macro-at.txi || exit 1
+
+rm -f macro-at.info
diff --git a/gnu/usr.bin/texinfo/makeinfo/tests/macro-at.txi b/gnu/usr.bin/texinfo/makeinfo/tests/macro-at.txi
new file mode 100644
index 00000000000..24b91013456
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/tests/macro-at.txi
@@ -0,0 +1,38 @@
+\input texinfo @c -*- texinfo -*-
+@setfilename macro-at.info
+@settitle AUTHORS -- who did what on GNU LilyPond
+
+@macro foo
+foo-expansion
+@end macro
+
+@macro bar
+bar-expansion
+@end macro
+
+@node Top, , AUTHORS -- who did what on GNU LilyPond, (dir)
+@top
+@menu
+* AUTHORS -- who did what on GNU LilyPond:: AUTHORS -- who did what.
+@end menu
+
+@node AUTHORS -- who did what on GNU LilyPond, Top, , Top
+@chapter AUTHORS -- who did what on GNU LilyPond?
+
+This file lists authors of GNU LilyPond, and what they wrote.
+It also uses foobar@{.
+
+@itemize @bullet
+@item @email{pinard@@iro.montreal.ca, Fran@,{c}ois Pinard},
+ parts of Documentation.
+@item @email{foobar@@baz@@, The Foobar},
+ the usual foobarical thing.
+@item @email{another@@foobar@{, Buzzer},
+ buzzed all the way.
+@item @email{@foo{}@@@bar{}},
+ also helped.
+@item @email{tomcato@@xoommail.com, Tom Cato Amundsen},
+ cembalo-partita in mundela.
+@end itemize
+
+@bye
diff --git a/gnu/usr.bin/texinfo/makeinfo/texinfo.dtd b/gnu/usr.bin/texinfo/makeinfo/texinfo.dtd
new file mode 100644
index 00000000000..da4352e634d
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/texinfo.dtd
@@ -0,0 +1,337 @@
+<!-- $Id: texinfo.dtd,v 1.1 2002/06/10 13:21:23 espie Exp $
+ Document Type Definition for Texinfo.
+
+ Author: Philippe Martin (feloy@free.fr)
+ Contributors:
+ Karl Eichwalder (keichwa@gmx.net)
+
+ Copyright (C) 2001, 02 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. */
+-->
+
+<!-- ENTITIES -->
+
+<!-- Meta-information -->
+<!ENTITY % metainformation "setfilename | settitle | titlefont | dircategory">
+
+<!-- block -->
+<!-- ***** -->
+<!ENTITY % block "menu | para | quotation | example | smallexample | lisp
+ | smalllisp | cartouche | copying
+ | format | smallformat | display
+ | smalldisplay | itemize | enumerate | sp | center | group
+ | table | multitable">
+
+<!-- Sectioning -->
+<!-- ********** -->
+<!ENTITY % section.level1 "top | chapter | unnumbered | appendix
+ | majorheading | chapheading">
+
+<!ENTITY % section.level2 "section | unnumberedsec | appendixsec | heading">
+
+<!ENTITY % section.level3 "subsection | unnumberedsubsec | appendixsubsec
+ | subheading">
+
+<!ENTITY % section.level4 "subsubsection | unnumberedsubsubsec
+ | appendixsubsubsec | subsubheading">
+
+<!ENTITY % section.all "%section.level1; | %section.level2; | %section.level3;
+ | %section.level4;">
+
+
+<!ENTITY % section.level1.content "(%block;
+ | %section.level2;
+ | %section.level3;
+ | %section.level4;
+ | printindex)*">
+
+<!ENTITY % section.level2.content "(%block;
+ | %section.level3;
+ | %section.level4;)*">
+
+<!ENTITY % section.level3.content "(%block;
+ | %section.level4;)*">
+
+<!ENTITY % section.level4.content "(%block;)*">
+
+
+<!-- Inline -->
+<!-- ****** -->
+<!ENTITY % Inline.emphasize "strong | emph">
+<!ENTITY % Inline.smallcaps "sc">
+<!ENTITY % Inline.fonts "i | b | tt | r">
+<!ENTITY % Inline.markup "code | dfn | cite | key | kbd | var | acronym | url">
+<!ENTITY % Inline.reference "xref | inforef | indexterm | email | uref">
+
+<!ENTITY % Inline.phrase
+ "%Inline.emphasize; | %Inline.smallcaps; | %Inline.fonts;
+ | %Inline.markup; | %Inline.reference; ">
+
+
+<!-- ************ -->
+<!-- * ELEMENTS * -->
+<!-- ************ -->
+
+<!-- TOP Level Element -->
+<!-- ***************** -->
+<!ELEMENT texinfo ((%metainformation; | node | %block;)* )>
+
+<!-- meta-information -->
+<!ELEMENT setfilename (#PCDATA)>
+<!ELEMENT settitle (#PCDATA)>
+<!ELEMENT titlefont (#PCDATA)>
+<!ELEMENT dircategory (#PCDATA)>
+
+<!-- NODES -->
+<!-- ***** -->
+<!ELEMENT node (nodename, nodenext?, nodeprev?, nodeup?,
+ (para | menu | %section.all;)*) >
+
+<!ELEMENT nodename (#PCDATA)>
+<!ELEMENT nodenext (#PCDATA)>
+<!ELEMENT nodeprev (#PCDATA)>
+<!ELEMENT nodeup (#PCDATA)>
+
+<!-- SECTIONING -->
+<!-- ********** -->
+
+<!ELEMENT top (title?, %section.level1.content;)>
+
+<!ELEMENT chapter (title?, %section.level1.content;)>
+<!ELEMENT section (title?, %section.level2.content;)>
+<!ELEMENT subsection (title?, %section.level3.content;)>
+<!ELEMENT subsubsection (title?, %section.level4.content;)>
+
+<!ELEMENT unnumbered (title?, %section.level1.content;)>
+<!ELEMENT unnumberedsec (title?, %section.level2.content;)>
+<!ELEMENT unnumberedsubsec (title?, %section.level3.content;)>
+<!ELEMENT unnumberedsubsubsec (title?, %section.level4.content;)>
+
+<!ELEMENT appendix (title?, %section.level1.content;)>
+<!ELEMENT appendixsec (title?, %section.level2.content;)>
+<!ELEMENT appendixsubsec (title?, %section.level3.content;)>
+<!ELEMENT appendixsubsubsec (title?, %section.level4.content;)>
+
+<!ELEMENT majorheading (title?, %section.level1.content;)>
+<!ELEMENT chapheading (title?, %section.level1.content;)>
+<!ELEMENT heading (title?, %section.level2.content;)>
+<!ELEMENT subheading (title?, %section.level3.content;)>
+<!ELEMENT subsubheading (title?, %section.level4.content;)>
+
+<!ELEMENT title (#PCDATA | %Inline.phrase; | footnote)*>
+
+<!-- BLOCK Elements -->
+<!-- ************** -->
+
+<!ELEMENT quotation (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT example (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT smallexample (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT lisp (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT smalllisp (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT cartouche (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT copying (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT format (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT smallformat (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT display (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT smalldisplay (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT center (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT group (#PCDATA | %block; | %Inline.phrase;)*>
+<!ELEMENT image (#PCDATA)>
+
+<!ELEMENT para (#PCDATA | %Inline.phrase; | footnote)*>
+
+<!ELEMENT menu ((menuentry | para)*)>
+<!ELEMENT menuentry (menunode?, menutitle?, menucomment?)>
+<!ELEMENT menunode (#PCDATA)>
+<!ELEMENT menutitle (#PCDATA)>
+<!ELEMENT menucomment (#PCDATA | para)*>
+
+<!-- Lists -->
+<!ELEMENT itemize (itemfunction, (item | itemize | enumerate | indexterm)*)>
+<!ELEMENT enumerate (enumarg?, (item | itemize | enumerate)*)>
+<!ATTLIST enumerate
+ first CDATA #IMPLIED>
+
+<!ELEMENT item (%block;)*>
+<!ELEMENT enumarg (#PCDATA)>
+
+<!ELEMENT itemfunction (#PCDATA | %Inline.phrase;)*>
+
+<!-- Tables -->
+<!ELEMENT table (tableitem | indexterm)+>
+<!ELEMENT tableitem (tableterm+, item)>
+<!ELEMENT tableterm (#PCDATA | %Inline.phrase;)*>
+
+<!ELEMENT multitable (columnfraction*, row*)>
+<!ELEMENT columnfraction (#PCDATA)>
+<!ELEMENT row (entry*)>
+<!ELEMENT entry (#PCDATA | %Inline.phrase;)*>
+
+<!-- INLINE Elements -->
+<!-- *************** -->
+
+<!-- Emphasize -->
+<!ELEMENT strong (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT emph (#PCDATA | %Inline.phrase;)*>
+
+<!-- small caps -->
+<!ELEMENT sc (#PCDATA | %Inline.phrase;)*>
+
+<!-- fonts -->
+<!ELEMENT i (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT b (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT tt (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT r (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT notfixedwidth (#PCDATA | %Inline.phrase;)*>
+
+<!-- markup -->
+<!ELEMENT code (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT dfn (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT cite (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT key (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT kbd (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT var (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT acronym (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT url (#PCDATA | %Inline.phrase;)*>
+
+<!-- reference -->
+<!ELEMENT anchor EMPTY>
+<!ATTLIST anchor
+ name CDATA #IMPLIED>
+
+<!ELEMENT xref (xrefnodename | xrefinfoname | xrefinfofile
+ | xrefprintedname | xrefprinteddesc)*>
+<!ELEMENT xrefnodename (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT xrefinfoname (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT xrefinfofile (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT xrefprintedname (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT xrefprinteddesc (#PCDATA | %Inline.phrase;)*>
+
+<!ELEMENT inforef (inforefnodename | inforefrefname | inforefinfoname)*>
+<!ELEMENT inforefnodename (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT inforefrefname (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT inforefinfoname (#PCDATA | %Inline.phrase;)*>
+
+<!ELEMENT indexterm (#PCDATA | %Inline.phrase;)*>
+<!ATTLIST indexterm
+ INDEX CDATA #IMPLIED>
+
+<!ELEMENT email (emailaddress, emailname?)>
+<!ELEMENT emailaddress (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT emailname (#PCDATA | %Inline.phrase;)*>
+
+<!ELEMENT uref (urefurl, urefdesc?, urefreplacement?)>
+<!ELEMENT urefurl (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT urefdesc (#PCDATA | %Inline.phrase;)*>
+<!ELEMENT urefreplacement (#PCDATA | %Inline.phrase;)*>
+
+<!ELEMENT footnote (para)>
+
+
+
+<!ENTITY tex "TeX">
+<!ENTITY ellipsis "">
+<!ENTITY lt "">
+<!ENTITY gt "">
+<!ENTITY bullet "">
+<!ENTITY copyright "">
+<!ENTITY minus "">
+<!ENTITY linebreak "">
+<!ENTITY space "">
+<!ENTITY dots "">
+<!ENTITY enddots "">
+<!ENTITY amp "">
+
+<!ENTITY auml "">
+<!ENTITY ouml "">
+<!ENTITY uuml "">
+<!ENTITY Auml "">
+<!ENTITY Ouml "">
+<!ENTITY Uuml "">
+<!ENTITY Euml "">
+<!ENTITY euml "">
+<!ENTITY Iuml "">
+<!ENTITY iuml "">
+<!ENTITY yuml "">
+<!ENTITY uml "">
+
+<!ENTITY Aacute "">
+<!ENTITY Eacute "">
+<!ENTITY Iacute "">
+<!ENTITY Oacute "">
+<!ENTITY Uacute "">
+<!ENTITY Yacute "">
+<!ENTITY aacute "">
+<!ENTITY eacute "">
+<!ENTITY iacute "">
+<!ENTITY oacute "">
+<!ENTITY uacute "">
+<!ENTITY yacute "">
+
+<!ENTITY ccedil "">
+<!ENTITY Ccedil "">
+
+<!ENTITY Acirc "">
+<!ENTITY Ecirc "">
+<!ENTITY Icirc "">
+<!ENTITY Ocirc "">
+<!ENTITY Ucirc "">
+<!ENTITY acirc "">
+<!ENTITY ecirc "">
+<!ENTITY icirc "">
+<!ENTITY ocirc "">
+<!ENTITY ucirc "">
+
+<!ENTITY Agrave "">
+<!ENTITY Egrave "">
+<!ENTITY Igrave "">
+<!ENTITY Ograve "">
+<!ENTITY Ugrave "">
+<!ENTITY agrave "">
+<!ENTITY egrave "">
+<!ENTITY igrave "">
+<!ENTITY ograve "">
+<!ENTITY ugrave "">
+
+<!ENTITY Atilde "">
+<!ENTITY Ntilde "">
+<!ENTITY Otilde "">
+<!ENTITY atilde "">
+<!ENTITY ntilde "">
+<!ENTITY otilde "">
+
+<!ENTITY oslash "">
+<!ENTITY Oslash "">
+
+<!ENTITY iexcl "">
+<!ENTITY pound "">
+<!ENTITY iquest "">
+<!ENTITY AElig "">
+<!ENTITY aelig "">
+<!ENTITY Aring "">
+<!ENTITY aring "">
+<!ENTITY szlig "">
+
+<!ENTITY macr "">
+
+
+<!-- fixxme: not yet classified -->
+
+<!ELEMENT sp (#PCDATA)>
+<!ATTLIST sp
+ lines CDATA #IMPLIED>
+<!ELEMENT printindex (#PCDATA)>
+
diff --git a/gnu/usr.bin/texinfo/makeinfo/texinfo.xsl b/gnu/usr.bin/texinfo/makeinfo/texinfo.xsl
new file mode 100644
index 00000000000..afe90c9f1c4
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/texinfo.xsl
@@ -0,0 +1,242 @@
+<?xml version='1.0'?>
+<!-- $Id: texinfo.xsl,v 1.1 2002/06/10 13:21:23 espie Exp $ -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output method="html" indent="yes"/>
+
+<!-- root rule -->
+<xsl:template match="/">
+ <html>
+ <head><title>
+ <xsl:apply-templates select="TEXINFO/SETTITLE" mode="head"/>
+ </title></head>
+ <body bgcolor="#FFFFFF"><xsl:apply-templates/>
+</body></html>
+</xsl:template>
+
+
+<xsl:template match="TEXINFO">
+ <xsl:apply-templates/>
+</xsl:template>
+
+
+<xsl:template match="TEXINFO/SETFILENAME">
+</xsl:template>
+
+<xsl:template match="TEXINFO/SETTITLE" mode="head">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="TEXINFO/SETTITLE">
+ <h1><xsl:apply-templates/></h1>
+</xsl:template>
+
+
+<xsl:template match="TEXINFO/DIRCATEGORY">
+</xsl:template>
+
+<xsl:template match="//PARA">
+ <p><xsl:apply-templates/></p>
+</xsl:template>
+
+<xsl:template match="//EMPH">
+ <i><xsl:apply-templates/></i>
+</xsl:template>
+
+<!-- The node -->
+<xsl:template match="TEXINFO/NODE">
+ <hr/>
+ <p>
+ <xsl:apply-templates select="NODENAME" mode="select"/>
+ <xsl:apply-templates select="NODEPREV" mode="select"/>
+ <xsl:apply-templates select="NODEUP" mode="select"/>
+ <xsl:apply-templates select="NODENEXT" mode="select"/>
+ <xsl:apply-templates/>
+ <h2>Footnotes</h2>
+ <ol>
+ <xsl:apply-templates select=".//FOOTNOTE" mode="footnote"/>
+ </ol>
+ </p>
+</xsl:template>
+
+<xsl:template match="TEXINFO/NODE/NODENAME" mode="select">
+<h2>
+ <a>
+ <xsl:attribute name="name">
+ <xsl:apply-templates/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </a>
+</h2>
+</xsl:template>
+
+<xsl:template match="TEXINFO/NODE/NODENAME"/>
+
+
+<xsl:template match="TEXINFO/NODE/NODEPREV" mode="select">
+ [ <b>Previous: </b>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>#</xsl:text>
+ <xsl:apply-templates/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </a> ]
+</xsl:template>
+
+<xsl:template match="TEXINFO/NODE/NODEPREV"/>
+
+<xsl:template match="TEXINFO/NODE/NODEUP" mode="select">
+ [ <b>Up: </b>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>#</xsl:text>
+ <xsl:apply-templates/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </a> ]
+</xsl:template>
+
+<xsl:template match="TEXINFO/NODE/NODEUP"/>
+
+<xsl:template match="TEXINFO/NODE/NODENEXT" mode="select">
+ [ <b>Next: </b>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>#</xsl:text>
+ <xsl:apply-templates/>
+ </xsl:attribute>
+ <xsl:apply-templates/>
+ </a> ]
+</xsl:template>
+
+<xsl:template match="TEXINFO/NODE/NODENEXT"/>
+
+<!-- Menu -->
+<xsl:template match="//MENU">
+ <h3>Menu</h3>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="//MENU/MENUENTRY">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>#</xsl:text>
+ <xsl:apply-templates select="MENUNODE"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="MENUTITLE"/>
+ </a>:
+ <xsl:apply-templates select="MENUCOMMENT"/>
+ <br/>
+</xsl:template>
+
+<xsl:template match="//MENU/MENUENTRY/MENUNODE">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="//MENU/MENUENTRY/MENUTITLE">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="//MENU/MENUENTRY/MENUCOMMENT">
+ <xsl:apply-templates mode="menucomment"/>
+</xsl:template>
+
+<xsl:template match="PARA" mode="menucomment">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="//PARA">
+ <p><xsl:apply-templates/></p>
+</xsl:template>
+
+<!-- LISTS -->
+<xsl:template match="//ITEMIZE">
+ <ul>
+ <xsl:apply-templates/>
+ </ul>
+</xsl:template>
+
+<xsl:template match="//ITEMIZE/ITEM">
+ <li>
+ <xsl:apply-templates/>
+ </li>
+</xsl:template>
+
+<xsl:template match="//ENUMERATE">
+ <ol>
+ <xsl:apply-templates/>
+ </ol>
+</xsl:template>
+
+<xsl:template match="//ENUMERATE/ITEM">
+ <li>
+ <xsl:apply-templates/>
+ </li>
+</xsl:template>
+
+<!-- INLINE -->
+<xsl:template match="//CODE">
+ <tt>
+ <xsl:apply-templates/>
+ </tt>
+</xsl:template>
+
+<xsl:template match="//DFN">
+ <i><b>
+ <xsl:apply-templates/>
+ </b></i>
+</xsl:template>
+
+<xsl:template match="//STRONG">
+ <b>
+ <xsl:apply-templates/>
+ </b>
+</xsl:template>
+
+<xsl:template match="//CENTER">
+ <center>
+ <xsl:apply-templates/>
+ </center>
+</xsl:template>
+
+<xsl:template match="//VAR">
+ <i>
+ <xsl:apply-templates/>
+ </i>
+</xsl:template>
+
+<xsl:template match="//KBD">
+ <tt>
+ <xsl:apply-templates/>
+ </tt>
+</xsl:template>
+
+<xsl:template match="//KEY">
+ <b>
+ <xsl:apply-templates/>
+ </b>
+</xsl:template>
+
+<!-- BLOCKS -->
+<xsl:template match="//DISPLAY">
+ <pre>
+ <xsl:apply-templates/>
+ </pre>
+</xsl:template>
+
+
+<!-- INDEX -->
+<xsl:template match="//INDEXTERM">
+</xsl:template>
+
+<!-- FOOTNOTE -->
+<xsl:template match="//FOOTNOTE">
+</xsl:template>
+
+<xsl:template match="//FOOTNOTE" mode="footnote">
+ <li><xsl:apply-templates/></li>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/gnu/usr.bin/texinfo/makeinfo/xml.c b/gnu/usr.bin/texinfo/makeinfo/xml.c
new file mode 100644
index 00000000000..70cb4f10486
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/xml.c
@@ -0,0 +1,1430 @@
+/* xml.c -- xml output.
+ $Id: xml.c,v 1.1 2002/06/10 13:21:23 espie Exp $
+
+ Copyright (C) 2001, 02 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.
+
+ Written by Philippe Martin <feloy@free.fr>. */
+
+#include "system.h"
+#include "makeinfo.h"
+#include "insertion.h"
+#include "macro.h"
+#include "cmds.h"
+#include "lang.h"
+
+#include "xml.h"
+
+/* Options */
+int xml_index_divisions = 1;
+
+
+void xml_close_sections (/* int level */);
+
+typedef struct _element
+{
+ char name[32];
+ int contains_para;
+ int contained_in_para;
+} element;
+
+element texinfoml_element_list [] = {
+ { "texinfo", 1, 0 },
+ { "setfilename", 0, 0 },
+ { "titlefont", 0, 0 },
+ { "settitle", 0, 0 },
+
+ { "node", 1, 0 },
+ { "nodenext", 0, 0 },
+ { "nodeprev", 0, 0 },
+ { "nodeup", 0, 0 },
+
+ { "chapter", 1, 0 },
+ { "section", 1, 0 },
+ { "subsection", 1, 0 },
+ { "subsubsection", 1, 0 },
+
+ { "top", 1, 0 },
+ { "unnumbered", 1, 0 },
+ { "unnumberedsec", 1, 0 },
+ { "unnumberedsubsec", 1, 0 },
+ { "unnumberedsubsubsec", 1, 0 },
+
+ { "appendix", 1, 0 },
+ { "appendixsec", 1, 0 },
+ { "appendixsubsec", 1, 0 },
+ { "appendixsubsubsec", 1, 0 },
+
+ { "majorheading", 1, 0 },
+ { "chapheading", 1, 0 },
+ { "heading", 1, 0 },
+ { "subheading", 1, 0 },
+ { "subsubheading", 1, 0 },
+
+ { "menu", 1, 0 },
+ { "menuentry", 1, 0 },
+ { "menutitle", 0, 0 },
+ { "menucomment", 1, 0 },
+ { "menunode", 0, 0 },
+ { "nodename", 0, 0 },
+
+ { "acronym", 0, 1 },
+ { "tt", 0, 1 },
+ { "code", 0, 1 },
+ { "kbd", 0, 1 },
+ { "url", 0, 1 },
+ { "key", 0, 1 },
+ { "var", 0, 1 },
+ { "sc", 0, 1 },
+ { "dfn", 0, 1 },
+ { "emph", 0, 1 },
+ { "strong", 0, 1 },
+ { "cite", 0, 1 },
+ { "notfixedwidth", 0, 1 },
+ { "i", 0, 1 },
+ { "b", 0, 1 },
+ { "r", 0, 1 },
+
+ { "title", 0, 0 },
+ { "ifinfo", 1, 0 },
+ { "sp", 0, 0 },
+ { "center", 1, 0 },
+ { "dircategory", 0, 0 },
+ { "quotation", 1, 0 },
+ { "example", 1, 0 },
+ { "smallexample", 1, 0 },
+ { "lisp", 1, 0 },
+ { "smalllisp", 1, 0 },
+ { "cartouche", 1, 0 },
+ { "copying", 1, 0 },
+ { "format", 1, 0 },
+ { "smallformat", 1, 0 },
+ { "display", 1, 0 },
+ { "smalldisplay", 1, 0 },
+ { "footnote", 0, 1 },
+
+ { "itemize", 0, 0 },
+ { "itemfunction", 0, 0 },
+ { "item", 1, 0 },
+ { "enumerate", 0, 0 },
+ { "table", 0, 0 },
+ { "tableitem", 0, 0 }, /* not used */ /* TABLEITEM */
+ { "tableterm", 0, 0 }, /* not used */ /* TABLETERM */
+
+ { "indexterm", 0, 1 },
+
+ { "xref", 0, 1 },
+ { "xrefnodename", 0, 1 },
+ { "xrefinfoname", 0, 1 },
+ { "xrefprinteddesc", 0, 1 },
+ { "xrefinfofile", 0, 1 },
+ { "xrefprintedname", 0, 1 },
+
+ { "inforef", 0, 1 },
+ { "inforefnodename", 0, 1 },
+ { "inforefrefname", 0, 1 },
+ { "inforefinfoname", 0, 1 },
+
+ { "uref", 0, 1 },
+ { "urefurl", 0, 1 },
+ { "urefdesc", 0, 1 },
+ { "urefreplacement", 0, 1 },
+
+ { "email", 0, 1 },
+ { "emailaddress", 0, 1 },
+ { "emailname", 0, 1 },
+
+ { "group", 0, 0 },
+
+ { "printindex", 0, 0 },
+ { "anchor", 0, 1 },
+ { "image", 0, 1 },
+ { "", 0, 1 }, /* PRIMARY (docbook) */
+ { "", 0, 1 }, /* SECONDARY (docbook) */
+ { "", 0, 0 }, /* INFORMALFIGURE (docbook) */
+ { "", 0, 0 }, /* MEDIAOBJECT (docbook) */
+ { "", 0, 0 }, /* IMAGEOBJECT (docbook) */
+ { "", 0, 0 }, /* IMAGEDATA (docbook) */
+ { "", 0, 0 }, /* TEXTOBJECT (docbook) */
+ { "", 0, 0 }, /* INDEXENTRY (docbook) */
+ { "", 0, 0 }, /* PRIMARYIE (docbook) */
+ { "", 0, 0 }, /* SECONDARYIE (docbook) */
+ { "", 0, 0 }, /* INDEXDIV (docbook) */
+ { "multitable", 0, 0 },
+ { "", 0, 0 }, /* TGROUP (docbook) */
+ { "columnfraction", 0, 0 },
+ { "", 0, 0 }, /* TBODY (docbook) */
+ { "entry", 0, 0 }, /* ENTRY (docbook) */
+ { "row", 0, 0 }, /* ROW (docbook) */
+ { "", 0, 0 }, /* BOOKINFO (docbook) */
+ { "", 0, 0 }, /* ABSTRACT (docbook) */
+ { "", 0, 0 }, /* REPLACEABLE (docbook) */
+ { "para", 0, 0 } /* Must be last */
+ /* name / contains para / contained in para */
+};
+
+element docbook_element_list [] = {
+ { "book", 0, 0 }, /* TEXINFO */
+ { "", 0, 0 }, /* SETFILENAME */
+ { "", 0, 0 }, /* TITLEINFO */
+ { "title", 0, 0 }, /* SETTITLE */
+
+ { "", 1, 0 }, /* NODE */
+ { "", 0, 0 }, /* NODENEXT */
+ { "", 0, 0 }, /* NODEPREV */
+ { "", 0, 0 }, /* NODEUP */
+
+ { "chapter", 1, 0 },
+ { "sect1", 1, 0 }, /* SECTION */
+ { "sect2", 1, 0 }, /* SUBSECTION */
+ { "sect3", 1, 0 }, /* SUBSUBSECTION */
+
+ { "chapter", 1, 0 }, /* TOP */
+ { "chapter", 1, 0 }, /* UNNUMBERED */
+ { "sect1", 1, 0 }, /* UNNUMBEREDSEC */
+ { "sect2", 1, 0 }, /* UNNUMBEREDSUBSEC */
+ { "sect3", 1, 0 }, /* UNNUMBEREDSUBSUBSEC */
+
+ { "appendix", 1, 0 },
+ { "sect1", 1, 0 }, /* APPENDIXSEC */
+ { "sect2", 1, 0 }, /* APPENDIXSUBSEC */
+ { "sect3", 1, 0 }, /* APPENDIXSUBSUBSEC */
+
+ { "chapter", 1, 0 }, /* MAJORHEADING */
+ { "chapter", 1, 0 }, /* CHAPHEADING */
+ { "sect1", 1, 0 }, /* HEADING */
+ { "sect2", 1, 0 }, /* SUBHEADING */
+ { "sect3", 1, 0 }, /* SUBSUBHEADING */
+
+ { "", 1, 0 }, /* MENU */
+ { "", 1, 0 }, /* MENUENTRY */
+ { "", 0, 0 }, /* MENUTITLE */
+ { "", 1, 0 }, /* MENUCOMMENT */
+ { "", 0, 0 }, /* MENUNODE */
+ { "anchor", 0, 0 }, /* NODENAME */
+
+ { "acronym", 0, 1 },
+ { "wordasword", 0, 1 }, /* TT */
+ { "command", 0, 1 }, /* CODE */
+ { "userinput", 0, 1 }, /* KBD */
+ { "wordasword", 0, 1 }, /* URL */
+ { "keycap", 0, 1 }, /* KEY */
+ { "varname", 0, 1 }, /* VAR */
+ { "", 0, 1 }, /* SC */
+ { "firstterm", 0, 1 }, /* DFN */
+ { "emphasis", 0, 1 }, /* EMPH */
+ { "emphasis", 0, 1 }, /* STRONG */
+ { "citation", 0, 1 }, /* CITE */
+ { "", 0, 1 }, /* NOTFIXEDWIDTH */
+ { "wordasword", 0, 1 }, /* I */
+ { "wordasword", 0, 1 }, /* B */
+ { "", 0, 1 }, /* R */
+
+ { "title", 0, 0 },
+ { "", 1, 0 }, /* IFINFO */
+ { "", 0, 0 }, /* SP */
+ { "", 1, 0 }, /* CENTER */
+ { "", 0, 0 }, /* DIRCATEGORY */
+ { "blockquote", 1, 0 }, /* QUOTATION */
+ { "screen", 0, 1 },
+ { "screen", 0, 1 }, /* SMALLEXAMPLE */
+ { "screen", 0, 1 }, /* LISP */
+ { "screen", 0, 1 }, /* SMALLLISP */
+ { "", 1, 0 }, /* CARTOUCHE */
+ { "", 1, 0 }, /* COPYING */
+ { "screen", 0, 1 }, /* FORMAT */
+ { "screen", 0, 1 }, /* SMALLFORMAT */
+ { "screen", 0, 1 }, /* DISPLAY */
+ { "screen", 0, 1 }, /* SMALLDISPLAY */
+ { "footnote", 0, 1 },
+
+ { "itemizedlist", 0, 0 }, /* ITEMIZE */
+ { "", 0, 0 }, /* ITEMFUNCTION */
+ { "listitem", 1, 0 },
+ { "orderedlist", 0, 0 }, /* ENUMERATE */
+ { "variablelist", 0, 0 }, /* TABLE */
+ { "varlistentry", 0, 0 }, /* TABLEITEM */
+ { "term", 0, 0 }, /* TABLETERM */
+
+ { "indexterm", 0, 1 },
+
+ { "xref", 0, 1 }, /* XREF */
+ { "link", 0, 1 }, /* XREFNODENAME */
+ { "", 0, 1 }, /* XREFINFONAME */
+ { "", 0, 1 }, /* XREFPRINTEDDESC */
+ { "", 0, 1 }, /* XREFINFOFILE */
+ { "", 0, 1 }, /* XREFPRINTEDNAME */
+
+ { "", 0, 1 }, /* INFOREF */
+ { "", 0, 1 }, /* INFOREFNODENAME */
+ { "", 0, 1 }, /* INFOREFREFNAME */
+ { "", 0, 1 }, /* INFOREFINFONAME */
+
+ { "", 0, 1 }, /* UREF */
+ { "", 0, 1 }, /* UREFURL */
+ { "", 0, 1 }, /* UREFDESC */
+ { "", 0, 1 }, /* UREFREPLACEMENT */
+
+ { "ulink", 0, 1 }, /* EMAIL */
+ { "", 0, 1 }, /* EMAILADDRESS */
+ { "", 0, 1 }, /* EMAILNAME */
+
+ { "", 0, 0 }, /* GROUP */
+
+ { "index", 0, 0 }, /* PRINTINDEX */
+ { "", 0, 1 }, /* ANCHOR */
+ { "", 0, 1 }, /* IMAGE */
+ { "primary", 0, 1 }, /* PRIMARY */
+ { "secondary", 0, 1 },
+ { "informalfigure", 0, 0 },
+ { "mediaobject", 0, 0 },
+ { "imageobject", 0, 0 },
+ { "imagedata", 0, 0 },
+ { "textobject", 0, 0 },
+ { "indexentry", 0, 0 },
+ { "primaryie", 0, 0 },
+ { "secondaryie", 0, 0 },
+ { "indexdiv", 0, 0 },
+ { "informaltable", 0, 0 },
+ { "tgroup", 0, 0 },
+ { "colspec", 0, 0 },
+ { "tbody", 0, 0 },
+ { "entry", 0, 0 },
+ { "row", 0, 0 },
+ { "bookinfo", 0, 0 },
+ { "abstract", 1, 0 },
+ { "replaceable", 0, 0 },
+
+ { "para", 0, 0 } /* Must be last */
+ /* name / contains para / contained in para */
+};
+
+element *xml_element_list = NULL;
+
+
+typedef struct _replace_element
+{
+ int element_to_replace;
+ int element_containing;
+ int element_replacing;
+} replace_element;
+
+/* Elements to replace - Docbook only
+ -------------------
+ if `element_to_replace' have to be inserted
+ as a child of `element_containing,'
+ use `element_replacing' instead.
+
+ A value of `-1' for element_replacing means `do not use any element.'
+*/
+
+replace_element replace_elements [] = {
+ { I, TABLETERM, EMPH },
+ { B, TABLETERM, EMPH },
+ { TT, CODE, -1 },
+ { EXAMPLE, DISPLAY, -1 },
+ { CODE, DFN, -1 },
+ { CODE, VAR, -1 },
+ { EMPH, CODE, REPLACEABLE },
+ /* Add your elements to replace here */
+ {-1, 0, 0}
+};
+
+int xml_in_menu_entry = 0;
+int xml_in_menu_entry_comment = 0;
+int xml_node_open = 0;
+int xml_node_level = -1;
+int xml_in_para = 0;
+int xml_just_after_element = 0;
+
+int xml_no_para = 0;
+char *xml_node_id = NULL;
+int xml_sort_index = 0;
+
+static int xml_after_table_term = 0;
+static int book_started = 0;
+static int first_section_opened = 0;
+static int in_abstract = 0;
+
+static int xml_current_element ();
+
+void
+#if defined (VA_FPRINTF) && __STDC__
+xml_insert_element_with_attribute (int elt, int arg, char *format, ...);
+#else
+xml_insert_element_with_attribute ();
+#endif
+
+char *
+xml_id (id)
+ char *id;
+{
+ char *tem = xmalloc (strlen (id) + 1);
+ char *p = tem;
+ strcpy (tem, id);
+ while (*p++)
+ {
+ if (*p == ' ' || *p == '&' || *p == '/' || *p == '+')
+ *p = '-';
+ }
+ p = tem;
+ while (*p == '-')
+ *p = 'i';
+ return tem;
+}
+
+int
+xml_element (name)
+ char *name;
+{
+ int i;
+ for (i=0; i<=PARA; i++)
+ {
+ if (strcasecmp (name, texinfoml_element_list[i].name) == 0)
+ return i;
+ }
+ printf ("Error xml_element\n");
+ return -1;
+}
+
+void
+xml_begin_document (output_filename)
+ char *output_filename;
+{
+ if (book_started)
+ return;
+
+ book_started = 1;
+ if (docbook)
+ {
+ insert_string ("<!DOCTYPE Book PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\">");
+ xml_element_list = docbook_element_list;
+ }
+ else
+ {
+ insert_string ("<!DOCTYPE texinfo SYSTEM \"texinfo.dtd\">");
+ xml_element_list = texinfoml_element_list;
+ }
+ if (docbook)
+ {
+ if (language_code != last_language_code)
+ xml_insert_element_with_attribute (TEXINFO, START, "lang=\"%s\"", language_table[language_code].abbrev);
+ }
+ else
+ xml_insert_element (TEXINFO, START);
+ if (!docbook)
+ {
+ xml_insert_element (SETFILENAME, START);
+ insert_string (output_filename);
+ xml_insert_element (SETFILENAME, END);
+ }
+}
+
+/* */
+static int element_stack[256];
+static int element_stack_index = 0;
+
+static void
+xml_push_current_element (elt)
+ int elt;
+{
+ element_stack[element_stack_index++] = elt;
+ if (element_stack_index > 200)
+ printf ("*** stack overflow (%d - %s) ***\n",
+ element_stack_index,
+ xml_element_list[elt].name);
+}
+
+void
+xml_pop_current_element ()
+{
+ element_stack_index--;
+ if (element_stack_index < 0)
+ printf ("*** stack underflow (%d - %d) ***\n",
+ element_stack_index,
+ xml_current_element());
+}
+
+static int
+xml_current_element ()
+{
+ return element_stack[element_stack_index-1];
+}
+
+static void
+xml_indent ()
+{
+ int i;
+ insert ('\n');
+ for (i = 0; i < element_stack_index; i++)
+ insert (' ');
+}
+
+static void
+xml_indent_end_para ()
+{
+ int i;
+ for (i = 0; i < element_stack_index; i++)
+ insert (' ');
+}
+
+void
+xml_end_document ()
+{
+ if (xml_node_open)
+ {
+ if (xml_node_level != -1)
+ {
+ xml_close_sections (xml_node_level);
+ xml_node_level = -1;
+ }
+ xml_insert_element (NODE, END);
+ }
+ xml_insert_element (TEXINFO, END);
+ insert_string ("\n");
+ insert_string ("<!-- Keep this comment at the end of the file\n\
+Local variables:\n\
+mode: sgml\n\
+sgml-indent-step:1\n\
+sgml-indent-data:nil\n\
+End:\n\
+-->\n");
+ if (element_stack_index != 0)
+ error ("Element stack index : %d\n", element_stack_index);
+}
+
+/* MUST be 0 or 1, not true or false values */
+static int start_element_inserted = 1;
+
+/* NOTE: We use `elt' rather than `element' in the argument list of
+ the next function, since otherwise the Solaris SUNWspro compiler
+ barfs because `element' is a typedef declared near the beginning of
+ this file. */
+void
+#if defined (VA_FPRINTF) && __STDC__
+xml_insert_element_with_attribute (int elt, int arg, char *format, ...)
+#else
+xml_insert_element_with_attribute (elt, arg, format, va_alist)
+ int elt;
+ int arg;
+ char *format;
+ va_dcl
+#endif
+{
+ /* Look at the replace_elements table to see if we have to change the element */
+ if (xml_sort_index)
+ return;
+ if (docbook)
+ {
+ replace_element *element_list = replace_elements;
+ while (element_list->element_to_replace >= 0)
+ {
+ if ( ( (arg == START) &&
+ (element_list->element_containing == xml_current_element ()) &&
+ (element_list->element_to_replace == elt) ) ||
+ ( (arg == END) &&
+ (element_list->element_containing == element_stack[element_stack_index-1-start_element_inserted]) &&
+ (element_list->element_to_replace == elt) ) )
+ {
+ elt = element_list->element_replacing;
+ break;
+ }
+ element_list ++;
+ }
+
+ /* Forget the element */
+ if (elt < 0)
+ {
+ if (arg == START)
+ start_element_inserted = 0;
+ else
+ /* Replace the default value, for the next time */
+ start_element_inserted = 1;
+ return;
+ }
+ }
+
+ if (!book_started)
+ return;
+
+ if (xml_after_table_term && elt != TABLETERM)
+ {
+ xml_after_table_term = 0;
+ xml_insert_element (ITEM, START);
+ }
+
+ if (docbook && !only_macro_expansion && (in_menu || in_detailmenu))
+ return;
+
+ if (!xml_element_list[elt].name || !strlen (xml_element_list[elt].name))
+ {
+ /* printf ("Warning: Inserting empty element %d\n", elt);*/
+ return;
+ }
+
+ if (arg == START && !xml_in_para && !xml_no_para
+ && xml_element_list[elt].contained_in_para
+ && xml_element_list[xml_current_element()].contains_para )
+ {
+ xml_indent ();
+ insert_string ("<para>");
+ xml_in_para = 1;
+ }
+
+
+ if (arg == START && xml_in_para && !xml_element_list[elt].contained_in_para)
+ {
+ xml_indent_end_para ();
+ insert_string ("</para>");
+ xml_in_para = 0;
+ }
+
+ if (arg == END && xml_in_para && !xml_element_list[elt].contained_in_para)
+ {
+ xml_indent_end_para ();
+ insert_string ("</para>");
+ xml_in_para = 0;
+ }
+
+ if (arg == START && !xml_in_para && !xml_element_list[elt].contained_in_para)
+ xml_indent ();
+
+ if (arg == START)
+ xml_push_current_element (elt);
+ else
+ xml_pop_current_element ();
+
+ insert ('<');
+ if (arg == END)
+ insert ('/');
+ insert_string (xml_element_list[elt].name);
+
+ /* printf ("%s ", xml_element_list[elt].name);*/
+
+ if (format)
+ {
+ char temp_string[2000]; /* xx no fixed limits */
+#ifdef VA_SPRINTF
+ va_list ap;
+#endif
+
+ VA_START (ap, format);
+#ifdef VA_SPRINTF
+ VA_SPRINTF (temp_string, format, ap);
+#else
+ sprintf (temp_string, format, a1, a2, a3, a4, a5, a6, a7, a8);
+#endif
+ insert (' ');
+ insert_string (temp_string);
+ va_end (ap);
+ }
+
+ if (arg == START && xml_node_id && elt != NODENAME)
+ {
+ insert_string (" id=\"");
+ insert_string (xml_node_id);
+ insert_string ("\"");
+ free (xml_node_id);
+ xml_node_id = NULL;
+ }
+
+ insert ('>');
+
+ xml_just_after_element = 1;
+}
+
+/* See the NOTE before xml_insert_element_with_attribute, for why we
+ use `elt' rather than `element' here. */
+void
+xml_insert_element (int elt, int arg)
+{
+ xml_insert_element_with_attribute (elt, arg, NULL);
+}
+
+void
+xml_insert_entity (char *entity_name)
+{
+ int saved_escape_html = escape_html;
+
+ if (!book_started)
+ return;
+ if (docbook && !only_macro_expansion && (in_menu || in_detailmenu))
+ return;
+
+ if (!xml_in_para && !xml_no_para && !only_macro_expansion
+ && xml_element_list[xml_current_element ()].contains_para)
+ {
+ insert_string ("<para>");
+ xml_in_para = 1;
+ }
+ escape_html = 0;
+ insert ('&');
+ escape_html = saved_escape_html;
+ insert_string (entity_name);
+ insert (';');
+}
+
+typedef struct _xml_section xml_section;
+struct _xml_section {
+ int level;
+ char *name;
+ xml_section *prev;
+};
+
+xml_section *last_section = NULL;
+
+void
+xml_begin_node ()
+{
+ if (xml_node_open && ! docbook)
+ {
+ if (xml_node_level != -1)
+ {
+ xml_close_sections (xml_node_level);
+ xml_node_level = -1;
+ }
+ xml_insert_element (NODE, END);
+ }
+ xml_insert_element (NODE, START);
+ xml_node_open = 1;
+}
+
+void
+xml_close_sections (level)
+ int level;
+{
+ if (!first_section_opened && in_abstract)
+ {
+ xml_insert_element (ABSTRACT, END);
+ xml_insert_element (BOOKINFO, END);
+ first_section_opened = 1;
+ }
+ while (last_section && last_section->level >= level)
+ {
+ xml_section *temp = last_section;
+ xml_insert_element (xml_element(last_section->name), END);
+ temp = last_section;
+ last_section = last_section->prev;
+ free (temp->name);
+ free (temp);
+ }
+}
+
+void
+xml_open_section (level, name)
+ int level;
+ char *name;
+{
+ xml_section *sect = (xml_section *) xmalloc (sizeof (xml_section));
+
+ sect->level = level;
+ sect->name = xmalloc (1 + strlen (name));
+ strcpy (sect->name, name);
+ sect->prev = last_section;
+ last_section = sect;
+
+ if (xml_node_open && xml_node_level == -1)
+ xml_node_level = level;
+}
+
+void
+xml_start_menu_entry (tem)
+ char *tem;
+{
+ char *string;
+ discard_until ("* ");
+
+ /* The line number was already incremented in reader_loop when we
+ saw the newline, and discard_until has now incremented again. */
+ line_number--;
+
+ if (xml_in_menu_entry)
+ {
+ if (xml_in_menu_entry_comment)
+ {
+ xml_insert_element (MENUCOMMENT, END);
+ xml_in_menu_entry_comment=0;
+ }
+ xml_insert_element (MENUENTRY, END);
+ xml_in_menu_entry=0;
+ }
+ xml_insert_element (MENUENTRY, START);
+ xml_in_menu_entry=1;
+
+ xml_insert_element (MENUNODE, START);
+ string = expansion (tem, 0);
+ add_word (string);
+ xml_insert_element (MENUNODE, END);
+ free (string);
+
+ /* The menu item may use macros, so expand them now. */
+ xml_insert_element (MENUTITLE, START);
+ only_macro_expansion++;
+ get_until_in_line (1, ":", &string);
+ only_macro_expansion--;
+ execute_string ("%s", string); /* get escaping done */
+ xml_insert_element (MENUTITLE, END);
+ free (string);
+
+ if (looking_at ("::"))
+ discard_until (":");
+ else
+ { /* discard the node name */
+ get_until_in_line (0, ".", &string);
+ free (string);
+ }
+ input_text_offset++; /* discard the second colon or the period */
+ xml_insert_element (MENUCOMMENT, START);
+ xml_in_menu_entry_comment ++;
+}
+
+void
+xml_end_menu ()
+{
+ if (xml_in_menu_entry)
+ {
+ if (xml_in_menu_entry_comment)
+ {
+ xml_insert_element (MENUCOMMENT, END);
+ xml_in_menu_entry_comment --;
+ }
+ xml_insert_element (MENUENTRY, END);
+ xml_in_menu_entry--;
+ }
+ xml_insert_element (MENU, END);
+}
+
+static int xml_last_character;
+
+void
+xml_add_char (character)
+ int character;
+{
+ if (!book_started)
+ return;
+ if (docbook && !only_macro_expansion && (in_menu || in_detailmenu))
+ return;
+
+ if (!first_section_opened && !in_abstract && xml_current_element () == TEXINFO
+ && !xml_no_para && character != '\r' && character != '\n' && character != ' ')
+ {
+ xml_insert_element (BOOKINFO, START);
+ xml_insert_element (ABSTRACT, START);
+ in_abstract = 1;
+ }
+
+ if (xml_after_table_term && !xml_sort_index)
+ {
+ xml_after_table_term = 0;
+ xml_insert_element (ITEM, START);
+ }
+
+ if (xml_just_after_element && !xml_in_para && !inhibit_paragraph_indentation)
+ {
+ if (character == '\r' || character == '\n' || character == '\t' || character == ' ')
+ return;
+ xml_just_after_element = 0;
+ }
+
+ if (xml_element_list[xml_current_element()].contains_para
+ && !xml_in_para && !only_macro_expansion && !xml_no_para)
+ {
+ xml_indent ();
+ insert_string ("<para>\n");
+ xml_in_para = 1;
+ }
+
+ if (xml_in_para)
+ {
+ if (character == '\n')
+ {
+ if (xml_last_character == '\n' && !only_macro_expansion && !xml_no_para
+ && xml_element_list[xml_current_element()].contains_para )
+ {
+ xml_indent_end_para ();
+ insert_string ("</para>");
+ xml_in_para = 0;
+ xml_just_after_element = 1;
+ if (xml_in_menu_entry_comment)
+ {
+ xml_insert_element (MENUCOMMENT, END);
+ xml_in_menu_entry_comment = 0;
+ xml_insert_element (MENUENTRY, END);
+ xml_in_menu_entry = 0;
+ }
+ }
+ }
+ }
+
+ if (character == '\n' && !xml_in_para && !inhibit_paragraph_indentation)
+ return;
+
+ xml_last_character = character;
+
+ if (character == '&' && escape_html)
+ insert_string ("&amp;");
+ else if (character == '<' && escape_html)
+ insert_string ("&lt;");
+ else
+ insert (character);
+
+ return;
+}
+
+void
+xml_insert_footnote (note)
+ char *note;
+{
+ xml_insert_element (FOOTNOTE, START);
+ insert_string ("<para>");
+ execute_string ("%s", note);
+ insert_string ("</para>");
+ xml_insert_element (FOOTNOTE, END);
+}
+
+
+/*
+ * Lists and Tables
+ */
+static int xml_in_item[256];
+static int xml_table_level = 0;
+
+void
+xml_begin_table (type, item_function)
+ enum insertion_type type;
+ char *item_function;
+{
+ switch (type)
+ {
+ case ftable:
+ case vtable:
+ case table:
+ /*if (docbook)*/ /* 05-08 */
+ {
+ xml_insert_element (TABLE, START);
+ xml_table_level ++;
+ xml_in_item[xml_table_level] = 0;
+ }
+ break;
+ case itemize:
+ if (!docbook)
+ {
+ xml_insert_element (ITEMIZE, START);
+ xml_table_level ++;
+ xml_in_item[xml_table_level] = 0;
+ xml_insert_element (ITEMFUNCTION, START);
+ if (*item_function == COMMAND_PREFIX
+ && item_function[strlen (item_function) - 1] != '}'
+ && command_needs_braces (item_function + 1))
+ execute_string ("%s{}", item_function);
+ else
+ execute_string ("%s", item_function);
+ xml_insert_element (ITEMFUNCTION, END);
+ }
+ else
+ {
+ xml_insert_element_with_attribute (ITEMIZE, START,
+ "mark=\"%s\"",
+ (*item_function == COMMAND_PREFIX) ?
+ &item_function[1] : item_function);
+ xml_table_level ++;
+ xml_in_item[xml_table_level] = 0;
+ }
+ break;
+ }
+}
+
+void
+xml_end_table (type)
+ enum insertion_type type;
+{
+ switch (type)
+ {
+ case ftable:
+ case vtable:
+ case table:
+ /* if (docbook)*/ /* 05-08 */
+ {
+ if (xml_in_item[xml_table_level])
+ {
+ xml_insert_element (ITEM, END);
+ xml_insert_element (TABLEITEM, END);
+ xml_in_item[xml_table_level] = 0;
+ }
+ xml_insert_element (TABLE, END);
+ xml_table_level --;
+ }
+ break;
+ case itemize:
+ if (xml_in_item[xml_table_level])
+ {
+ xml_insert_element (ITEM, END);
+ xml_in_item[xml_table_level] = 0;
+ }
+ xml_insert_element (ITEMIZE, END);
+ xml_table_level --;
+ break;
+ }
+}
+
+void
+xml_begin_item ()
+{
+ if (xml_in_item[xml_table_level])
+ xml_insert_element (ITEM, END);
+
+ xml_insert_element (ITEM, START);
+ xml_in_item[xml_table_level] = 1;
+}
+
+void
+xml_begin_table_item ()
+{
+ if (!xml_after_table_term)
+ {
+ if (xml_in_item[xml_table_level])
+ {
+ xml_insert_element (ITEM, END);
+ xml_insert_element (TABLEITEM, END);
+ }
+ xml_insert_element (TABLEITEM, START);
+ }
+ xml_insert_element (TABLETERM, START);
+ xml_in_item[xml_table_level] = 1;
+ xml_after_table_term = 0;
+}
+
+void
+xml_continue_table_item ()
+{
+ xml_insert_element (TABLETERM, END);
+ xml_after_table_term = 1;
+}
+
+void
+xml_begin_enumerate (enum_arg)
+ char *enum_arg;
+{
+ if (!docbook)
+ xml_insert_element_with_attribute (ENUMERATE, START, "first=\"%s\"", enum_arg);
+ else
+ {
+ if (isdigit (*enum_arg))
+ {
+ if (enum_arg[0] == '1')
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "numeration=\"Arabic\"", NULL);
+ else
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "continuation=\"Continues\" numeration=\"Arabic\"", NULL);
+ }
+ else if (isupper (*enum_arg))
+ {
+ if (enum_arg[0] == 'A')
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "numeration=\"Upperalpha\"", NULL);
+ else
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "continuation=\"Continues\" numeration=\"Upperalpha\"", NULL);
+ }
+ else
+ {
+ if (enum_arg[0] == 'a')
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "numeration=\"Loweralpha\"", NULL);
+ else
+ xml_insert_element_with_attribute (ENUMERATE, START,
+ "continuation=\"Continues\" numeration=\"Loweralpha\"", NULL);
+ }
+ }
+ xml_table_level ++;
+ xml_in_item[xml_table_level] = 0;
+}
+
+void
+xml_end_enumerate ()
+{
+ if (xml_in_item[xml_table_level])
+ {
+ xml_insert_element (ITEM, END);
+ xml_in_item[xml_table_level] = 0;
+ }
+ xml_insert_element (ENUMERATE, END);
+ xml_table_level --;
+}
+
+static void
+xml_insert_text_file (name_arg)
+ char *name_arg;
+{
+ char *fullname = xmalloc (strlen (name_arg) + 4 + 1);
+ FILE *image_file;
+ strcpy (fullname, name_arg);
+ strcat (fullname, ".txt");
+ image_file = fopen (fullname, "r");
+ if (image_file)
+ {
+ int ch;
+ int save_inhibit_indentation = inhibit_paragraph_indentation;
+ int save_filling_enabled = filling_enabled;
+
+ xml_insert_element (TEXTOBJECT, START);
+ xml_insert_element (DISPLAY, START);
+
+ inhibit_paragraph_indentation = 1;
+ filling_enabled = 0;
+ last_char_was_newline = 0;
+
+ /* Maybe we need to remove the final newline if the image
+ file is only one line to allow in-line images. On the
+ other hand, they could just make the file without a
+ final newline. */
+ while ((ch = getc (image_file)) != EOF)
+ add_char (ch);
+
+ inhibit_paragraph_indentation = save_inhibit_indentation;
+ filling_enabled = save_filling_enabled;
+
+ xml_insert_element (DISPLAY, END);
+ xml_insert_element (TEXTOBJECT, END);
+
+ if (fclose (image_file) != 0)
+ perror (fullname);
+ }
+ else
+ warning (_("@image file `%s' unreadable: %s"), fullname,
+ strerror (errno));
+
+ free (fullname);
+}
+
+void
+xml_insert_docbook_image (name_arg)
+ char *name_arg;
+{
+ xml_insert_element (INFORMALFIGURE, START);
+ xml_insert_element (MEDIAOBJECT, START);
+
+ xml_insert_element (IMAGEOBJECT, START);
+ xml_insert_element_with_attribute (IMAGEDATA, START, "fileref=\"%s.eps\" format=\"eps\"", name_arg);
+ xml_pop_current_element ();
+ xml_insert_element (IMAGEOBJECT, END);
+
+ xml_insert_element (IMAGEOBJECT, START);
+ xml_insert_element_with_attribute (IMAGEDATA, START, "fileref=\"%s.jpg\" format=\"jpg\"", name_arg);
+ xml_pop_current_element ();
+ xml_insert_element (IMAGEOBJECT, END);
+
+ xml_insert_text_file (name_arg);
+
+ xml_insert_element (MEDIAOBJECT, END);
+ xml_insert_element (INFORMALFIGURE, END);
+}
+
+void
+xml_asterisk ()
+{
+}
+
+
+/*
+ * INDEX
+ */
+/* Used to separate primary and secondary entries in an index */
+#define INDEX_SEP ", "
+
+xml_insert_indexterm (indexterm, index)
+ char *indexterm;
+ char *index;
+{
+ if (!docbook)
+ {
+ xml_insert_element_with_attribute (INDEXTERM, START, "index=\"%s\"", index);
+ execute_string ("%s", indexterm);
+ xml_insert_element (INDEXTERM, END);
+ }
+ else
+ {
+ char *expanded;
+ char *primary = NULL, *secondary;
+ xml_sort_index = 1;
+ xml_no_para = 1;
+ expanded = expansion (indexterm);
+ xml_sort_index = 0;
+ xml_no_para = 0;
+ if (strstr (expanded+1, INDEX_SEP))
+ {
+ primary = xmalloc (strlen (expanded) + 1);
+ strcpy (primary, expanded);
+ secondary = strstr (primary+1, INDEX_SEP);
+ *secondary = '\0';
+ secondary += strlen (INDEX_SEP);
+ }
+ xml_insert_element_with_attribute (INDEXTERM, START, "role=\"%s\"", index);
+ xml_insert_element (PRIMARY, START);
+ if (primary)
+ insert_string (primary);
+ else
+ insert_string (expanded);
+ xml_insert_element (PRIMARY, END);
+ if (primary)
+ {
+ xml_insert_element (SECONDARY, START);
+ insert_string (secondary);
+ xml_insert_element (SECONDARY, END);
+ }
+ xml_insert_element (INDEXTERM, END);
+ free (expanded);
+ }
+}
+
+
+int xml_last_section_output_position = 0;
+static char last_division_letter = ' ';
+static char index_primary[2000]; /** xx no fixed limit */
+static int indexdivempty = 0;
+
+static int in_indexentry = 0;
+static int in_secondary = 0;
+static void
+xml_close_indexentry ()
+{
+ if (!in_indexentry)
+ return;
+ if (in_secondary)
+ xml_insert_element (SECONDARYIE, END);
+ xml_insert_element (INDEXENTRY, END);
+ in_secondary = 0;
+ in_indexentry = 0;
+}
+
+void
+xml_begin_index ()
+{
+ /*
+ We assume that we just opened a section, and so that the last output is
+ <SECTION ID="node-name"><TITLE>Title</TITLE>
+ where SECTION can be CHAPTER, ...
+ */
+
+ xml_section *temp = last_section;
+
+ int l = output_paragraph_offset-xml_last_section_output_position;
+ char *tmp = xmalloc (l+1);
+ char *p = tmp;
+ strncpy (tmp, output_paragraph, l);
+
+ /* We remove <SECTION */
+ tmp[l] = '\0';
+ while (*p != '<')
+ p++;
+ while (*p != ' ')
+ p++;
+
+ output_paragraph_offset = xml_last_section_output_position;
+ xml_last_section_output_position = 0;
+
+ xml_pop_current_element (); /* remove section element from elements stack */
+
+ last_section = last_section->prev; /* remove section from sections stack */
+ free (temp->name);
+ free (temp);
+
+ /* We put <INDEX> */
+ xml_insert_element (PRINTINDEX, START);
+ /* Remove the final > */
+ output_paragraph_offset--;
+
+ /* and put ID="node-name"><TITLE>Title</TITLE> */
+ insert_string (p);
+
+ if (xml_index_divisions)
+ {
+ xml_insert_element (INDEXDIV, START);
+ indexdivempty = 1;
+ }
+}
+
+void
+xml_end_index ()
+{
+ xml_close_indexentry ();
+ if (xml_index_divisions)
+ xml_insert_element (INDEXDIV, END);
+ xml_insert_element (PRINTINDEX, END);
+}
+
+void
+xml_index_divide (entry)
+ char *entry;
+{
+ char c;
+ if (strlen (entry) > (strlen (xml_element_list[CODE].name) + 2) &&
+ strncmp (entry+1, xml_element_list[CODE].name, strlen (xml_element_list[CODE].name)) == 0)
+ c = entry[strlen (xml_element_list[CODE].name)+2];
+ else
+ c = entry[0];
+ if (tolower (c) != last_division_letter && isalpha (c))
+ {
+ last_division_letter = tolower (c);
+ xml_close_indexentry ();
+ if (!indexdivempty)
+ {
+ xml_insert_element (INDEXDIV, END);
+ xml_insert_element (INDEXDIV, START);
+ }
+ xml_insert_element (TITLE, START);
+ insert (toupper (c));
+ xml_insert_element (TITLE, END);
+ }
+}
+
+void
+xml_insert_indexentry (entry, node)
+ char *entry;
+ char *node;
+{
+ char *primary = NULL, *secondary;
+ if (xml_index_divisions)
+ xml_index_divide (entry);
+
+ indexdivempty = 0;
+ if (strstr (entry+1, INDEX_SEP))
+ {
+ primary = xmalloc (strlen (entry) + 1);
+ strcpy (primary, entry);
+ secondary = strstr (primary+1, INDEX_SEP);
+ *secondary = '\0';
+ secondary += strlen (INDEX_SEP);
+
+ if (in_secondary && strcmp (primary, index_primary) == 0)
+ {
+ xml_insert_element (SECONDARYIE, END);
+ xml_insert_element (SECONDARYIE, START);
+ insert_string (secondary);
+ }
+ else
+ {
+ xml_close_indexentry ();
+ xml_insert_element (INDEXENTRY, START);
+ in_indexentry = 1;
+ xml_insert_element (PRIMARYIE, START);
+ insert_string (primary);
+ xml_insert_element (PRIMARYIE, END);
+ xml_insert_element (SECONDARYIE, START);
+ insert_string (secondary);
+ in_secondary = 1;
+ }
+ }
+ else
+ {
+ xml_close_indexentry ();
+ xml_insert_element (INDEXENTRY, START);
+ in_indexentry = 1;
+ xml_insert_element (PRIMARYIE, START);
+ insert_string (entry);
+ }
+ add_word_args (", %s", _("see "));
+ xml_insert_element_with_attribute (XREF, START, "linkend=\"%s\"", xml_id (node));
+ xml_pop_current_element ();
+
+ if (primary)
+ {
+ strcpy (index_primary, primary);
+ /* xml_insert_element (SECONDARYIE, END);*/
+ /* *(secondary-1) = ',';*/ /* necessary ? */
+ free (primary);
+ }
+ else
+ xml_insert_element (PRIMARYIE, END);
+
+ /* xml_insert_element (INDEXENTRY, END); */
+}
+
+/*
+ * MULTITABLE
+ */
+void
+xml_begin_multitable (ncolumns, column_widths)
+ int ncolumns;
+ int *column_widths;
+{
+ int i;
+ if (docbook)
+ {
+ xml_insert_element (MULTITABLE, START);
+ xml_insert_element_with_attribute (TGROUP, START, "cols=\"%d\"", ncolumns);
+ for (i=0; i<ncolumns; i++)
+ {
+ xml_insert_element_with_attribute (COLSPEC, START, "colwidth=\"%d*\"", column_widths[i]);
+ xml_pop_current_element ();
+ }
+ xml_insert_element (TBODY, START);
+ xml_no_para = 1;
+ }
+ else
+ {
+ xml_insert_element (MULTITABLE, START);
+ for (i=0; i<ncolumns; i++)
+ {
+ xml_insert_element (COLSPEC, START);
+ add_word_args ("%d", column_widths[i]);
+ xml_insert_element (COLSPEC, END);
+ }
+ xml_no_para = 1;
+ }
+}
+
+void
+xml_end_multitable_row (first_row)
+ int first_row;
+{
+ if (!first_row)
+ {
+ xml_insert_element (ENTRY, END);
+ xml_insert_element (ROW, END);
+ }
+ xml_insert_element (ROW, START);
+ xml_insert_element (ENTRY, START);
+}
+
+void
+xml_end_multitable_column ()
+{
+ xml_insert_element (ENTRY, END);
+ xml_insert_element (ENTRY, START);
+}
+
+void
+xml_end_multitable ()
+{
+ if (docbook)
+ {
+ xml_insert_element (ENTRY, END);
+ xml_insert_element (ROW, END);
+ xml_insert_element (TBODY, END);
+ xml_insert_element (TGROUP, END);
+ xml_insert_element (MULTITABLE, END);
+ xml_no_para = 0;
+ }
+ else
+ {
+ xml_insert_element (ENTRY, END);
+ xml_insert_element (ROW, END);
+ xml_insert_element (MULTITABLE, END);
+ xml_no_para = 0;
+ }
+}
diff --git a/gnu/usr.bin/texinfo/makeinfo/xml.h b/gnu/usr.bin/texinfo/makeinfo/xml.h
new file mode 100644
index 00000000000..e5849d37476
--- /dev/null
+++ b/gnu/usr.bin/texinfo/makeinfo/xml.h
@@ -0,0 +1,81 @@
+/* xml.h -- xml output declarations.
+ $Id: xml.h,v 1.1.1.1 2002/06/10 13:21:23 espie Exp $
+
+ Copyright (C) 2001, 02 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.
+
+ Written by Philippe Martin <feloy@free.fr>. */
+
+#ifndef XML_H
+#define XML_H
+
+/* Options. */
+
+/* Separate index entries into divisions for each letters. */
+extern int xml_index_divisions;
+extern int xml_sort_index;
+
+extern int xml_node_open;
+extern int xml_no_para;
+extern char *xml_node_id;
+extern int xml_last_section_output_position;
+
+enum xml_element
+{
+ TEXINFO=0, SETFILENAME, TITLEFONT, SETTITLE,
+ /* Node */
+ NODE /* 4 */, NODENEXT, NODEPREV, NODEUP,
+ /* Structuring */
+ CHAPTER /* 8 */, SECTION, SUBSECTION, SUBSUBSECTION,
+ TOP /* 12 */, UNNUMBERED, UNNUMBEREDSEC, UNNUMBEREDSUBSEC,
+ UNNUMBEREDSUBSUBSEC,
+ APPENDIX /* 17 */, APPENDIXSEC, APPENDIXSUBSEC, APPENDIXSUBSUBSEC,
+ MAJORHEADING /* 21 */, CHAPHEADING, HEADING, SUBHEADING, SUBSUBHEADING,
+ /* Menu */
+ MENU /* 26 */, MENUENTRY, MENUTITLE, MENUCOMMENT, MENUNODE, NODENAME,
+ /* -- */
+ ACRONYM/* 32 */, TT, CODE, KBD, URL, KEY, VAR, SC, DFN, EMPH, STRONG,
+ CITE, NOTFIXEDWIDTH, I, B, R,
+ TITLE,
+ IFINFO,
+ SP, CENTER,
+ DIRCATEGORY,
+ QUOTATION, EXAMPLE, SMALLEXAMPLE, LISP, SMALLLISP, CARTOUCHE,
+ COPYING, FORMAT, SMALLFORMAT, DISPLAY, SMALLDISPLAY,
+ FOOTNOTE,
+ ITEMIZE, ITEMFUNCTION, ITEM, ENUMERATE, TABLE, TABLEITEM, TABLETERM,
+ INDEXTERM,
+ XREF, XREFNODENAME, XREFINFONAME, XREFPRINTEDDESC, XREFINFOFILE,
+ XREFPRINTEDNAME,
+ INFOREF, INFOREFNODENAME, INFOREFREFNAME, INFOREFINFONAME,
+ UREF, UREFURL, UREFDESC, UREFREPLACEMENT,
+ EMAIL, EMAILADDRESS, EMAILNAME,
+ GROUP,
+ PRINTINDEX,
+ ANCHOR,
+ IMAGE,
+ PRIMARY, SECONDARY, INFORMALFIGURE, MEDIAOBJECT, IMAGEOBJECT,
+ IMAGEDATA, TEXTOBJECT,
+ INDEXENTRY, PRIMARYIE, SECONDARYIE, INDEXDIV,
+ MULTITABLE, TGROUP, COLSPEC, TBODY, ENTRY, ROW,
+ BOOKINFO, ABSTRACT, REPLACEABLE,
+ PARA
+};
+
+extern void xml_insert_element (/* int name, int arg */);
+extern char *xml_id (/* char *id */);
+
+#endif /* XML_H */