From 5500b59c459afe212e4ee8d1c1847e051a9b7653 Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 25 Mar 2002 13:08:32 +0000 Subject: Import of stripped down GNU texinfo 4.1 --- contrib/texinfo/makeinfo/README | 2 +- contrib/texinfo/makeinfo/cmds.c | 351 ++++++-- contrib/texinfo/makeinfo/defun.c | 137 +++- contrib/texinfo/makeinfo/docbook.c | 492 ++++++++++++ contrib/texinfo/makeinfo/docbook.h | 81 ++ contrib/texinfo/makeinfo/files.c | 97 ++- contrib/texinfo/makeinfo/files.h | 5 +- contrib/texinfo/makeinfo/footnote.c | 32 +- contrib/texinfo/makeinfo/html.c | 225 +++++- contrib/texinfo/makeinfo/html.h | 7 +- contrib/texinfo/makeinfo/index.c | 397 ++++----- contrib/texinfo/makeinfo/insertion.c | 269 ++++++- contrib/texinfo/makeinfo/insertion.h | 16 +- contrib/texinfo/makeinfo/lang.c | 419 ++++++++-- contrib/texinfo/makeinfo/lang.h | 75 +- contrib/texinfo/makeinfo/macro.c | 12 +- contrib/texinfo/makeinfo/makeinfo.c | 884 ++++++++++++++------ contrib/texinfo/makeinfo/makeinfo.h | 23 +- contrib/texinfo/makeinfo/multi.c | 51 +- contrib/texinfo/makeinfo/node.c | 403 ++++++++-- contrib/texinfo/makeinfo/node.h | 6 +- contrib/texinfo/makeinfo/sectioning.c | 77 +- contrib/texinfo/makeinfo/texinfo.dtd | 345 ++++++++ contrib/texinfo/makeinfo/texinfo.xsl | 242 ++++++ contrib/texinfo/makeinfo/toc.c | 178 ++-- contrib/texinfo/makeinfo/toc.h | 3 +- contrib/texinfo/makeinfo/xml.c | 1428 +++++++++++++++++++++++++++++++++ contrib/texinfo/makeinfo/xml.h | 76 ++ 28 files changed, 5438 insertions(+), 895 deletions(-) create mode 100644 contrib/texinfo/makeinfo/docbook.c create mode 100644 contrib/texinfo/makeinfo/docbook.h create mode 100644 contrib/texinfo/makeinfo/texinfo.dtd create mode 100644 contrib/texinfo/makeinfo/texinfo.xsl create mode 100644 contrib/texinfo/makeinfo/xml.c create mode 100644 contrib/texinfo/makeinfo/xml.h (limited to 'contrib/texinfo/makeinfo') diff --git a/contrib/texinfo/makeinfo/README b/contrib/texinfo/makeinfo/README index a6f97eb..1b45f02 100644 --- a/contrib/texinfo/makeinfo/README +++ b/contrib/texinfo/makeinfo/README @@ -2,7 +2,7 @@ makeinfo is a standalone program to convert Texinfo source into Info files readable with standalone info or M-x info in Emacs. makeinfo can also output plain ASCII (with --no-headers) -or HTML (with --html). +or HTML (with --html) or XML (with --xml). The Emacs function M-x texinfo-format-buffer does more or less the same job, but makeinfo is faster and gives better error messages. 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 @@ -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 ("
"); + 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 ? "..." : "..."); + { + if (xml && !docbook) + xml_insert_entity ("dots"); + else if (docbook) + xml_insert_entity ("hellip"); + else + add_word (html ? "..." : "..."); + } } /* Insert ellipsis for sentence end. */ @@ -394,7 +420,17 @@ cm_enddots (arg) int arg; { if (arg == START) - add_word (html ? "...." : "...."); + { + if (xml && !docbook) + xml_insert_entity ("enddots"); + else if (docbook) + { + xml_insert_entity ("hellip"); + add_char ('.'); + } + else + add_word (html ? "...." : "...."); + } } void @@ -405,6 +441,10 @@ cm_bullet (arg) { if (html) add_word ("•"); + 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 ("©"); + 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 ("<"); @@ -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 ? "<" : ">"); 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 */ + /* 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 ("
");
+
+  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 ("
"); +} + +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 ("%s", 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 ("

"); + add_word ("

"); 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 ("

"); + add_word ("
"); 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 diff --git a/contrib/texinfo/makeinfo/defun.c b/contrib/texinfo/makeinfo/defun.c index c62aba7..b261a99 100644 --- a/contrib/texinfo/makeinfo/defun.c +++ b/contrib/texinfo/makeinfo/defun.c @@ -1,7 +1,7 @@ /* defun.c -- @defun and friends. - $Id: defun.c,v 1.11 1999/07/11 16:50:19 karl Exp $ + $Id: defun.c,v 1.18 2002/01/22 18:01:24 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2000, 01, 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 @@ -19,6 +19,7 @@ #include "system.h" #include "defun.h" +#include "docbook.h" #include "insertion.h" #include "makeinfo.h" @@ -395,9 +396,9 @@ defun_internal (type, x_p) type_name = next_nonwhite_defun_arg (&scan_args); /* The type name for typed languages. */ - if (base_type == deftypemethod - || base_type == deftypeivar - || base_type == deftypeop + if ((base_type == deftypemethod) + || (base_type == deftypeivar) + || (base_type == deftypeop) ) type_name2 = next_nonwhite_defun_arg (&scan_args); @@ -422,6 +423,13 @@ defun_internal (type, x_p) defined_name = tem; } + /* It's easy to write @defun foo(arg1 arg2), but a following ( is + misparsed by texinfo.tex and this is next to impossible to fix. + Warn about it. */ + if (*scan_args && **scan_args && **scan_args == '(') + warning ("`%c' follows defined name `%s' instead of whitespace", + **scan_args, defined_name); + if (!x_p) begin_insertion (type); @@ -430,11 +438,15 @@ defun_internal (type, x_p) current_indent -= default_indentation_increment; start_paragraph (); - if (html && !x_p) + if (!x_p) { /* Start the definition on new paragraph. */ - add_word ("

\n"); + if (html) + add_word ("

\n"); + if (docbook) + docbook_begin_paragraph (); + } - if (!html) + if (!html && !docbook) switch (base_type) { case deffn: @@ -473,13 +485,16 @@ defun_internal (type, x_p) /* If this is not a @def...x version, it could only be a normal version @def.... So start the table here. */ if (!x_p) - add_word ("\n"); + { + add_html_elt ("
\n"); + } /* If this is an @def...x there has to be an other @def... before it, so this is only a new row within an existing table. With two complete standalone tables the gap between them is too big. */ add_word ("\n"); - add_word ("\n\n"); + add_html_elt ("\n\n\n\n"); + add_html_elt ("\n"); + add_html_elt ("\n"); + add_html_elt ("\n"); /* close second column */ add_word ("\n"); /* close row */ - + /* This is needed because I have to know if the next line is normal text or another @def..x. If text follows, create a new table to get the indentation for the following text. @@ -588,10 +645,10 @@ defun_internal (type, x_p) if (!looking_at ("@def")) { add_word ("
"); + add_html_elt (""); switch (base_type) { @@ -487,24 +502,61 @@ defun_internal (type, x_p) case defvr: case deftp: /* is for the following function arguments. */ - add_word_args ("%s", defined_name); + add_word (""); + execute_string ("%s", defined_name); + add_word (""); break; case deftypefn: case deftypevr: - add_word_args ("%s %s", type_name, defined_name); + execute_string ("%s ", type_name); + add_word (""); + execute_string ("%s", defined_name); + add_word (""); break; case defcv: case defop: - add_word_args ("%s", defined_name); + add_word (""); + execute_string ("%s", defined_name); + add_word (""); break; case deftypemethod: case deftypeop: case deftypeivar: - add_word_args ("%s %s", type_name2, defined_name); + execute_string ("%s ", type_name2); + add_word (""); + execute_string ("%s", defined_name); + add_word (""); break; } } /* if (html)... */ + if (docbook) + { + switch (base_type) + { + case deffn: + case defvr: + case deftp: + case defcv: + case defop: + add_word_args ("<%s>%s", DB_FUNCTION, defined_name, + DB_FUNCTION); + break; + case deftypefn: + case deftypevr: + add_word_args ("%s <%s>%s", type_name, DB_FUNCTION, + defined_name, DB_FUNCTION); + break; + case deftypemethod: + case deftypeop: + case deftypeivar: + add_word_args ("%s <%s>%s", type_name2, DB_FUNCTION, + defined_name, DB_FUNCTION); + break; + } + + } /* if (docbook)... */ + current_indent += default_indentation_increment; /* Now process the function arguments, if any. If these carry onto @@ -548,32 +600,37 @@ defun_internal (type, x_p) case deftypevr: add_word (""); /* close italic area for arguments */ /* put the rest into the second column */ - add_word_args ("%s", category); + add_word (""); + execute_string ("%s", category); break; - - case defcv: - add_word (""); - add_word_args ("%s %s %s", category, _("of"), type_name); - break; - - case defop: - case deftypemethod: - case deftypeop: - add_word (""); - add_word (""); - add_word_args ("%s %s %s", category, _("on"), type_name); - break; - - case deftypeivar: - add_word (""); - add_word (""); - add_word_args ("%s %s %s", category, _("of"), type_name); - break; - } /* switch (base_type)... */ - + + case defcv: + add_word (""); + execute_string ("%s %s %s", category, _("of"), type_name); + break; + + case defop: + case deftypemethod: + case deftypeop: + add_word (""); + add_word (""); + execute_string ("%s %s %s", category, _("on"), type_name); + break; + + case deftypeivar: + add_word (""); + add_word (""); + execute_string ("%s %s %s", category, _("of"), type_name); + break; + } /* switch (base_type)... */ + add_word ("
\n"); - add_word ("\n"); - add_word ("\n
\n"); + add_html_elt (""); + add_word ("\n\n
\n"); } - + } /* if (html)... */ /* Make an entry in the appropriate index. */ diff --git a/contrib/texinfo/makeinfo/docbook.c b/contrib/texinfo/makeinfo/docbook.c new file mode 100644 index 0000000..c9b05c2 --- /dev/null +++ b/contrib/texinfo/makeinfo/docbook.c @@ -0,0 +1,492 @@ +/* docbook.c -- docbook output. + $Id: docbook.c,v 1.3 2001/12/31 16:52:17 karl 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\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 ("\n\n"); + else + add_word ("\n\n"); + } + else + add_word_args ("\n\n", i); + } + + section_level = level; + + if (level == 0) + { + if (strcmp(cmd, "appendix") == 0) + add_word ("\n"); + add_word (""); + + 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 ("\n"); + + close_paragraph (); + filling_enabled = 1; + no_indent = old_no_indent; + docbook_no_new_paragraph--; + insert_string("\n"); + 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\n"); + else + insert_string ("\n\n\n\n"); + in_varlistitem = 1; + + return; + } + if (in_list) + return; + if (in_docbook_paragraph) + { + insert_string ("\n\n\n"); + adjust_braces_following (0, 10); + } + +#if 0 + if (docbook_must_insert_node_anchor) + { + char *tem; + insert_string ("\n"); + docbook_must_insert_node_anchor = 0; + } + else +#endif + { + insert_string ("\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 ("\n\ +\n%s\n", title); + --docbook_no_new_paragraph; +} + +void +docbook_end_book () +{ + int i; + if (in_docbook_paragraph) + { + insert_string ("\n\n\n"); + } + + for (i = section_level; i >= 0 ; i--) + { + if (i == 0) + add_word ("\n"); + else + add_word_args ("\n", i); + } + + add_word ("\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 (""); +} + +void +docbook_xref2 (node_name, ref_name) + char *node_name; + char *ref_name; +{ + char *tem; + add_word (""); +} + +int +docbook_quote (character) + int character; +{ + switch (language_code) + { + case fr: + if (character == '`') + { + add_word ("« "); + return ';'; + } + else + { + add_word (" "); + 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 (" "); + break; + } +} + +static int in_item = 0; + +void +docbook_begin_itemize () +{ + if (in_docbook_paragraph) + insert_string ("\n\n"); + + in_docbook_paragraph = 0; + insert_string ("\n\n"); + in_item = 0; + in_list = 1; +} + +void +docbook_end_itemize () +{ + if (in_item) + { + insert_string ("\n\n"); + in_item = 0; + } + insert_string ("\n\n\n\n"); + in_docbook_paragraph = 1; + in_list = 0; +} + +void +docbook_begin_enumerate () +{ + if (in_docbook_paragraph) + insert_string ("\n\n"); + in_docbook_paragraph = 0; + insert_string ("\n\n"); + in_item = 0; + in_list = 1; +} + +void +docbook_end_enumerate () +{ + if (in_item) + { + insert_string ("\n\n"); + in_item = 0; + } + insert_string ("\n\n\n\n"); + in_docbook_paragraph = 1; + in_list = 0; +} + +void +docbook_begin_table () +{ +#if 0 + if (in_docbook_paragraph) + insert_string ("\n\n\n"); + in_docbook_paragraph = 0; +#endif + + add_word ("\n\n"); + in_table ++; + in_varlistitem = 0; + in_entry = 0; +} + +void +docbook_end_table () +{ + if (!in_varlistitem) + docbook_begin_paragraph (); + insert_string ("\n\n\n\n\n"); +#if 0 + if (in_table == 1) + { + insert_string ("\n\n\n"); + in_docbook_paragraph = 0; + } + else + { + insert_string ("\n\n\n"); + in_docbook_paragraph = 1; + } +#endif + in_table --; + in_list = 0; +} + +void +docbook_add_item () +{ + if (in_item) + insert_string ("\n\n"); + insert_string ("\n\n"); + in_docbook_paragraph = 1; + in_item = 1; +} + +void +docbook_add_table_item () +{ + if (in_varlistitem) + { + insert_string ("\n\n\n\n"); + in_entry = 0; + in_varlistitem = 0; + } + if (!in_entry) + { + insert_string ("\n"); + in_entry = 1; + } + insert_string (""); + in_list = 1; + in_term = 1; +} + +void +docbook_close_table_item () +{ + insert_string (""); + in_list = 1; + in_term = 0; +} + +void +docbook_add_anchor (anchor) + char *anchor; +{ + add_word (""); +} + +void +docbook_footnote (note) + char *note; +{ + /* add_word_args ("\n%s\n\n", note); */ + add_word ("\n"); + execute_string("%s", note); + add_word("\n\n"); +} + +void +docbook_begin_index () +{ + add_word ("\n"); +} + +void +docbook_begin_example () +{ + add_word ("\n\n\n"); + in_example = 1; +} + +void +docbook_end_example () +{ + in_example = 0; + add_word ("\n\n"); +} diff --git a/contrib/texinfo/makeinfo/docbook.h b/contrib/texinfo/makeinfo/docbook.h new file mode 100644 index 0000000..6f0ca49 --- /dev/null +++ b/contrib/texinfo/makeinfo/docbook.h @@ -0,0 +1,81 @@ +/* docbook.h -- docbook declarations. + $Id: docbook.h,v 1.2 2001/12/31 16:51:32 karl 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/contrib/texinfo/makeinfo/files.c b/contrib/texinfo/makeinfo/files.c index ce8ace0..83c00e1 100644 --- a/contrib/texinfo/makeinfo/files.c +++ b/contrib/texinfo/makeinfo/files.c @@ -1,7 +1,7 @@ -/* files.c -- file-related functions for Texinfo. - $Id: files.c,v 1.5 1999/03/23 21:42:44 karl Exp $ +/* files.c -- file-related functions for makeinfo. + $Id: files.c,v 1.10 2002/01/16 15:52:45 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2000, 01, 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 @@ -139,9 +139,7 @@ find_and_load (filename) long file_size; int file = -1, count = 0; char *fullpath, *result; -#if O_BINARY || defined (VMS) - int n; -#endif + int n, bytes_to_read; result = fullpath = NULL; @@ -163,28 +161,18 @@ find_and_load (filename) /* VMS stat lies about the st_size value. The actual number of readable bytes is always less than this value. The arcane mysteries of VMS/RMS are too much to probe, so this hack - suffices to make things work. */ -#if O_BINARY || defined (VMS) -#ifdef VMS - while ((n = read (file, result + count, file_size)) > 0) -#else /* !VMS */ -#ifndef WIN32 - while ((n = read (file, result + count, file_size)) > 0) -#else /* WIN32 */ - /* Does WIN32 really need reading 1 character at a time?? */ - while ((n = read (file, result + count, 1)) > 0) -#endif /* WIN32 */ -#endif /* !VMS */ - count += n; + suffices to make things work. It's also needed on Cygwin. And so + we might as well use it everywhere. */ + bytes_to_read = file_size; + while ((n = read (file, result + count, bytes_to_read)) > 0) + { + count += n; + bytes_to_read -= n; + } if (0 < count && count < file_size) result = xrealloc (result, count + 2); /* why waste the slack? */ else if (n == -1) -#else /* !VMS && !O_BINARY */ - count = file_size; - if (read (file, result, file_size) != file_size) -#endif /* !VMS && !WIN32 */ - - error_exit: +error_exit: { if (result) free (result); @@ -527,3 +515,62 @@ output_name_from_input_name (name) { return expand_filename (NULL, name); } + + +/* Modify the file name FNAME so that it fits the limitations of the + underlying filesystem. In particular, truncate the file name as it + would be truncated by the filesystem. We assume the result can + never be longer than the original, otherwise we couldn't be sure we + have enough space in the original string to modify it in place. */ +char * +normalize_filename (fname) + char *fname; +{ + int maxlen; + char orig[PATH_MAX + 1]; + int i; + char *lastdot, *p; + +#ifdef _PC_NAME_MAX + maxlen = pathconf (fname, _PC_NAME_MAX); + if (maxlen < 1) +#endif + maxlen = PATH_MAX; + + i = skip_directory_part (fname); + if (fname[i] == '\0') + return fname; /* only a directory name -- don't modify */ + strcpy (orig, fname + i); + + switch (maxlen) + { + case 12: /* MS-DOS 8+3 filesystem */ + if (orig[0] == '.') /* leading dots are not allowed */ + orig[0] = '_'; + lastdot = strrchr (orig, '.'); + if (!lastdot) + lastdot = orig + strlen (orig); + strncpy (fname + i, orig, lastdot - orig); + for (p = fname + i; + p < fname + i + (lastdot - orig) && p < fname + i + 8; + p++) + if (*p == '.') + *p = '_'; + *p = '\0'; + if (*lastdot == '.') + strncat (fname + i, lastdot, 4); + break; + case 14: /* old Unix systems with 14-char limitation */ + strcpy (fname + i, orig); + if (strlen (fname + i) > 14) + fname[i + 14] = '\0'; + break; + default: + strcpy (fname + i, orig); + if (strlen (fname) > maxlen - 1) + fname[maxlen - 1] = '\0'; + break; + } + + return fname; +} diff --git a/contrib/texinfo/makeinfo/files.h b/contrib/texinfo/makeinfo/files.h index d96c444..88ae209 100644 --- a/contrib/texinfo/makeinfo/files.h +++ b/contrib/texinfo/makeinfo/files.h @@ -1,7 +1,7 @@ /* files.h -- declarations for files.c. - $Id: files.h,v 1.1 1998/10/24 21:37:25 karl Exp $ + $Id: files.h,v 1.2 2002/01/16 15:52:45 karl Exp $ - Copyright (C) 1998 Free Software Foundation, Inc. + Copyright (C) 1998, 2002 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 @@ -41,5 +41,6 @@ extern char *output_name_from_input_name (); extern char *expand_filename (); extern char *filename_part (); extern char *pathname_part (); +extern char *normalize_filename (); #endif /* !FILES_H */ diff --git a/contrib/texinfo/makeinfo/footnote.c b/contrib/texinfo/makeinfo/footnote.c index c1a056d..d9f2525 100644 --- a/contrib/texinfo/makeinfo/footnote.c +++ b/contrib/texinfo/makeinfo/footnote.c @@ -1,7 +1,7 @@ /* footnote.c -- footnotes for Texinfo. - $Id: footnote.c,v 1.10 1999/09/20 12:20:52 karl Exp $ + $Id: footnote.c,v 1.13 2002/03/02 15:05:21 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2002 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 @@ -21,6 +21,7 @@ #include "footnote.h" #include "macro.h" #include "makeinfo.h" +#include "xml.h" /* Nonzero means that the footnote style for this document was set on the command line, which overrides any other settings. */ @@ -200,6 +201,18 @@ cm_footnote () return; } + /* output_pending_notes is non-reentrant (it uses a global data + structure pending_notes, which it frees before it returns), and + TeX doesn't grok footnotes inside footnotes anyway. Disallow + that. */ + if (already_outputting_pending_notes) + { + line_error (_("Footnotes inside footnotes are not allowed")); + free (marker); + free (note); + return; + } + if (!*marker) { free (marker); @@ -213,14 +226,21 @@ cm_footnote () marker = xstrdup ("*"); } + if (xml) + xml_insert_footnote (note); + else + { remember_note (marker, note); /* fixme: html: footnote processing needs work; we currently ignore the style requested; we could clash with a node name of the form `fn-', though that's unlikely. */ if (html) - add_word_args ("%s", - current_footnote_number, marker); + { + add_html_elt ("%s", + current_footnote_number, marker); + } else /* Your method should at least insert MARKER. */ switch (footnote_style) @@ -255,7 +275,7 @@ cm_footnote () break; } current_footnote_number++; - + } free (marker); free (note); } @@ -328,7 +348,9 @@ output_pending_notes () /* Make the text of every footnote begin a separate paragraph. */ add_word_args ("
  • \n

    ", footnote->number); + already_outputting_pending_notes++; execute_string ("%s", footnote->note); + already_outputting_pending_notes--; add_word ("

    \n"); } else diff --git a/contrib/texinfo/makeinfo/html.c b/contrib/texinfo/makeinfo/html.c index f2e53e5..b7a8d59 100644 --- a/contrib/texinfo/makeinfo/html.c +++ b/contrib/texinfo/makeinfo/html.c @@ -1,7 +1,7 @@ /* html.c -- html-related utilities. - $Id: html.c,v 1.5 1999/09/18 19:27:41 karl Exp $ + $Id: html.c,v 1.19 2002/02/23 19:12:15 karl Exp $ - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 01, 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 @@ -30,27 +30,40 @@ int html_output_head_p = 0; void html_output_head () { - char *html_title; - + static char *html_title = NULL; + static int html_title_written = 0; + if (html_output_head_p) return; html_output_head_p = 1; - /* The should not have markup. */ - html_title = title ? text_expansion (title) : _("Untitled"); + /* The <title> should not have markup, so use text_expansion. */ + if (!html_title) + html_title = title ? text_expansion (title) : _("Untitled"); - add_word_args ("<html lang=\"%s\"><head>\n<title>%s\n", + add_word_args ("\n\n%s\n", language_table[language_code].abbrev, html_title); add_word ("\n"); - - add_word_args ("\n", html_title); + + if (!document_description) + document_description = html_title; + + add_word_args ("\n", + document_description); add_word_args ("\n", VERSION); add_word ("\n"); - add_word ("\n\n"); + add_word ("\n\n"); + + if (title && !html_title_written) + { + add_word_args ("

    %s

    \n", html_title); + html_title_written = 1; + } } @@ -78,13 +91,12 @@ escape_string (string) default: newlen++; } - i++; } - while (string[i]); + while (string[i++]); if (newlen == i) return string; /* Already OK. */ - newstring = xmalloc (newlen + 2); + newstring = xmalloc (newlen); i = 0; do { @@ -109,7 +121,7 @@ escape_string (string) } while (string[i++]); free (string); - return newstring - newlen -1; + return newstring - newlen; } /* Open or close TAG according to START_OR_END. */ @@ -136,14 +148,16 @@ insert_html_tag (start_or_end, tag) /* Output an HTML to the filename for NODE, including the other string as extra attributes. */ void -add_link (node, attributes) - char *node, *attributes; +add_link (nodename, attributes) + char *nodename, *attributes; { - if (node) + if (nodename) { - add_word_args ("\n"); + add_html_elt ("\n"); } } @@ -176,7 +190,170 @@ add_anchor_name (nodename, href) int href; { if (href) - add_char ('#'); + { + if (splitting) + add_url_name (nodename, href); + add_char ('#'); + } + /* Always add NODENAME, so that the reference would pinpoint the + exact node on its file. This is so several nodes could share the + same file, in case of file-name clashes, but also for more + accurate browser positioning. */ + if (strcasecmp (nodename, "(dir)") == 0) + /* Strip the parens, but keep the original letter-case. */ + add_word_args ("%.3s", nodename + 1); + else + add_escaped_anchor_name (nodename); +} + +/* Insert the text for the name of a reference in an HTML url, aprropriate + for NODENAME */ +void +add_url_name (nodename, href) + char *nodename; + int href; +{ + add_nodename_to_filename (nodename, href); +} + +/* Only allow [-0-9a-zA-Z_.] when nodifying filenames. This may + result in filename clashes; e.g., + + @node Foo ],,, + @node Foo [,,, + + both map to Foo--.html. If that happens, cm_node will put all + the nodes whose file names clash on the same file. */ +void +fix_filename (filename) + char *filename; +{ + char *p; + for (p = filename; *p; p++) + { + if (!(isalnum (*p) || strchr ("-._", *p))) + *p = '-'; + } +} + +/* As we can't look-up a (forward-referenced) nodes' html filename + from the tentry, we take the easy way out. We assume that + nodenames are unique, and generate the html filename from the + nodename, that's always known. */ +static char * +nodename_to_filename_1 (nodename, href) + char *nodename; + int href; +{ + char *p; + char *filename; + char dirname[PATH_MAX]; - add_escaped_anchor_name (nodename); + if (strcasecmp (nodename, "Top") == 0) + { + /* We want to convert references to the Top node into + "index.html#Top". */ + if (href) + filename = xstrdup ("index.html"); /* "#Top" is added by our callers */ + else + filename = xstrdup ("Top"); + } + else if (strcasecmp (nodename, "(dir)") == 0) + /* We want to convert references to the (dir) node into + "../index.html". */ + filename = xstrdup ("../index.html"); + else + { + filename = xmalloc (PATH_MAX); + dirname[0] = '\0'; + *filename = '\0'; + + /* Check for external reference: ``(info-document)node-name'' + Assume this node lives at: ``../info-document/node-name.html'' + + We need to handle the special case (sigh): ``(info-document)'', + ie, an external top-node, which should translate to: + ``../info-document/info-document.html'' */ + + p = nodename; + if (*nodename == '(') + { + int length; + + p = strchr (nodename, ')'); + if (p == NULL) + { + line_error (_("Invalid node name: `%s'"), nodename); + exit (1); + } + + length = p - nodename - 1; + if (length > 5 && + FILENAME_CMPN (p - 5, ".info", 5) == 0) + length -= 5; + /* This is for DOS, and also for Windows and GNU/Linux + systems that might have Info files copied from a DOS 8+3 + filesystem. */ + if (length > 4 && + FILENAME_CMPN (p - 4, ".inf", 4) == 0) + length -= 4; + strcpy (filename, "../"); + strncpy (dirname, nodename + 1, length); + *(dirname + length) = '\0'; + fix_filename (dirname); + strcat (filename, dirname); + strcat (filename, "/"); + p++; + } + + /* In the case of just (info-document), there will be nothing + remaining, and we will refer to ../info-document/, which will + work fine. */ + strcat (filename, p); + if (*p) + { + /* Hmm */ + fix_filename (filename + strlen (filename) - strlen (p)); + strcat (filename, ".html"); + } + } + + /* Produce a file name suitable for the underlying filesystem. */ + normalize_filename (filename); + +#if 0 + /* We add ``#Nodified-filename'' anchor to external references to be + prepared for non-split HTML support. Maybe drop this. */ + if (href && *dirname) + { + strcat (filename, "#"); + strcat (filename, p); + /* Hmm, again */ + fix_filename (filename + strlen (filename) - strlen (p)); + } +#endif + + return filename; +} + +/* If necessary, ie, if current filename != filename of node, output + the node name. */ +void +add_nodename_to_filename (nodename, href) + char *nodename; + int href; +{ + /* for now, don't check: always output filename */ + char *filename = nodename_to_filename_1 (nodename, href); + add_word (filename); + free (filename); +} + +char * +nodename_to_filename (nodename) + char *nodename; +{ + /* The callers of nodename_to_filename use the result to produce + defining_file = xstrdup (input_filename); the_indices[which] = new; + /* The index breaks if there are colons in the entry. */ + if (strchr (new->entry_text, ':')) + warning (_("Info cannot handle `:' in index entry `%s'"), + new->entry_text); } + if (xml) + xml_insert_indexterm (index_entry, name); } /* The function which user defined index commands call. */ @@ -583,7 +590,7 @@ sort_index (index) /* If this particular entry should be printed as a "code" index, then expand it as @code{entry}, i.e. as in fixed-width font. */ array[count-1]->entry = expansion (temp->entry_text, - array[count-1]->code); + array[count-1]->code); temp = temp->next; } @@ -621,203 +628,225 @@ int printing_index = 0; void cm_printindex () { - int item; - INDEX_ELT *index; - INDEX_ELT *last_index = 0; - INDEX_ELT **array; - char *index_name; - unsigned line_length; - char *line; - int saved_inhibit_paragraph_indentation = inhibit_paragraph_indentation; - int saved_filling_enabled = filling_enabled; - int saved_line_number = line_number; - char *saved_input_filename = input_filename; - - close_paragraph (); - get_rest_of_line (0, &index_name); - - index = index_list (index_name); - if (index == (INDEX_ELT *)-1) + if (xml && !docbook) { - line_error (_("Unknown index `%s' in @printindex"), index_name); - free (index_name); - return; + char *index_name; + get_rest_of_line (0, &index_name); + xml_insert_element (PRINTINDEX, START); + insert_string (index_name); + xml_insert_element (PRINTINDEX, END); } - - /* Do this before sorting, so execute_string in index_element_compare - will give the same results as when we actually print. */ - printing_index = 1; - filling_enabled = 0; - inhibit_paragraph_indentation = 1; - array = sort_index (index); - - close_paragraph (); - if (html) - add_word (""); } diff --git a/contrib/texinfo/makeinfo/insertion.c b/contrib/texinfo/makeinfo/insertion.c index 11b9089..c7087f2 100644 --- a/contrib/texinfo/makeinfo/insertion.c +++ b/contrib/texinfo/makeinfo/insertion.c @@ -1,7 +1,7 @@ /* insertion.c -- insertions for Texinfo. - $Id: insertion.c,v 1.27 1999/07/06 23:12:53 karl Exp $ + $Id: insertion.c,v 1.39 2002/03/02 15:05:21 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2000, 01, 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 @@ -23,20 +23,21 @@ #include "insertion.h" #include "macro.h" #include "makeinfo.h" +#include "xml.h" /* Must match list in insertion.h. */ static char *insertion_type_names[] = -{ +{ "cartouche", "defcv", "deffn", "defivar", "defmac", "defmethod", "defop", "defopt", "defspec", "deftp", "deftypefn", "deftypefun", "deftypeivar", "deftypemethod", "deftypeop", "deftypevar", "deftypevr", "defun", "defvar", "defvr", "detailmenu", "direntry", - "display", "enumerate", "example", "flushleft", "flushright", - "format", "ftable", "group", "ifclear", "ifhtml", "ifinfo", - "ifnothtml", "ifnotinfo", "ifnottex", "ifset", "iftex", "itemize", - "lisp", "menu", "multitable", "quotation", "rawhtml", "rawtex", - "smalldisplay", "smallexample", "smallformat", "smalllisp", "table", - "tex", "vtable", "bad_type" + "display", "documentdescription", "enumerate", "example", "flushleft", + "flushright", "format", "ftable", "group", "ifclear", "ifhtml", + "ifinfo", "ifnothtml", "ifnotinfo", "ifnottex", "ifset", "iftex", + "itemize", "lisp", "menu", "multitable", "quotation", "rawhtml", + "rawtex", "smalldisplay", "smallexample", "smallformat", "smalllisp", + "verbatim", "table", "tex", "vtable", "bad_type" }; /* All nested environments. */ @@ -359,7 +360,9 @@ begin_insertion (type) no_discard++; } else - push_insertion (type, get_item_function ()); + { + push_insertion (type, get_item_function ()); + } switch (type) { @@ -374,9 +377,12 @@ begin_insertion (type) { had_menu_commentary = 1; } - else if (!no_headers) + else if (!no_headers && !xml) add_word ("* Menu:\n"); + if (xml) + xml_insert_element (MENU, START); + in_menu++; in_fixed_width_font++; no_discard++; @@ -399,15 +405,29 @@ begin_insertion (type) break; case direntry: - if (html) - command_name_condition (); - else - { - close_single_paragraph (); - filling_enabled = no_indent = 0; - inhibit_paragraph_indentation = 1; - insert_string ("START-INFO-DIR-ENTRY\n"); - } + close_single_paragraph (); + filling_enabled = no_indent = 0; + inhibit_paragraph_indentation = 1; + insert_string ("START-INFO-DIR-ENTRY\n"); + break; + + case documentdescription: + { + char *desc; + int start_of_end; + int save_fixed_width; + + discard_until ("\n"); /* ignore the @documentdescription line */ + start_of_end = get_until ("\n@end documentdescription", &desc); + save_fixed_width = in_fixed_width_font; + + in_fixed_width_font = 0; + document_description = expansion (desc, 0); + free (desc); + + in_fixed_width_font = save_fixed_width; + input_text_offset = start_of_end; /* go back to the @end to match */ + } break; case quotation: @@ -443,7 +463,7 @@ begin_insertion (type) /* Kludge alert: if
     is followed by a newline, IE3
                renders an extra blank line before the pre-formatted block.
                Other browsers seem to not mind one way or the other.  */
    -        add_word ("
    ");
    +        add_word ("
    ");
     
           if (type != format && type != smallformat)
             current_indent += default_indentation_increment;
    @@ -492,6 +512,8 @@ begin_insertion (type)
               else
                 add_word (dl_tag);
             }
    +      if (xml)
    +	xml_begin_table (type, insertion_stack->item_function);
           break;
     
         case enumerate:
    @@ -509,6 +531,9 @@ begin_insertion (type)
           if (html)
             enum_html ();
     
    +      if (xml)
    +	xml_begin_enumerate (enumeration_arg);
    +      
           if (isdigit (*enumeration_arg))
             start_enumerating (atoi (enumeration_arg), ENUM_DIGITS);
           else
    @@ -519,7 +544,9 @@ begin_insertion (type)
         case group:
           /* Only close the paragraph if we are not inside of an
              @example-like environment. */
    -      if (!insertion_stack->next
    +      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
    @@ -581,6 +608,8 @@ begin_insertion (type)
           close_single_paragraph ();
           inhibit_paragraph_indentation = 1;
           filling_enabled = indented_fill = no_indent = 0;
    +      if (html)
    +	add_word ("
    "); break; case flushright: @@ -588,6 +617,8 @@ begin_insertion (type) filling_enabled = indented_fill = no_indent = 0; inhibit_paragraph_indentation = 1; force_flush_right++; + if (html) + add_word ("
    "); break; default: @@ -627,12 +658,64 @@ end_insertion (type) pop_insertion (); + if (xml) + { + switch (type) + { + case ifinfo: + case documentdescription: + break; + case quotation: + xml_insert_element (QUOTATION, END); + break; + case example: + xml_insert_element (EXAMPLE, END); + break; + case smallexample: + xml_insert_element (SMALLEXAMPLE, END); + break; + case lisp: + xml_insert_element (LISP, END); + break; + case smalllisp: + xml_insert_element (SMALLLISP, END); + break; + case cartouche: + xml_insert_element (CARTOUCHE, END); + break; + case format: + 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 (type); + break; + case group: + xml_insert_element (GROUP, END); + break; + } + } switch (type) { /* Insertions which have no effect on paragraph formatting. */ + case documentdescription: case ifclear: - case ifhtml: case ifinfo: + case ifhtml: case ifnothtml: case ifnotinfo: case ifnottex: @@ -680,6 +763,11 @@ end_insertion (type) break; case flushleft: + if (html) + add_word ("
    \n"); + close_insertion_paragraph (); + break; + case group: case cartouche: close_insertion_paragraph (); @@ -724,6 +812,8 @@ end_insertion (type) case flushright: force_flush_right--; + if (html) + add_word ("
    \n"); close_insertion_paragraph (); break; @@ -750,7 +840,7 @@ end_insertion (type) case deftypeivar: if (html) /* close the tables which has been opened in defun.c */ - add_word ("
  • \n"); + add_word ("
    \n"); break; } /* switch (base_type)... */ @@ -790,12 +880,11 @@ discard_insertions (specials_ok) else { char *offender = insertion_type_pname (insertion_stack->insertion); - char *current_filename = input_filename; - input_filename = insertion_stack->filename; - line_number = insertion_stack->line_number; - line_error (_("No matching `%cend %s'"), COMMAND_PREFIX, offender); - input_filename = current_filename; + file_line_error (insertion_stack->filename, + insertion_stack->line_number, + _("No matching `%cend %s'"), COMMAND_PREFIX, + offender); pop_insertion (); } } @@ -807,75 +896,103 @@ discard_insertions (specials_ok) void cm_quotation () { + if (xml) + xml_insert_element (QUOTATION, START); begin_insertion (quotation); } void cm_example () { + if (xml) + xml_insert_element (EXAMPLE, START); begin_insertion (example); } void cm_smallexample () { + if (xml) + xml_insert_element (SMALLEXAMPLE, START); begin_insertion (smallexample); } void cm_lisp () { + if (xml) + xml_insert_element (LISP, START); begin_insertion (lisp); } void cm_smalllisp () { + if (xml) + xml_insert_element (SMALLLISP, START); begin_insertion (smalllisp); } -/* @cartouche/@end cartouche draws box with rounded corners in - TeX output. Right now, just a no-op insertion. */ void cm_cartouche () { + if (xml) + xml_insert_element (CARTOUCHE, START); begin_insertion (cartouche); } void cm_format () { + if (xml) + xml_insert_element (FORMAT, START); begin_insertion (format); } void cm_smallformat () { + if (xml) + xml_insert_element (SMALLFORMAT, START); begin_insertion (smallformat); } void cm_display () { + if (xml) + xml_insert_element (DISPLAY, START); begin_insertion (display); } void cm_smalldisplay () { + if (xml) + xml_insert_element (SMALLDISPLAY, START); begin_insertion (smalldisplay); } void cm_direntry () { - if (no_headers || html) + if (html || xml) command_name_condition (); else begin_insertion (direntry); } void +cm_documentdescription () +{ + if (html || xml) + begin_insertion (documentdescription); + else + command_name_condition (); +} + + +void cm_itemize () { begin_insertion (itemize); @@ -918,6 +1035,77 @@ cm_enumerate () do_enumeration (enumerate, "1"); } +/* Handle verbatim environment: + find_end_verbatim == 0: process until end of file + find_end_verbatim != 0: process until 'COMMAND_PREFIXend verbatim' + or end of file + + We cannot simply copy input stream onto output stream; as the + verbatim environment may be encapsulated in an @example environment, + for example. */ +void +handle_verbatim_environment (find_end_verbatim) + int find_end_verbatim; +{ + int character; + int seen_end = 0; + int save_filling_enabled = filling_enabled; + int save_inhibit_paragraph_indentation = inhibit_paragraph_indentation; + + close_single_paragraph (); + inhibit_paragraph_indentation = 1; + filling_enabled = 0; + in_fixed_width_font++; + last_char_was_newline = 0; + + /* No indentation: this is verbatim after all + If you want indent, enclose @verbatim in @example + current_indent += default_indentation_increment; + */ + + if (html) + add_word ("

    ");
    +
    +  while (input_text_offset < input_text_length)
    +    {
    +      character = curchar ();
    +
    +      if (character == '\n')
    +        line_number++;
    +      /*
    +	Assume no newlines in END_VERBATIM
    +      */
    +      else if (find_end_verbatim && (character == COMMAND_PREFIX) /* @ */
    +	  && (input_text_length - input_text_offset > 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;
    +	}
    +
    +      add_char (character);
    +      input_text_offset++;
    +    }
    +
    +  if (find_end_verbatim && !seen_end)
    +    warning (_("end of file inside verbatim block"));
    +
    +  if (html)
    +    add_word ("
    "); + + in_fixed_width_font--; + filling_enabled = save_filling_enabled; + inhibit_paragraph_indentation = save_inhibit_paragraph_indentation; +} + +void +cm_verbatim () +{ + handle_verbatim_environment (1); +} + void cm_table () { @@ -1087,6 +1275,10 @@ cm_end () line_error (_("Bad argument to `%s', `%s', using `%s'"), command, temp, insertion_type_pname (current_insertion_type ())); } + if (xml && type == menu) /* fixme */ + { + xml_end_menu (); + } end_insertion (type); free (temp); } @@ -1096,7 +1288,7 @@ cm_end () static int itemx_flag = 0; /* Return whether CMD takes a brace-delimited {arg}. */ -static int +/*static */int command_needs_braces (cmd) char *cmd; { @@ -1195,6 +1387,8 @@ cm_item () } add_word ("
  • "); } + else if (xml) + xml_begin_item (); else { start_paragraph (); @@ -1289,6 +1483,15 @@ cm_item () last_html_output_position = output_position; add_word ("
    "); } + else if (xml) /* && docbook)*/ /* 05-08 */ + { + xml_begin_table_item (); + if (item_func && *item_func) + execute_string ("%s{%s}", item_func, rest_of_line); + else + execute_string ("%s", rest_of_line); + xml_continue_table_item (); + } else { /* We need this to determine if we have two @item's in a row diff --git a/contrib/texinfo/makeinfo/insertion.h b/contrib/texinfo/makeinfo/insertion.h index 6f4a24b..51540b2 100644 --- a/contrib/texinfo/makeinfo/insertion.h +++ b/contrib/texinfo/makeinfo/insertion.h @@ -1,7 +1,7 @@ /* insertion.h -- declarations for insertion.c. - $Id: insertion.h,v 1.6 1999/07/06 23:12:58 karl Exp $ + $Id: insertion.h,v 1.8 2001/06/30 00:29:41 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 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 @@ -22,15 +22,15 @@ /* Must match list in insertion.c. */ enum insertion_type -{ +{ cartouche, defcv, deffn, defivar, defmac, defmethod, defop, defopt, defspec, deftp, deftypefn, deftypefun, deftypeivar, deftypemethod, deftypeop, deftypevar, deftypevr, defun, defvar, defvr, detailmenu, - direntry, display, enumerate, example, flushleft, flushright, format, - ftable, group, ifclear, ifhtml, ifinfo, ifnothtml, ifnotinfo, - ifnottex, ifset, iftex, itemize, lisp, menu, multitable, quotation, - rawhtml, rawtex, smalldisplay, smallexample, smallformat, smalllisp, - table, tex, vtable, bad_type + direntry, display, documentdescription, enumerate, example, flushleft, + flushright, format, ftable, group, ifclear, ifhtml, ifinfo, ifnothtml, + ifnotinfo, ifnottex, ifset, iftex, itemize, lisp, menu, multitable, + quotation, rawhtml, rawtex, smalldisplay, smallexample, smallformat, + smalllisp, verbatim, table, tex, vtable, bad_type }; typedef struct istack_elt diff --git a/contrib/texinfo/makeinfo/lang.c b/contrib/texinfo/makeinfo/lang.c index eeb9ef5..468bed8 100644 --- a/contrib/texinfo/makeinfo/lang.c +++ b/contrib/texinfo/makeinfo/lang.c @@ -1,7 +1,7 @@ -/* lang.c -- language depend behaviour (startpoint) - $Id: lang.c,v 1.11 1999/07/13 21:16:29 karl Exp $ +/* lang.c -- language-dependent support. + $Id: lang.c,v 1.14 2001/09/11 18:04:35 karl Exp $ - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 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 @@ -17,20 +17,150 @@ 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 Karl Heinz Marbaise . */ + Originally written by Karl Heinz Marbaise . */ #include "system.h" #include "cmds.h" #include "lang.h" #include "makeinfo.h" +#include "xml.h" /* Current document encoding. */ -char *document_encoding = NULL; +encoding_code_type document_encoding_code = no_encoding; /* Current language code; default is English. */ language_code_type language_code = en; -language_struct language_table[] = { +/* Translation table between HTML and ISO Codes. The last item is + hopefully the Unicode. It might be possible that those Unicodes are + not correct, cause I didn't check them. kama */ +iso_map_type iso8859_1_map [] = { + { "nbsp", 0xA0, 0x00A0 }, + { "iexcl", 0xA1, 0x00A1 }, + { "cent", 0xA2, 0x00A2 }, + { "pound", 0xA3, 0x00A3 }, + { "curren", 0xA4, 0x00A4 }, + { "yen", 0xA5, 0x00A5 }, + { "brkbar", 0xA6, 0x00A6 }, + { "sect", 0xA7, 0x00A7 }, + { "uml", 0xA8, 0x00A8 }, + { "copy", 0xA9, 0x00A9 }, + { "ordf", 0xAA, 0x00AA }, + { "laquo", 0xAB, 0x00AB }, + { "not", 0xAC, 0x00AC }, + { "shy", 0xAD, 0x00AD }, + { "reg", 0xAE, 0x00AE }, + { "hibar", 0xAF, 0x00AF }, + { "deg", 0xB0, 0x00B0 }, + { "plusmn", 0xB1, 0x00B1 }, + { "sup2", 0xB2, 0x00B2 }, + { "sup3", 0xB3, 0x00B3 }, + { "acute", 0xB4, 0x00B4 }, + { "micro", 0xB5, 0x00B5 }, + { "para", 0xB6, 0x00B6 }, + { "middot", 0xB7, 0x00B7 }, + { "cedil", 0xB8, 0x00B8 }, + { "sup1", 0xB9, 0x00B9 }, + { "ordm", 0xBA, 0x00BA }, + { "raquo", 0xBB, 0x00BB }, + { "frac14", 0xBC, 0x00BC }, + { "frac12", 0xBD, 0x00BD }, + { "frac34", 0xBE, 0x00BE }, + { "iquest", 0xBF, 0x00BF }, + { "Agrave", 0xC0, 0x00C0 }, + { "Aacute", 0xC1, 0x00C1 }, + { "Acirc", 0xC2, 0x00C2 }, + { "Atilde", 0xC3, 0x00C3 }, + { "Auml", 0xC4, 0x00C4 }, + { "Aring", 0xC5, 0x00C5 }, + { "AElig", 0xC6, 0x00C6 }, + { "Ccedil", 0xC7, 0x00C7 }, + { "Ccedil", 0xC7, 0x00C7 }, + { "Egrave", 0xC8, 0x00C8 }, + { "Eacute", 0xC9, 0x00C9 }, + { "Ecirc", 0xCA, 0x00CA }, + { "Euml", 0xCB, 0x00CB }, + { "Igrave", 0xCC, 0x00CC }, + { "Iacute", 0xCD, 0x00CD }, + { "Icirc", 0xCE, 0x00CE }, + { "Iuml", 0xCF, 0x00CF }, + { "ETH", 0xD0, 0x00D0 }, /* I don't know ;-( */ + { "Ntilde", 0xD1, 0x00D1 }, + { "Ograve", 0xD2, 0x00D2 }, + { "Oacute", 0xD3, 0x00D3 }, + { "Ocirc", 0xD4, 0x00D4 }, + { "Otilde", 0xD5, 0x00D5 }, + { "Ouml", 0xD6, 0x00D6 }, + { "times", 0xD7, 0x00D7 }, + { "Oslash", 0xD8, 0x00D8 }, + { "Ugrave", 0xD9, 0x00D9 }, + { "Uacute", 0xDA, 0x00DA }, + { "Ucirc", 0xDB, 0x00DB }, + { "Uuml", 0xDC, 0x00DC }, + { "Yacute", 0xDD, 0x00DD }, + { "THORN", 0xDE, 0x00DE }, + { "szlig", 0xDF, 0x00DF }, + { "agrave", 0xE0, 0x00E0 }, + { "aacute", 0xE1, 0x00E1 }, + { "acirc", 0xE2, 0x00E2 }, + { "atilde", 0xE3, 0x00E3 }, + { "auml", 0xE4, 0x00E4 }, + { "aring", 0xE5, 0x00E5 }, + { "aelig", 0xE6, 0x00E6 }, + { "ccedil", 0xE7, 0x00E7 }, + { "egrave", 0xE8, 0x00E8 }, + { "eacute", 0xE9, 0x00E9 }, + { "ecirc", 0xEA, 0x00EA }, + { "euml", 0xEB, 0x00EB }, + { "igrave", 0xEC, 0x00EC }, + { "iacute", 0xED, 0x00ED }, + { "icirc", 0xEE, 0x00EE }, + { "iuml", 0xEF, 0x00EF }, + { "eth", 0xF0, 0x00F0 }, + { "ntilde", 0xF1, 0x00F1 }, + { "ograve", 0xF2, 0x00F2 }, + { "oacute", 0xF3, 0x00F3 }, + { "ocirc", 0xF4, 0x00F4 }, + { "otilde", 0xF5, 0x00F5 }, + { "ouml", 0xF6, 0x00F6 }, + { "divide", 0xF7, 0x00F7 }, + { "oslash", 0xF8, 0x00F8 }, + { "ugrave", 0xF9, 0x00F9 }, + { "uacute", 0xFA, 0x00FA }, + { "ucirc", 0xFB, 0x00FB }, + { "uuml", 0xFC, 0x00FC }, + { "yacute", 0xFD, 0x00FD }, + { "thorn", 0xFE, 0x00FE }, + { "yuml", 0xFF, 0x00FF } +}; + +/* This might be put into structure below and NOT coded via define, + because some translation tables could contain different numbers of + characters, but for now it suffices. */ +#define ISO_MAP_SIZE (sizeof (iso8859_1_map) / sizeof (iso8859_1_map[0])) + +encoding_type encoding_table[] = { + { no_encoding, "(no encoding)", NULL }, + { ISO_8859_1, "ISO-8859-1", (iso_map_type *) iso8859_1_map }, + { ISO_8859_2, "ISO-8859-2", NULL }, + { ISO_8859_3, "ISO-8859-3", NULL }, + { ISO_8859_4, "ISO-8859-4", NULL }, + { ISO_8859_5, "ISO-8859-5", NULL }, + { ISO_8859_6, "ISO-8859-6", NULL }, + { ISO_8859_7, "ISO-8859-7", NULL }, + { ISO_8859_8, "ISO-8859-8", NULL }, + { ISO_8859_9, "ISO-8859-9", NULL }, + { ISO_8859_10, "ISO-8859-10", NULL }, + { ISO_8859_11, "ISO-8859-11", NULL }, + { ISO_8859_12, "ISO-8859-12", NULL }, + { ISO_8859_13, "ISO-8859-13", NULL }, + { ISO_8859_14, "ISO-8859-14", NULL }, + { ISO_8859_15, "ISO-8859-15", NULL }, + { last_encoding_code, NULL, NULL } +}; + + +language_type language_table[] = { { aa, "aa", "Afar" }, { ab, "ab", "Abkhazian" }, { af, "af", "Afrikaans" }, @@ -173,16 +303,18 @@ language_struct language_table[] = { { last_language_code, NULL, NULL } }; + + /* @documentlanguage. Maybe we'll do something useful with this in the future. For now, we just recognize it. */ void cm_documentlanguage () { language_code_type c; - char *lang_arg; + char *lang_arg; /* Read the line with the language code on it. */ - get_rest_of_line (1, &lang_arg); + get_rest_of_line (0, &lang_arg); /* Linear search is fine these days. */ for (c = aa; c != last_language_code; c++) @@ -203,11 +335,178 @@ cm_documentlanguage () -/* @documentencoding. Set global. */ +/* Search through the encoding table for the given character, returning + its equivalent. */ + +static int +cm_search_iso_map (html) + char *html; +{ + int i; + iso_map_type *iso = encoding_table[document_encoding_code].isotab; + + /* If no conversion table for this encoding, quit. */ + if (!iso) + return -1; + + for (i = 0; i < ISO_MAP_SIZE; i++) + { + if (strcmp (html, iso[i].html) == 0) + return i; + } + + return -1; +} + + +/* @documentencoding. Set the translation table. */ + void cm_documentencoding () { - get_rest_of_line (1, &document_encoding); + encoding_code_type enc; + char *enc_arg; + + get_rest_of_line (1, &enc_arg); + + /* See if we have this encoding. */ + for (enc = ISO_8859_1; enc != last_encoding_code; enc++) + { + if (strcasecmp (enc_arg, encoding_table[enc].ecname) == 0) + { + document_encoding_code = enc; + break; + } + } + + /* If we didn't find this code, complain. */ + if (enc == last_encoding_code) + warning (_("unrecogized encoding name `%s'"), enc_arg); + + else if (encoding_table[document_encoding_code].isotab == NULL) + warning (_("sorry, encoding `%s' not supported"), enc_arg); + + free (enc_arg); +} + + +/* If html or xml output, add HTML_STR to the output. If not html and + the user requested encoded output, add the real 8-bit character + corresponding to HTML_STR from the translation tables. Otherwise, + add INFO_STR. */ + +void +add_encoded_char (html_str, info_str) + char *html_str; + char *info_str; +{ + if (html || xml) + add_word_args ("&%s;", html_str); + else if (enable_encoding) + { + /* Look for HTML_STR in the current translation table. */ + int rc = cm_search_iso_map (html_str); + if (rc >= 0) + /* We found it, add the real character. */ + add_char (encoding_table[document_encoding_code].isotab[rc].bytecode); + else + { /* We didn't find it, that seems bad. */ + warning (_("invalid encoded character `%s'"), html_str); + add_word (info_str); + } + } + else + add_word (info_str); +} + + + +/* Output an accent for HTML or XML. */ + +static void +cm_accent_generic_html (arg, start, end, html_supported, single, + html_solo_standalone, html_solo) + int arg, start, end; + char *html_supported; + int single; + int html_solo_standalone; + char *html_solo; +{ + static int valid_html_accent; /* yikes */ + + if (arg == START) + { /* If HTML has good support for this character, use it. */ + if (strchr (html_supported, curchar ())) + { /* Yes; start with an ampersand. The character itself + will be added later in read_command (makeinfo.c). */ + valid_html_accent = 1; + add_char ('&'); + } + else + { + valid_html_accent = 0; + if (html_solo_standalone) + { /* No special HTML support, so produce standalone char. */ + add_word_args ("&%s;", html_solo); + } + else + /* If the html_solo does not exist as standalone character + (namely ˆ ` ˜), then we use + the single character version instead. */ + add_char (single); + } + } + else if (arg == END) + { /* Only if we saw a valid_html_accent can we use the full + HTML accent (umlaut, grave ...). */ + if (valid_html_accent) + { + add_word (html_solo); + add_char (';'); + } + } +} + + +static void +cm_accent_generic_no_headers (arg, start, end, single, html_solo) + int arg, start, end; + int single; + char *html_solo; +{ + if (arg == END) + { + if (no_encoding) + add_char (single); + else + { + int rc; + char *buffer = xmalloc (1 + strlen (html_solo) + 1); + buffer[0] = output_paragraph[end - 1]; + buffer[1] = 0; + strcat (buffer, html_solo); + + rc = cm_search_iso_map (buffer); + if (rc >= 0) + /* A little bit tricky ;-) + Here we replace the character which has + been inserted in read_command with + the value we have found in converting table + Does there exist a better way to do this? kama. */ + output_paragraph[end - 1] + = encoding_table[document_encoding_code].isotab[rc].bytecode; + else + { /* If we didn't find a translation for this character, + put the single instead. E.g., &Xuml; does not exist so X¨ + should be produced. */ + warning (_("%s is an invalid ISO code, using %c"), + buffer, single); + add_char (single); + } + + free (buffer); + } + } } @@ -219,6 +518,8 @@ void cm_accent (arg) int arg; { + int old_escape_html = escape_html; + escape_html = 0; if (arg == START) { /* Must come first to avoid ambiguity with overdot. */ @@ -228,7 +529,7 @@ cm_accent (arg) else if (arg == END) { if (strcmp (command, "=") == 0) /* macron */ - add_word (html ? "¯" : "="); + add_word ((html || xml) ? "¯" : "="); else if (strcmp (command, "H") == 0) /* Hungarian umlaut */ add_word ("''"); else if (strcmp (command, "dotaccent") == 0) /* overdot */ @@ -242,18 +543,19 @@ cm_accent (arg) else if (strcmp (command, "ubaraccent") == 0) /* underbar */ add_char ('_'); else if (strcmp (command, "v") == 0) /* hacek/check */ - add_word (html ? "<" : "<"); + add_word ((html || xml) ? "<" : "<"); } + escape_html = old_escape_html; } /* Common routine for the accent characters that have support in HTML. If the character being accented is in the HTML_SUPPORTED set, then produce &CHTML_SOLO;, for example, Ä for an A-umlaut. If not in HTML_SUPPORTED, just produce &HTML_SOLO;X for the best we can do with - at an X-umlaut. Finally, if not producing HTML, just use SINGLE, a + at an X-umlaut. If not producing HTML, just use SINGLE, a character such as " which is the best plain text representation we - can manage. If HTML_SOLO_STANDALONE is zero the given HTML_SOLO - does not exist as valid standalone character in HTML. */ + can manage. If HTML_SOLO_STANDALONE is nonzero the given HTML_SOLO + exists as valid standalone character in HTML, e.g., ¨. */ static void cm_accent_generic (arg, start, end, html_supported, single, @@ -264,47 +566,19 @@ cm_accent_generic (arg, start, end, html_supported, single, int html_solo_standalone; char *html_solo; { - if (html) - { - static int valid_html_accent; - - if (arg == START) - { /* If HTML has good support for this character, use it. */ - if (strchr (html_supported, curchar ())) - { /* Yes; start with an ampersand. The character itself - will be added later in read_command (makeinfo.c). */ - add_char ('&'); - valid_html_accent = 1; - } - else - { /* No special HTML support, so produce standalone char. */ - valid_html_accent = 0; - if (html_solo_standalone) - { - add_char ('&'); - add_word (html_solo); - add_char (';'); - } - else - /* If the html_solo does not exist as standalone character - (namely ˆ ` ˜), then we use - the single character version instead. */ - add_char (single); - } - } - else if (arg == END) - { /* Only if we saw a valid_html_accent can we use the full - HTML accent (umlaut, grave ...). */ - if (valid_html_accent) - { - add_word (html_solo); - add_char (';'); - } - } - } + if (html || xml) + cm_accent_generic_html (arg, start, end, html_supported, + single, html_solo_standalone, html_solo); + else if (no_headers) + cm_accent_generic_no_headers (arg, start, end, single, html_solo); else if (arg == END) - { /* Not producing HTML, so just use the normal character. */ - add_char (single); + { + if (enable_encoding) + /* use 8-bit if available */ + cm_accent_generic_no_headers (arg, start, end, single, html_solo); + else + /* use regular character */ + add_char (single); } } @@ -347,7 +621,7 @@ void cm_accent_tilde (arg, start, end) int arg, start, end; { - cm_accent_generic (arg, start, end, "AOano", '~', 0, "tilde"); + cm_accent_generic (arg, start, end, "ANOano", '~', 0, "tilde"); } @@ -356,6 +630,9 @@ cm_accent_tilde (arg, start, end) void cm_special_char (arg) { + int old_escape_html = escape_html; + escape_html = 0; + if (arg == START) { if ((*command == 'L' || *command == 'l' @@ -363,34 +640,37 @@ cm_special_char (arg) && command[1] == 0) { /* Lslash lslash Oslash oslash. Lslash and lslash aren't supported in HTML. */ - if (html && (command[0] == 'O' || command[0] == 'o')) - add_word_args ("&%cslash;", command[0]); + if ((html || xml) && command[0] == 'O') + add_encoded_char ("Oslash", "/O"); + else if ((html || xml) && command[0] == 'o') + add_encoded_char ("oslash", "/o"); else add_word_args ("/%c", command[0]); } else if (strcmp (command, "exclamdown") == 0) - add_word (html ? "¡" : "!"); + add_encoded_char ("iexcl", "!"); else if (strcmp (command, "pounds") == 0) - add_word (html ? "£" : "#"); + add_encoded_char ("pound" , "#"); else if (strcmp (command, "questiondown") == 0) - add_word (html ? "¿" : "?"); + add_encoded_char ("iquest", "?"); else if (strcmp (command, "AE") == 0) - add_word (html ? "Æ" : command); + add_encoded_char ("AElig", command); else if (strcmp (command, "ae") == 0) - add_word (html ? "æ" : command); + add_encoded_char ("aelig", command); else if (strcmp (command, "OE") == 0) - add_word (html ? "Œ" : command); + add_word ("Œ", command); else if (strcmp (command, "oe") == 0) - add_word (html ? "œ" : command); + add_word ("œ", command); else if (strcmp (command, "AA") == 0) - add_word (html ? "Å" : command); + add_encoded_char ("Aring", command); else if (strcmp (command, "aa") == 0) - add_word (html ? "å" : command); + add_encoded_char ("aring", command); else if (strcmp (command, "ss") == 0) - add_word (html ? "ß" : command); + add_encoded_char ("szlig", command); else line_error ("cm_special_char internal error: command=@%s", command); } + escape_html = old_escape_html; } /* Dotless i or j. */ @@ -400,6 +680,7 @@ cm_dotless (arg, start, end) { if (arg == END) { + xml_no_para --; if (output_paragraph[start] != 'i' && output_paragraph[start] != 'j') /* This error message isn't perfect if the argument is multiple characters, but it doesn't seem worth getting right. */ @@ -412,4 +693,6 @@ cm_dotless (arg, start, end) /* We've already inserted the `i' or `j', so nothing to do. */ } + else + xml_no_para ++; } diff --git a/contrib/texinfo/makeinfo/lang.h b/contrib/texinfo/makeinfo/lang.h index 25bf0bd..57d4946 100644 --- a/contrib/texinfo/makeinfo/lang.h +++ b/contrib/texinfo/makeinfo/lang.h @@ -1,7 +1,7 @@ /* lang.h -- declarations for language codes etc. - $Id: lang.h,v 1.6 1999/03/22 20:07:34 karl Exp $ + $Id: lang.h,v 1.7 2001/09/11 18:04:29 karl Exp $ - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 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 @@ -17,15 +17,14 @@ 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 Karl Heinz Marbaise . */ + Originally written by Karl Heinz Marbaise . */ #ifndef LANG_H #define LANG_H -/* The langauge code which can be changed through @documentlanguage - * Actualy Info does not support this (may be in the future) ;-) - * Default for language code is en (english!) kama - * These code should ISO 639 two letter codes. +/* The language code which can be changed through @documentlanguage + * Actually we don't currently support this (may be in the future) ;-) + * These code are the ISO-639 two letter codes. */ typedef enum { @@ -61,19 +60,71 @@ typedef enum /* The current language code. */ extern language_code_type language_code; -/* Information about all valid languages. */ + +/* Information for each language. */ typedef struct { language_code_type lc; /* language code as enum type */ char *abbrev; /* two letter language code */ char *desc; /* full name for language code */ -} language_struct; -extern language_struct language_table[]; +} language_type; + +extern language_type language_table[]; + + + +/* The document encoding. This is usefull if we working e.g. + * with german Texinfo so we can produce correct german umlaut + * while creating output (--no-headers ASCII like). + */ +typedef enum { + no_encoding, + ISO_8859_1, /* default for en, de, */ + ISO_8859_2, /* actualy not supported like the rest below */ + ISO_8859_3, + ISO_8859_4, + ISO_8859_5, + ISO_8859_6, + ISO_8859_7, + ISO_8859_8, + ISO_8859_9, + ISO_8859_10, + ISO_8859_11, + ISO_8859_12, + ISO_8859_13, + ISO_8859_14, + ISO_8859_15, + last_encoding_code +} encoding_code_type; + +/* The current document encoding, or null if not set. */ +extern encoding_code_type document_encoding_code; + -/* The encoding, or null if not set. */ -extern char *document_encoding; +/* Maps an HTML abbreviation to ISO and Unicode codes for a given code. */ + +typedef unsigned short int unicode_t; /* should be 16 bits */ +typedef unsigned char byte_t; + +typedef struct +{ + char *html; /* HTML equivalent like umlaut auml => ä */ + byte_t bytecode; /* 8-Bit Code (ISO 8859-1,...) */ + unicode_t unicode; /* Unicode in U+ convention */ +} iso_map_type; + +/* Information about the document encoding. */ +typedef struct +{ + encoding_code_type ec; /* document encoding type (see above enum) */ + char *ecname; /* encoding name like ISO-8859-1 */ + iso_map_type *isotab; /* address of ISO translation table */ +} encoding_type; +/* Table with all the encoding codes that we recognize. */ +extern encoding_type encoding_table[]; + /* The commands. */ extern void cm_documentlanguage (), cm_documentencoding (); diff --git a/contrib/texinfo/makeinfo/macro.c b/contrib/texinfo/makeinfo/macro.c index 8c89da2..2bba378 100644 --- a/contrib/texinfo/makeinfo/macro.c +++ b/contrib/texinfo/makeinfo/macro.c @@ -1,7 +1,7 @@ /* macro.c -- user-defined macros for Texinfo. - $Id: macro.c,v 1.10 1999/08/17 21:06:35 karl Exp $ + $Id: macro.c,v 1.12 2002/03/02 15:05:21 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2002 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 @@ -590,10 +590,8 @@ define_macro (mactype, recursive) { if ((input_text_offset + 9) > input_text_length) { - int temp_line = line_number; - line_number = defining_line; - line_error (_("%cend macro not found"), COMMAND_PREFIX); - line_number = temp_line; + file_line_error (input_filename, defining_line, + _("%cend macro not found"), COMMAND_PREFIX); return; } @@ -1002,6 +1000,8 @@ cm_alias () skip_whitespace (); get_until_in_line (1, "=", &(a->alias)); + canon_white (a->alias); + discard_until ("="); skip_whitespace (); get_until_in_line (0, " ", &(a->mapto)); diff --git a/contrib/texinfo/makeinfo/makeinfo.c b/contrib/texinfo/makeinfo/makeinfo.c index 5f042bc..d910094 100644 --- a/contrib/texinfo/makeinfo/makeinfo.c +++ b/contrib/texinfo/makeinfo/makeinfo.c @@ -1,7 +1,7 @@ /* makeinfo -- convert Texinfo source into other formats. - $Id: makeinfo.c,v 1.171 1999/09/19 15:24:44 karl Exp $ + $Id: makeinfo.c,v 1.195 2002/02/11 17:12:49 karl Exp $ - Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 99 + Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -34,34 +34,7 @@ #include "macro.h" #include "node.h" #include "toc.h" - -/* We'd like to take advantage of _doprnt if it's around, a la error.c, - but then we'd have no VA_SPRINTF. */ -#if HAVE_VPRINTF -# if __STDC__ -# include -# define VA_START(args, lastarg) va_start(args, lastarg) -# else -# include -# define VA_START(args, lastarg) va_start(args) -# endif -# define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap) -# define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap) -#else /* not HAVE_VPRINTF */ -# define VA_START(args, lastarg) -# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 -# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; -# define va_end(args) -#endif - -/* DJGPP supports /dev/null, which is okay for Unix aficionados, - shell scripts and Makefiles, but interactive DOS die-hards - would probably want to have NUL as well. */ -#ifdef __DJGPP__ -# define ALSO_NULL_DEVICE "NUL" -#else -# define ALSO_NULL_DEVICE "" -#endif +#include "xml.h" /* You can change some of the behavior of Makeinfo by changing the following defines: */ @@ -157,6 +130,9 @@ int insertion_paragraph_closed = 0; /* Nonzero means attempt to make all of the lines have fill_column width. */ int do_justification = 0; +/* Nonzero means don't replace whitespace with   in HTML mode. */ +int in_html_elt = 0; + typedef struct brace_element { struct brace_element *next; @@ -262,7 +238,38 @@ error (format, va_alist) putc ('\n', stderr); } -/* Just like error (), but print the line number as well. */ +/* Just like error (), but print the input file and line number as well. */ +void +#if defined (VA_FPRINTF) && __STDC__ +file_line_error (char *infile, int lno, char *format, ...) +#else +file_line_error (infile, lno, format, va_alist) + char *infile; + int lno; + char *format; + va_dcl +#endif +{ +#ifdef VA_FPRINTF + va_list ap; +#endif + + remember_error (); + fprintf (stderr, "%s:%d: ", infile, lno); + + VA_START (ap, format); +#ifdef VA_FPRINTF + VA_FPRINTF (stderr, format, ap); +#else + fprintf (stderr, format, a1, a2, a3, a4, a5, a6, a7, a8); +#endif /* not VA_FPRINTF */ + va_end (ap); + + fprintf (stderr, ".\n"); +} + +/* Just like file_line_error (), but take the input file and the line + number from global variables. */ void #if defined (VA_FPRINTF) && __STDC__ line_error (char *format, ...) @@ -362,68 +369,106 @@ usage (exit_value) fprintf (stderr, _("Try `%s --help' for more information.\n"), progname); else { - printf (_("Usage: %s [OPTION]... TEXINFO-FILE...\n\ -\n\ -Translate Texinfo source documentation to various other formats:\n\ -Info files suitable for reading online with Emacs or standalone GNU Info\n\ -(by default); plain text (with --no-headers); or HTML (with --html).\n\ -\n\ -Options:\n\ - --commands-in-node-names allow @ commands in node names.\n\ - -D VAR define a variable, as with @set.\n\ - -E, --macro-expand FILE output macro-expanded source to FILE.\n\ - --error-limit=NUM quit after NUM errors (default %d).\n\ - --fill-column=NUM break Info lines at NUM characters (default %d).\n\ - --footnote-style=STYLE output footnotes according to STYLE:\n\ - `separate' to place footnotes in their own node,\n\ - `end' to place the footnotes at the end of the\n\ - node in which they are defined (the default).\n\ - --force preserve output even if errors.\n\ - --help display this help and exit.\n\ - --html output HTML rather than Info format;\n\ - -I DIR append DIR to the @include search path.\n\ - --ifhtml process @ifhtml and @html text even when not\n\ - generating HTML.\n\ - --ifinfo process @ifinfo text even when generating HTML.\n\ - --iftex process @iftex and @tex text.\n\ - implies --no-split.\n"), - progname, max_error_level, fill_column); + printf (_("Usage: %s [OPTION]... TEXINFO-FILE...\n"), progname); + printf ("\n"); + /* xgettext: no-wrap */ + puts (_("\ +Translate Texinfo source documentation to various other formats, by default\n\ +Info files suitable for reading online with Emacs or standalone GNU Info.\n")); + + /* xgettext: no-wrap */ printf (_("\ - --no-headers suppress Info node separators and Node: lines and\n\ - write to standard output without --output.\n\ - --no-ifhtml do not process @ifhtml and @html text.\n\ - --no-ifinfo do not process @ifinfo text.\n\ - --no-iftex do not process @iftex and @tex text.\n\ - --no-split suppress splitting of large Info output files or\n\ - generation of one HTML file per node.\n\ - --no-validate suppress node cross-reference validation.\n\ - --no-warn suppress warnings (but not errors).\n\ - --number-sections include chapter, section, etc. numbers in output.\n\ - -o, --output=FILE output to FILE, ignoring any @setfilename.\n\ - -P DIR prepend DIR to the @include search path.\n\ - --paragraph-indent=VAL indent Info paragraphs by VAL spaces (default %d).\n\ - if VAL is `none', do not indent;\n\ - if VAL is `asis', preserve existing indentation.\n\ - --reference-limit=NUM warn about at most NUM references (default %d).\n\ - -U VAR undefine a variable, as with @clear.\n\ - -v, --verbose explain what is being done.\n\ - --version display version information and exit.\n\ -"), - paragraph_start_indent, reference_warning_limit); +General options:\n\ + --error-limit=NUM quit after NUM errors (default %d).\n\ + --force preserve output even if errors.\n\ + --help display this help and exit.\n\ + --no-validate suppress node cross-reference validation.\n\ + --no-warn suppress warnings (but not errors).\n\ + --reference-limit=NUM warn about at most NUM references (default %d).\n\ + -v, --verbose explain what is being done.\n\ + --version display version information and exit.\n"), + max_error_level, reference_warning_limit); + printf ("\n"); + + /* xgettext: no-wrap */ + puts (_("\ +Output format selection (default is to produce Info):\n\ + --docbook output DocBook rather than Info.\n\ + --html output HTML rather than Info.\n\ + --no-headers output plain text, suppressing Info node\n\ + separators and Node: lines; also, write to\n\ + standard output without --output.\n\ + --xml output XML (TexinfoML) rather than Info.\n\ +")); + + puts (_("\ +General output options:\n\ + -E, --macro-expand FILE output macro-expanded source to FILE.\n\ + ignoring any @setfilename.\n\ + --no-split suppress splitting of Info or HTML output,\n\ + generate only one output file.\n\ + --number-sections output chapter and sectioning numbers.\n\ + -o, --output=FILE output to FILE (directory if split HTML),\n\ +")); + + /* xgettext: no-wrap */ + printf (_("\ +Options for Info and plain text:\n\ + --enable-encoding output accented and special characters in\n\ + Info output based on @documentencoding.\n\ + --fill-column=NUM break Info lines at NUM characters (default %d).\n\ + --footnote-style=STYLE output footnotes in Info according to STYLE:\n\ + `separate' to put them in their own node;\n\ + `end' to put them at the end of the node\n\ + in which they are defined (default).\n\ + --paragraph-indent=VAL indent Info paragraphs by VAL spaces (default %d).\n\ + If VAL is `none', do not indent; if VAL is\n\ + `asis', preserve existing indentation.\n\ + --split-size=NUM split Info files at size NUM (default %d).\n"), + fill_column, paragraph_start_indent, + DEFAULT_SPLIT_SIZE); } - - puts (_("\n\ -The defaults for the @if... conditionals depend on the output format:\n\ -if generating HTML, --ifhtml is on and the others are off;\n\ -if generating Info or plain text, --ifinfo is on and the others are off.\n\ -\n\ + printf ("\n"); + + /* xgettext: no-wrap */ + puts (_("\ +Input file options:\n\ + --commands-in-node-names allow @ commands in node names.\n\ + -D VAR define the variable VAR, as with @set.\n\ + -I DIR append DIR to the @include search path.\n\ + -P DIR prepend DIR to the @include search path.\n\ + -U VAR undefine the variable VAR, as with @clear.\n\ +")); + /* xgettext: no-wrap */ + puts (_("\ +Conditional processing in input:\n\ + --ifhtml process @ifhtml and @html even if not generating HTML.\n\ + --ifinfo process @ifinfo text even when generating HTML.\n\ + --iftex process @iftex and @tex text; implies --no-split.\n\ + --no-ifhtml do not process @ifhtml and @html text.\n\ + --no-ifinfo do not process @ifinfo text.\n\ + --no-iftex do not process @iftex and @tex text.\n\ +")); + + /* xgettext: no-wrap */ + puts (_("\ + The defaults for the @if... conditionals depend on the output format:\n\ + if generating HTML, --ifhtml is on and the others are off;\n\ + if generating Info or plain text, --ifinfo is on and the others are off.\n\ +")); + + /* xgettext: no-wrap */ + puts (_("\ Examples:\n\ - makeinfo foo.texi write Info to foo's @setfilename\n\ - makeinfo --html foo.texi write HTML to foo's @setfilename\n\ - makeinfo --no-headers -o - foo.texi write plain text to standard output\n\ - makeinfo --number-sections foo.texi write Info with numbered sections\n\ - makeinfo --no-split foo.texi write one Info file however big\n\ -\n\ + makeinfo foo.texi write Info to foo's @setfilename\n\ + makeinfo --html foo.texi write HTML to foo's @setfilename\n\ + makeinfo --no-headers -o - foo.texi write plain text to standard output\n\ + makeinfo --number-sections foo.texi write Info with numbered sections\n\ + makeinfo --no-split foo.texi write one Info file however big\n\ +")); + + /* xgettext: no-wrap */ + puts (_("\ Email bug reports to bug-texinfo@gnu.org,\n\ general questions and discussion to help-texinfo@gnu.org.")); xexit (exit_value); @@ -432,6 +477,8 @@ general questions and discussion to help-texinfo@gnu.org.")); struct option long_options[] = { { "commands-in-node-names", 0, &expensive_validation, 1 }, + { "docbook", 0, 0, 'd' }, + { "enable-encoding", 0, &enable_encoding, 1 }, { "error-limit", 1, 0, 'e' }, { "fill-column", 1, 0, 'f' }, { "footnote-style", 1, 0, 's' }, @@ -457,8 +504,10 @@ struct option long_options[] = { "output", 1, 0, 'o' }, { "paragraph-indent", 1, 0, 'p' }, { "reference-limit", 1, 0, 'r' }, + { "split-size", 1, 0, 'S'}, { "verbose", 0, &verbose_mode, 1 }, { "version", 0, 0, 'V' }, + { "xml", 0, 0, 'x' }, {NULL, 0, NULL, 0} }; @@ -487,7 +536,7 @@ main (argc, argv) textdomain (PACKAGE); /* Parse argument flags from the input line. */ - while ((c = getopt_long (argc, argv, "D:e:E:f:hI:o:p:P:r:s:U:vV:w", + while ((c = getopt_long (argc, argv, "D:de:E:f:hI:o:p:P:r:s:U:vV:wx", long_options, &ind)) != EOF) { if (c == 0 && long_options[ind].flag == 0) @@ -501,13 +550,19 @@ main (argc, argv) handle_variable_internal ((c == 'D') ? SET : CLEAR, optarg); break; + case 'd': /* --docbook */ + splitting = 0; + xml = 1; + docbook = 1; + break; + case 'e': /* --error-limit */ if (sscanf (optarg, "%d", &max_error_level) != 1) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), "--error-limit", progname, optarg); - usage (stderr, 1); + usage (1); } break; @@ -606,6 +661,16 @@ main (argc, argv) footnote_style_preset = 1; break; + case 'S': /* --split-size */ + if (sscanf (optarg, "%d", &split_size) != 1) + { + fprintf (stderr, + _("%s: %s arg must be numeric, not `%s'.\n"), + "--split-size", progname, optarg); + usage (1); + } + break; + case 'v': verbose_mode++; break; @@ -617,7 +682,7 @@ main (argc, argv) There is NO warranty. You may redistribute this software\n\ under the terms of the GNU General Public License.\n\ For more information about these matters, see the files named COPYING.\n"), - "1999"); + "2002"); exit (0); break; @@ -625,9 +690,13 @@ For more information about these matters, see the files named COPYING.\n"), html = 1; process_html = 1; process_info = 0; - splitting = 0; /* too complicated for now */ break; + case 'x': /* --xml */ + splitting = 0; + xml = 1; + break; + case '?': usage (1); break; @@ -971,6 +1040,7 @@ get_rest_of_line (expand, string) int expand; char **string; { + xml_no_para ++; if (expand) { char *tem; @@ -993,6 +1063,7 @@ get_rest_of_line (expand, string) line_number++; input_text_offset++; } + xml_no_para --; } /* Backup the input pointer to the previous character, keeping track @@ -1020,10 +1091,21 @@ get_until_in_braces (match, string) for (i = input_text_offset; i < input_text_length; i++) { - if (input_text[i] == '{') + if (i < input_text_length - 1 && input_text[i] == '@') + { + i++; /* skip commands like @, and @{ */ + continue; + } + else if (input_text[i] == '{') brace++; else if (input_text[i] == '}') - brace--; + { + brace--; + /* If looking for a brace, don't stop at the interior brace, + like after "baz" in "@foo{something @bar{baz} more}". */ + if (brace == 0) + continue; + } else if (input_text[i] == '\n') line_number++; @@ -1191,6 +1273,77 @@ convert_from_file (name) convert_from_loaded_file (name); } +/* Given OUTPUT_FILENAME == ``/foo/bar/baz.html'', return + ``/foo/bar/baz/baz.html''. + + Split html output goes into the subdirectory of the toplevel + filename, without extension. For example: + + @setfilename foo.info + + produces output in files foo/index.html, foo/second-node.html, .... */ + +static char * +insert_toplevel_subdirectory (output_filename) + char *output_filename; +{ + char *dir, *subdir, *base, *basename, *p; + char buf[PATH_MAX]; + int max_name_len; + static const char index_name[] = "index.html"; + const int index_len = sizeof (index_name) - 1; + + strcpy (buf, output_filename); + dir = pathname_part (buf); + base = filename_part (buf); + basename = xstrdup (base); /* remember real @setfilename name */ + p = dir + strlen (dir) - 1; + if (p > dir && IS_SLASH (*p)) + *p = 0; + p = strrchr (base, '.'); + if (p) + *p = 0; + + /* Split html output goes into subdirectory of toplevel name. */ + subdir = ""; + if (FILENAME_CMP (base, filename_part (dir)) != 0) + subdir = base; + + max_name_len = strlen (basename); + if (index_len > max_name_len) + max_name_len = index_len; + + free (output_filename); + output_filename = xmalloc (strlen (dir) + 1 + + strlen (subdir) + 1 + + max_name_len + + 1); + strcpy (output_filename, dir); + if (strlen (dir)) + strcat (output_filename, "/"); + strcat (output_filename, subdir); + if (mkdir (output_filename, 0777) == -1 && errno != EEXIST) + { /* that failed, try subdir name with .html */ + strcpy (output_filename, dir); + if (strlen (dir)) + strcat (output_filename, "/"); + strcat (output_filename, basename); + if (mkdir (output_filename, 0777) == -1 && errno != EEXIST) + { + line_error (_("Can't create directory `%s': %s"), + output_filename, + strerror (errno)); + exit (1); + } + strcat (output_filename, "/"); + } + else if (strlen (subdir)) + strcat (output_filename, "/"); + strcat (output_filename, index_name); + return output_filename; +} + +/* FIXME: this is way too hairy */ void convert_from_loaded_file (name) char *name; @@ -1260,12 +1413,15 @@ convert_from_loaded_file (name) if (!command_output_filename) { get_until ("\n", &output_filename); /* read rest of line */ - if (html) - { /* Change any extension to .html. */ + if (xml && !docbook) + xml_begin_document (output_filename); + if (html || xml) + { /* Change any extension to .html or .xml. */ char *html_name, *directory_part, *basename_part, *temp; canon_white (output_filename); directory_part = pathname_part (output_filename); + basename_part = filename_part (output_filename); /* Zap any existing extension. */ @@ -1278,7 +1434,7 @@ convert_from_loaded_file (name) + strlen (basename_part) + 6); strcpy (html_name, directory_part); strcat (html_name, basename_part); - strcat (html_name, ".html"); + strcat (html_name, html ? ".html" : ".xml"); /* Replace name from @setfilename with the html name. */ free (output_filename); @@ -1297,13 +1453,15 @@ convert_from_loaded_file (name) } canon_white (output_filename); + toplevel_output_filename = xstrdup (output_filename); if (real_output_filename && strcmp (real_output_filename, "-") == 0) { if (macro_expansion_filename && strcmp (macro_expansion_filename, "-") == 0) { - fprintf (stderr, _("%s: Skipping macro expansion to stdout as Info output is going there.\n"), + fprintf (stderr, + _("%s: Skipping macro expansion to stdout as Info output is going there.\n"), progname); macro_expansion_output_stream = NULL; } @@ -1313,7 +1471,16 @@ convert_from_loaded_file (name) } else { - if (!real_output_filename) + if (html && splitting) + { + if (FILENAME_CMP (output_filename, NULL_DEVICE) == 0 + || FILENAME_CMP (output_filename, ALSO_NULL_DEVICE) == 0) + splitting = 0; + else + output_filename = insert_toplevel_subdirectory (output_filename); + real_output_filename = xstrdup (output_filename); + } + else if (!real_output_filename) real_output_filename = expand_filename (output_filename, name); else real_output_filename = xstrdup (real_output_filename); @@ -1325,7 +1492,10 @@ convert_from_loaded_file (name) if (verbose_mode) printf (_("Making %s file `%s' from `%s'.\n"), - no_headers ? "text" : (html ? "HTML" : "info"), + no_headers ? "text" + : html ? "HTML" + : xml ? "XML" + : "info", output_filename, input_filename); if (output_stream == NULL) @@ -1336,6 +1506,7 @@ convert_from_loaded_file (name) /* Make the displayable filename from output_filename. Only the base portion of the filename need be displayed. */ + flush_output (); /* in case there was no @bye */ if (output_stream != stdout) pretty_output_filename = filename_part (output_filename); else @@ -1354,12 +1525,15 @@ convert_from_loaded_file (name) } /* html fixxme: should output this as trailer on first page. */ - if (!no_headers && !html) + if (!no_headers && !html && !xml) add_word_args (_("This is %s, produced by makeinfo version %s from %s.\n"), output_filename, VERSION, input_filename); close_paragraph (); reader_loop (); + if (xml) + xml_end_document (); + finished: discard_insertions (0); @@ -1398,6 +1572,7 @@ finished: close_paragraph (); } + flush_output (); /* in case there was no @bye */ if (output_stream != stdout) fclose (output_stream); @@ -1410,7 +1585,7 @@ finished: toc_update (); if (splitting && !html && (!errors_printed || force)) - split_file (real_output_filename, 0); + split_file (real_output_filename, split_size); else if (errors_printed && !force && strcmp (real_output_filename, "-") != 0 @@ -1542,6 +1717,10 @@ handle_menu_entry () input_text_offset++; /* discard the second colon or the period */ add_word (": "); } + else if (xml && tem) + { + xml_start_menu_entry (tem); + } else if (tem) { /* For Info output, we can just use the input and the main case in reader_loop where we output what comes in. Just move off the * @@ -1774,6 +1953,8 @@ reader_loop () case '<': if (html && escape_html) add_word ("<"); + else if (xml) + xml_insert_entity ("lt"); else add_char (character); input_text_offset++; @@ -1782,6 +1963,8 @@ reader_loop () case '>': if (html && escape_html) add_word (">"); + else if (xml) + xml_insert_entity ("gt"); else add_char (character); input_text_offset++; @@ -1799,8 +1982,16 @@ reader_loop () we can ignore its partner. */ if (!only_macro_expansion) { - line_error (_("Misplaced %c"), '{'); - remember_brace (misplaced_brace); + if (!STREQ (command, "math")) + { + line_error (_("Misplaced %c"), '{'); + remember_brace (misplaced_brace); + } + else + { /* We don't mind `extra' braces inside @math. */ + extern void cm_no_op (); + remember_brace (cm_no_op); + } /* remember_brace advances input_text_offset. */ break; } @@ -1851,7 +2042,7 @@ remember_brace_1 (proc, position) BRACE_ELEMENT *new = xmalloc (sizeof (BRACE_ELEMENT)); new->next = brace_stack; new->proc = proc; - new->command = xstrdup (command); + new->command = command ? xstrdup (command) : ""; new->pos = position; new->line = line_number; new->in_fixed_width_font = in_fixed_width_font; @@ -1933,12 +2124,11 @@ discard_braces () if (brace_stack->proc != misplaced_brace) { char *proc_name; - int temp_line_number = line_number; - line_number = brace_stack->line; proc_name = find_proc_name (brace_stack->proc); - line_error (_("%c%s missing close brace"), COMMAND_PREFIX, proc_name); - line_number = temp_line_number; + file_line_error (input_filename, brace_stack->line, + _("%c%s missing close brace"), COMMAND_PREFIX, + proc_name); pop_and_call_brace (); } else @@ -2018,12 +2208,30 @@ add_word (string) add_char (*string++); } +/* Like add_word, but inhibits conversion of whitespace into  . + Use this to output HTML directives with embedded blanks, to make + them @w-safe. */ +void +add_html_elt (string) + char *string; +{ + in_html_elt++; + add_word (string); + in_html_elt--; +} + /* Add the character to the current paragraph. If filling_enabled is nonzero, then do filling as well. */ void add_char (character) int character; { + if (xml) + { + xml_add_char (character); + return; + } + /* If we are avoiding outputting headers, and we are currently in a menu, then simply return. But if we're only expanding macros, then we're being called from glean_node_from_menu to try to @@ -2044,9 +2252,11 @@ add_char (character) } } - if (non_splitting_words && strchr (" \t\n", character)) + if (non_splitting_words + && !(html && in_html_elt) + && strchr (" \t\n", character)) { - if (html) + if (html || docbook) { /* Seems cleaner to use   than an 8-bit char. */ add_word (" "); character = ';'; @@ -2117,6 +2327,14 @@ add_char (character) } } + /* This is sad, but it seems desirable to not force any + particular order on the front matter commands. This way, + the document can do @settitle, @documentlanguage, etc, in + any order and with any omissions, and we'll still output + the html `just in time'. */ + if (!executing_string && html && !html_output_head_p) + html_output_head (); + if (!paragraph_is_open) { start_paragraph (); @@ -2263,13 +2481,6 @@ void insert (character) int character; { - /* This is sad, but it seems desirable to not force any particular - order on the front matter commands. This way, the document can do - @settitle, @documentlanguage, etc, in any order and with any - omissions, and we'll still output the html `just in time'. */ - if (!executing_string && html && !html_output_head_p) - html_output_head (); - output_paragraph[output_paragraph_offset++] = character; if (output_paragraph_offset == paragraph_buffer_len) { @@ -2701,7 +2912,68 @@ cm_xref (arg) char *arg5 = get_xref_token (0); char *tem; - if (html) + /* "@xref{,Foo,, Bar, Baz} is not valid usage of @xref. The + first argument must never be blank." --rms. + We hereby comply by disallowing such constructs. */ + if (!*arg1) + line_error (_("First argument to cross-reference may not be empty")); + + if (xml && docbook) + { + if (!*arg4 && !*arg5) + { + char *arg1_id = xml_id (arg1); + if (*arg2) + { + xml_insert_element_with_attribute (XREFNODENAME, START, + "linkend=\"%s\"", arg1_id); + free (arg1_id); + if (*arg2) + execute_string (arg2); + xml_insert_element (XREFNODENAME, END); + } + else + { + xml_insert_element_with_attribute (XREF, START, + "linkend=\"%s\"", arg1_id); + free (arg1_id); + xml_pop_current_element (); + } + } + } + else if (xml) + { + xml_insert_element (XREF, START); + xml_insert_element (XREFNODENAME, START); + execute_string (arg1); + xml_insert_element (XREFNODENAME, END); + if (*arg2) + { + xml_insert_element (XREFINFONAME, START); + execute_string (arg2); + xml_insert_element (XREFINFONAME, END); + } + if (*arg3) + { + xml_insert_element (XREFPRINTEDDESC, START); + execute_string (arg3); + xml_insert_element (XREFPRINTEDDESC, END); + } + if (*arg4) + { + xml_insert_element (XREFINFOFILE, START); + execute_string (arg4); + xml_insert_element (XREFINFOFILE, END); + } + if (*arg5) + { + xml_insert_element (XREFPRINTEDNAME, START); + execute_string (arg5); + xml_insert_element (XREFPRINTEDNAME, END); + } + xml_insert_element (XREF, END); + } + else if (html) { if (!ref_flag) add_word_args ("%s", px_ref_flag ? _("see ") : _("See ")); @@ -2709,109 +2981,126 @@ cm_xref (arg) else add_word_args ("%s", px_ref_flag ? "*note " : "*Note "); - if (*arg5 || *arg4) - { - char *node_name; - - if (!*arg2) - { - if (*arg3) - node_name = arg3; - else - node_name = arg1; - } - else - node_name = arg2; - - if (html) - { - /* html fixxme: revisit this; external node name not - much use to us with numbered nodes. */ - add_word (""); - execute_string ("%s", arg1); - add_word (""); - } - else - { - execute_string ("%s:", node_name); - in_fixed_width_font++; - execute_string (" (%s)%s%s", arg4, arg1, px_ref_flag ? "." : ""); - in_fixed_width_font--; - } - - /* Free all of the arguments found. */ - if (arg1) free (arg1); - if (arg2) free (arg2); - if (arg3) free (arg3); - if (arg4) free (arg4); - if (arg5) free (arg5); - return; - } - else - remember_node_reference (arg1, line_number, followed_reference); - - if (*arg3) - { - if (html) - { - add_word (""); - execute_string ("%s", *arg2 ? arg2 : arg3); - add_word (""); - } - else - { - execute_string ("%s:", *arg2 ? arg2 : arg3); - in_fixed_width_font++; - execute_string (" %s%s", arg1, px_ref_flag ? "." : ""); - in_fixed_width_font--; - } - } - else - { - if (html) - { - add_word (""); - execute_string ("%s", *arg2 ? arg2 : arg1); - add_word (""); - } - else - { - if (*arg2) - { - execute_string ("%s:", arg2); - in_fixed_width_font++; - execute_string (" %s%s", arg1, px_ref_flag ? "." : ""); - in_fixed_width_font--; - } - else - { - in_fixed_width_font++; - execute_string ("%s::", arg1); - in_fixed_width_font--; - } - } - } - + if (!xml) + { + if (*arg5 || *arg4) + { + /* arg1 - node name + arg2 - reference name + arg3 - title or topic (and reference name if arg2 is NULL) + arg4 - info file name + arg5 - printed manual title */ + char *ref_name; + + if (!*arg2) + { + if (*arg3) + ref_name = arg3; + else + ref_name = arg1; + } + else + ref_name = arg2; + + if (html) + { + /* html fixxme: revisit this; external node name not + much use to us with numbered nodes. */ + add_html_elt (""); + execute_string ("%s", ref_name); + add_word (""); + } + else + { + execute_string ("%s:", ref_name); + in_fixed_width_font++; + execute_string (" (%s)%s%s", arg4, arg1, px_ref_flag ? "." : ""); + in_fixed_width_font--; + } + + /* Free all of the arguments found. */ + if (arg1) free (arg1); + if (arg2) free (arg2); + if (arg3) free (arg3); + if (arg4) free (arg4); + if (arg5) free (arg5); + return; + } + else + remember_node_reference (arg1, line_number, followed_reference); + + if (*arg3) + { + if (html) + { + add_html_elt (""); + execute_string ("%s", *arg2 ? arg2 : arg3); + add_word (""); + } + else + { + execute_string ("%s:", *arg2 ? arg2 : arg3); + in_fixed_width_font++; + execute_string (" %s%s", arg1, px_ref_flag ? "." : ""); + in_fixed_width_font--; + } + } + else + { + if (html) + { + add_html_elt (""); + execute_string ("%s", *arg2 ? arg2 : arg1); + add_word (""); + } + else + { + if (*arg2) + { + execute_string ("%s:", arg2); + in_fixed_width_font++; + execute_string (" %s%s", arg1, px_ref_flag ? "." : ""); + in_fixed_width_font--; + } + else + { + in_fixed_width_font++; + execute_string ("%s::", arg1); + in_fixed_width_font--; + } + } + } + } /* Free all of the arguments found. */ if (arg1) free (arg1); if (arg2) free (arg2); @@ -2879,15 +3168,45 @@ cm_inforef (arg) char *pname = get_xref_token (0); char *file = get_xref_token (0); - if (html) + /* (see comments at cm_xref). */ + if (!*node) + line_error (_("First argument to @inforef may not be empty")); + + if (xml && !docbook) + { + xml_insert_element (INFOREF, START); + xml_insert_element (INFOREFNODENAME, START); + execute_string (node); + xml_insert_element (INFOREFNODENAME, END); + if (*pname) + { + xml_insert_element (INFOREFREFNAME, START); + execute_string (pname); + xml_insert_element (INFOREFREFNAME, END); + } + xml_insert_element (INFOREFINFONAME, START); + execute_string (file); + xml_insert_element (INFOREFINFONAME, END); + + xml_insert_element (INFOREF, END); + } + else if (html) { + char *tem; + add_word (_("see ")); /* html fixxme: revisit this */ - add_word (""); - execute_string ("%s", pname); + add_html_elt (""); + execute_string ("%s", *pname ? pname : tem); add_word (""); + free (tem); } else { @@ -2915,9 +3234,29 @@ cm_uref (arg) char *desc = get_xref_token (0); char *replacement = get_xref_token (0); - if (html) + if (xml) + { + xml_insert_element (UREF, START); + xml_insert_element (UREFURL, START); + execute_string (url); + xml_insert_element (UREFURL, END); + if (*desc) + { + xml_insert_element (UREFDESC, START); + execute_string (desc); + xml_insert_element (UREFDESC, END); + } + if (*replacement) + { + xml_insert_element (UREFREPLACEMENT, START); + execute_string (replacement); + xml_insert_element (UREFREPLACEMENT, END); + } + xml_insert_element (UREF, END); + } + else if (html) { /* never need to show the url */ - add_word ("", fullname, fullname); + add_html_elt (");
+	  add_word_args (", (*alt_arg) ? alt_arg : fullname); } + else if (xml && docbook) + xml_insert_docbook_image (name_arg); + else if (xml) + { + xml_insert_element (IMAGE, START); + add_word (name_arg); + xml_insert_element (IMAGE, END); + } else { /* Try to open foo.txt. */ FILE *image_file; @@ -3060,8 +3448,8 @@ cm_image (arg) perror (fullname); } else - warning (_("@image file `%s' unreadable: %s"), fullname, - strerror (errno)); + line_error (_("@image file `%s' (for text) unreadable: %s"), + fullname, strerror (errno)); } free (fullname); @@ -3071,6 +3459,10 @@ cm_image (arg) if (name_arg) free (name_arg); + if (alt_arg) + free (alt_arg); + if (ext_arg) + free (ext_arg); } /* Conditionals. */ @@ -3415,13 +3807,9 @@ handle_variable_internal (action, name) } if (!done) - { - int save = line_number; - line_number = orig_line_number; - line_error (_("Reached eof before matching @end %s"), - condition); - line_number = save; - } + file_line_error (input_filename, orig_line_number, + _("Reached eof before matching @end %s"), + condition); /* We found the end of a false @ifset/ifclear. If we are in a menu, back up over the newline that ends the ifset, diff --git a/contrib/texinfo/makeinfo/makeinfo.h b/contrib/texinfo/makeinfo/makeinfo.h index caff188..21aae89 100644 --- a/contrib/texinfo/makeinfo/makeinfo.h +++ b/contrib/texinfo/makeinfo/makeinfo.h @@ -1,7 +1,7 @@ /* makeinfo.h -- declarations for Makeinfo. - $Id: makeinfo.h,v 1.25 1999/09/18 18:09:22 karl Exp $ + $Id: makeinfo.h,v 1.31 2001/09/11 16:37:51 karl Exp $ - Copyright (C) 1996, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1996, 97, 98, 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 @@ -116,6 +116,15 @@ DECLARE (int, multitable_active, 0); /* Nonzero means that we're generating HTML. */ DECLARE (int, html, 0); +/* Nonzero means that we're generating XML. */ +DECLARE (int, xml, 0); + +/* Nonzero means that we're generating DocBook. */ +DECLARE (int, docbook, 0); + +/* Nonzero means true 8-bit output for Info and plain text. */ +DECLARE (int, enable_encoding, 0); + /* Nonzero means escape characters in HTML output. */ DECLARE (int, escape_html, 1); extern char *escape_string (); /* do HTML escapes */ @@ -135,6 +144,9 @@ DECLARE (char *, current_node, NULL); /* Command name in the process of being hacked. */ DECLARE (char *, command, NULL); +/* @documentdescription ... @end documentdescription. */ +DECLARE (char *, document_description, NULL); + /* Nonzero if the last character inserted has the syntax class of NEWLINE. */ DECLARE (int, last_char_was_newline, 1); @@ -144,6 +156,7 @@ DECLARE (char *, input_text, (char *)NULL); DECLARE (int, input_text_length, 0); DECLARE (int, input_text_offset, 0); DECLARE (int, line_number, 0); +DECLARE (char *, toplevel_output_filename, NULL); #define curchar() input_text[input_text_offset] /* A colon separated list of directories to search for files included @@ -181,6 +194,9 @@ DECLARE (int, verbose_mode, 0); /* Nonzero means prefix each @chapter, ... with a number like 1. (--number-sections) */ DECLARE (int, number_sections, 0); +/* Nonzero means split size. When zero, DEFAULT_SPLIT_SIZE is used. */ +DECLARE (int, split_size, 0); + /* Nonzero means expand node names and references while validating. This will avoid errors when the Texinfo document uses features like @@ and @value inconsistently in node names, but will slow @@ -225,6 +241,8 @@ DECLARE (int, expensive_validation, 0); #define COMMAND_PREFIX '@' +#define END_VERBATIM "end verbatim" + /* Stuff for splitting large files. */ #define SPLIT_SIZE_THRESHOLD 70000 /* What's good enough for Stallman... */ #define DEFAULT_SPLIT_SIZE 50000 /* Is probably good enough for me. */ @@ -256,5 +274,4 @@ DECLARE (int, splitting, 1); /* Defaults to true for now. */ #define looking_at(string) \ (strncmp (input_text + input_text_offset, string, strlen (string)) == 0) - #endif /* not MAKEINFO_H */ diff --git a/contrib/texinfo/makeinfo/multi.c b/contrib/texinfo/makeinfo/multi.c index b41bb47..6b6ec3d 100644 --- a/contrib/texinfo/makeinfo/multi.c +++ b/contrib/texinfo/makeinfo/multi.c @@ -1,7 +1,7 @@ /* multi.c -- multitable stuff for makeinfo. - $Id: multi.c,v 1.18 1999/08/17 21:06:56 karl Exp $ + $Id: multi.c,v 1.23 2002/01/19 01:09:08 karl Exp $ - Copyright (C) 1996, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1996, 97, 98, 99, 2000, 01, 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 @@ -15,11 +15,14 @@ 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. */ + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Written by phr@gnu.org (Paul Rubin). */ #include "system.h" #include "insertion.h" #include "makeinfo.h" +#include "xml.h" #define MAXCOLS 100 /* remove this limit later @@ */ @@ -108,6 +111,8 @@ draw_horizontal_separator () add_word ("
    "); return; } + if (xml) + return; for (s = 0; s < envs[0].current_indent; s++) out_char (' '); @@ -156,6 +161,9 @@ do_multitable () /* scan the current item function to get the field widths and number of columns, and set up the output environment list accordingly. */ + /* if (docbook)*/ /* 05-08 */ + if (xml) + xml_no_para = 1; ncolumns = setup_multitable_parameters (); first_row = 1; @@ -163,6 +171,16 @@ do_multitable () current paragraph, so this is ok. */ if (html) add_word ("

    "); + /* else if (docbook)*/ /* 05-08 */ + else if (xml) + { + int *widths = xmalloc (ncolumns * sizeof (int)); + int i; + for (i=0; i"); /*
    for non-tables browsers. */ - add_word ("
    "); /*
    for non-tables browsers. */ + add_word ("
    "); + add_word ("
    "); first_row = 0; - return; + return 0; + } + /* else if (docbook)*/ /* 05-08 */ + else if (xml) + { + xml_end_multitable_row (first_row); + first_row = 0; + return 0; } first_row = 0; @@ -504,7 +529,10 @@ cm_tab () error (_("ignoring @tab outside of multitable")); if (html) - add_word (""); + add_word (""); + /* else if (docbook)*/ /* 05-08 */ + else if (xml) + xml_end_multitable_column (); else nselect_next_environment (); @@ -516,7 +544,7 @@ cm_tab () void end_multitable () { - if (!html) + if (!html && !docbook) output_multitable_row (); /* Multitables cannot be nested. Otherwise, we'd have to save the @@ -528,7 +556,10 @@ end_multitable () close_insertion_paragraph (); if (html) - add_word ("
    \n"); + add_word ("
    \n"); + /* else if (docbook)*/ /* 05-08 */ + else if (xml) + xml_end_multitable (); #if 0 printf (_("** Multicolumn output from last row:\n")); diff --git a/contrib/texinfo/makeinfo/node.c b/contrib/texinfo/makeinfo/node.c index 8dbbd42..3c7a27d 100644 --- a/contrib/texinfo/makeinfo/node.c +++ b/contrib/texinfo/makeinfo/node.c @@ -1,7 +1,7 @@ /* node.c -- nodes for Texinfo. - $Id: node.c,v 1.23 1999/09/20 12:31:21 karl Exp $ + $Id: node.c,v 1.31 2002/02/23 19:12:15 karl Exp $ - Copyright (C) 1998, 99 Free Software Foundation, Inc. + Copyright (C) 1998, 99, 2000, 01, 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 @@ -24,8 +24,10 @@ #include "macro.h" #include "makeinfo.h" #include "node.h" +#include "html.h" #include "sectioning.h" #include "insertion.h" +#include "xml.h" /* See comments in node.h. */ @@ -64,6 +66,12 @@ write_tag_table_internal (indirect_p) TAG_ENTRY *node; int old_indent = no_indent; + if (xml) + { + flush_output (); + return; + } + no_indent = 1; filling_enabled = 0; must_start_paragraph = 0; @@ -211,7 +219,25 @@ find_node (name) return tag; } -/* Similarly for next etc. references in a @node command, where we +/* Look in the tag table for a node whose file name is FNAME, and + return the associated tag_entry. If there's no such node in the + table, return NULL. */ +TAG_ENTRY * +find_node_by_fname (fname) + char *fname; +{ + TAG_ENTRY *tag = tag_table; + while (tag) + { + if (tag->html_fname && FILENAME_CMP (tag->html_fname, fname) == 0) + return tag; + tag = tag->next_ent; + } + + return tag; +} + +/* Remember next, prev, etc. references in a @node command, where we don't care about most of the entries. */ static void remember_node_node_reference (node) @@ -237,8 +263,8 @@ remember_node_node_reference (node) /* Remember NODE and associates. */ void -remember_node (node, prev, next, up, position, line_no, flags) - char *node, *prev, *next, *up; +remember_node (node, prev, next, up, position, line_no, fname, flags) + char *node, *prev, *next, *up, *fname; int position, line_no, flags; { /* Check for existence of this tag already. */ @@ -280,6 +306,7 @@ remember_node (node, prev, next, up, position, line_no, flags) node_number++; new->number = node_number; } + new->html_fname = fname; new->next_ent = tag_table; tag_table = new; } @@ -392,7 +419,7 @@ glean_node_from_menu (remember_ref, ref_type) char *nodename; char *line, *expanded_line; char *old_input = input_text; - size_t old_size = input_text_length; + int old_size = input_text_length; if (strncmp (&input_text[input_text_offset + 1], MENU_STARTER, @@ -457,9 +484,13 @@ set_current_output_filename (fname) void cm_node () { + static long epilogue_len = 0L; char *node, *prev, *next, *up; int new_node_pos, defaulting, this_section; int no_warn = 0; + char *fname_for_this_node = NULL; + char *tem; + TAG_ENTRY *tag = NULL; if (strcmp (command, "nwnode") == 0) no_warn = TAG_FLAG_NO_WARN; @@ -473,27 +504,12 @@ cm_node () if (!html && !already_outputting_pending_notes) { + if (!xml) close_paragraph (); output_pending_notes (); } - if (html && splitting && top_node_seen) - { - /* End the current split output file. */ - close_paragraph (); - output_pending_notes (); - start_paragraph (); - /* Fixme: html: need a navigation bar here. */ - add_word ("\n"); - close_paragraph (); - fclose (output_stream); - output_stream = NULL; - } - - filling_enabled = indented_fill = 0; new_node_pos = output_position; - if (!html || (html && splitting)) - current_footnote_number = 1; if (macro_expansion_output_stream && !executing_string) append_to_expansion_output (input_text_offset + 1); @@ -510,6 +526,70 @@ cm_node () prev = get_node_token (0); up = get_node_token (0); + if (html && splitting + /* If there is a Top node, it always goes into index.html. So + don't start a new HTML file for Top. */ + && (top_node_seen || strcasecmp (node, "Top") != 0)) + { + /* We test *node here so that @node without a valid name won't + start a new file name with a bogus name such as ".html". + This could happen if we run under "--force", where we cannot + simply bail out. Continuing to use the same file sounds like + the best we can do in such cases. */ + if (current_output_filename && output_stream && *node) + { + char *fname_for_prev_node; + + if (current_node) + { + /* NOTE: current_node at this point still holds the name + of the previous node. */ + tem = expand_node_name (current_node); + fname_for_prev_node = nodename_to_filename (tem); + free (tem); + } + else /* could happen if their top node isn't named "Top" */ + fname_for_prev_node = filename_part (current_output_filename); + tem = expand_node_name (node); + fname_for_this_node = nodename_to_filename (tem); + free (tem); + /* Don't close current output file, if next output file is + to have the same name. This may happen at top level, or + if two nodes produce the same file name under --split. */ + if (FILENAME_CMP (fname_for_this_node, fname_for_prev_node) != 0) + { + long pos1 = 0; + + /* End the current split output file. */ + close_paragraph (); + output_pending_notes (); + start_paragraph (); + /* Compute the length of the HTML file's epilogue. We + cannot know the value until run time, due to the + text/binary nuisance on DOS/Windows platforms, where + 2 `\r' characters could be added to the epilogue when + it is written in text mode. */ + if (epilogue_len == 0) + { + flush_output (); + pos1 = ftell (output_stream); + } + add_word ("\n"); + close_paragraph (); + if (epilogue_len == 0) + epilogue_len = ftell (output_stream) - pos1; + fclose (output_stream); + output_stream = NULL; + tag = find_node_by_fname (fname_for_this_node); + } + free (fname_for_prev_node); + } + } + + filling_enabled = indented_fill = 0; + if (!html || (html && splitting)) + current_footnote_number = 1; + if (verbose_mode) printf (_("Formatting node %s...\n"), node); @@ -517,7 +597,23 @@ cm_node () remember_itext (input_text, input_text_offset); no_indent = 1; - if (!no_headers && !html) + if (xml) + { + xml_begin_document (); + xml_begin_node (); + if (!docbook) + { + xml_insert_element (NODENAME, START); + if (macro_expansion_output_stream && !executing_string) + me_execute_string (node); + else + execute_string ("%s", node); + xml_insert_element (NODENAME, END); + } + else + xml_node_id = xml_id (node); + } + else if (!no_headers && !html) { add_word_args ("\037\nFile: %s, Node: ", pretty_output_filename); @@ -729,33 +825,83 @@ cm_node () if (!*next) { free (next); next = NULL; } if (!*prev) { free (prev); prev = NULL; } if (!*up) { free (up); up = NULL; } - remember_node (node, prev, next, up, new_node_pos, line_number, no_warn); + remember_node (node, prev, next, up, new_node_pos, line_number, + fname_for_this_node, no_warn); outstanding_node = 1; } if (html) { - char *tem; - - if (splitting) - { /* this code not operational, we do not currently split html */ - char filename[20]; - - sprintf (filename, "node%d.html", number_of_node (node)); - output_stream = fopen (filename, "w"); + if (splitting && *node && output_stream == NULL) + { + char *dirname; + char filename[PATH_MAX]; + + dirname = pathname_part (current_output_filename); + strcpy (filename, dirname); + strcat (filename, fname_for_this_node); + free (dirname); + + /* See if the node name converted to a file name clashes + with other nodes or anchors. If it clashes with an + anchor, we complain and nuke that anchor's file. */ + if (!tag) + { + output_stream = fopen (filename, "w"); + html_output_head_p = 0; /* so that we generate HTML preamble */ + html_output_head (); + } + else if ((tag->flags & TAG_FLAG_ANCHOR) != 0) + { + line_error (_("Anchor `%s' and node `%s' map to the same file name"), + tag->node, node); + file_line_error (tag->filename, tag->line_no, + _("This @anchor command ignored; references to it will not work")); + file_line_error (tag->filename, tag->line_no, + _("Rename this anchor or use the `--no-split' option")); + /* Nuke the file name recorded in anchor's tag. + Since we are about to nuke the file itself, we + don't want find_node_by_fname to consider this + anchor anymore. */ + free (tag->html_fname); + tag->html_fname = NULL; + output_stream = fopen (filename, "w"); + html_output_head_p = 0; /* so that we generate HTML preamble */ + html_output_head (); + } + else + { + /* This node's file name clashes with another node. + We put them both on the same file. */ + output_stream = fopen (filename, "r+"); + if (output_stream) + { + static char html_end[] = "\n"; + char end_line[sizeof(html_end)]; + int fpos = fseek (output_stream, -epilogue_len, + SEEK_END); + + if (fpos < 0 + || fgets (end_line, sizeof (html_end), + output_stream) == NULL + /* Paranoia: did someone change the way HTML + files are finished up? */ + || strcasecmp (end_line, html_end) != 0) + { + line_error (_("Unexpected string at end of split-HTML file `%s'"), + fname_for_this_node); + fclose (output_stream); + xexit (1); + } + fseek (output_stream, -epilogue_len, SEEK_END); + } + } if (output_stream == NULL) { fs_error (filename); xexit (1); } set_current_output_filename (filename); - /* FIXME: when this code is operational, we will need to - expand node, next, prev, and up before output. */ - add_word_args ("%s", node); - if (next) add_link (next, "rel=next"); - if (prev) add_link (prev, "rel=previous"); - if (up) add_link (up, "rel=up"); - add_word ("\n\n"); } if (!splitting && no_headers) @@ -779,32 +925,32 @@ cm_node () if (next) { - add_word (",\n"); - add_word (_("Next:")); - add_word ("
    ", tem); + add_word (",\n"); + add_word (_("Next:")); + add_word ("", tem); free (tem); } if (prev) { - add_word (",\n"); - add_word (_("Previous:")); - add_word ("%s", tem); + add_word (",\n"); + add_word (_("Previous:")); + add_word ("%s", tem); free (tem); } if (up) { - add_word (",\n"); - add_word (_("Up:")); - add_word ("%s", tem); + add_word (",\n"); + add_word (_("Up:")); + add_word ("%s", tem); free (tem); } /* html fixxme: we want a `top' or `contents' link here. */ @@ -812,7 +958,29 @@ cm_node () add_word_args ("\n%s
    \n", splitting ? "


    " : ""); } } - + else if (docbook) + ; + else if (xml) + { + if (next) + { + xml_insert_element (NODENEXT, START); + execute_string ("%s", next); + xml_insert_element (NODENEXT, END); + } + if (prev) + { + xml_insert_element (NODEPREV, START); + execute_string ("%s", prev); + xml_insert_element (NODEPREV, END); + } + if (up) + { + xml_insert_element (NODEUP, START); + execute_string ("%s", up); + xml_insert_element (NODEUP, END); + } + } else if (!no_headers) { if (macro_expansion_output_stream) @@ -858,6 +1026,7 @@ cm_anchor (arg) int arg; { char *anchor; + char *fname_for_anchor = NULL; if (arg == END) return; @@ -872,6 +1041,8 @@ cm_anchor (arg) sure a new paragraph is indeed started. */ if (!paragraph_is_open) { + if (!executing_string && html) + html_output_head (); start_paragraph (); if (!in_fixed_width_font || in_menu || in_detailmenu) { @@ -882,11 +1053,104 @@ cm_anchor (arg) add_word (""); + if (splitting) + { + /* If we are splitting, cm_xref will produce a reference to + a file whose name is derived from the anchor name. So we + must create a file when we see an @anchor, otherwise + xref's to anchors won't work. The file we create simply + redirects to the file of this anchor's node. */ + TAG_ENTRY *tag; + + fname_for_anchor = nodename_to_filename (anchor); + /* See if the anchor name converted to a file name clashes + with other anchors or nodes. */ + tag = find_node_by_fname (fname_for_anchor); + if (tag) + { + if ((tag->flags & TAG_FLAG_ANCHOR) != 0) + line_error (_("Anchors `%s' and `%s' map to the same file name"), + anchor, tag->node); + else + line_error (_("Anchor `%s' and node `%s' map to the same file name"), + anchor, tag->node); + line_error (_("@anchor command ignored; references to it will not work")); + line_error (_("Rename this anchor or use the `--no-split' option")); + free (fname_for_anchor); + /* We will not be creating a file for this anchor, so + set its name to NULL, so that remember_node stores a + NULL and find_node_by_fname won't consider this + anchor for clashes. */ + fname_for_anchor = NULL; + } + else + { + char *dirname, *p; + char filename[PATH_MAX]; + FILE *anchor_stream; + + dirname = pathname_part (current_output_filename); + strcpy (filename, dirname); + strcat (filename, fname_for_anchor); + free (dirname); + + anchor_stream = fopen (filename, "w"); + if (anchor_stream == NULL) + { + fs_error (filename); + xexit (1); + } + /* The HTML magic below will cause the browser to + immediately go to the anchor's node's file. Lynx + seems not to support this redirection, but it looks + like a bug in Lynx, and they can work around it by + clicking on the link once more. */ + fputs ("\n", anchor_stream); + fclose (anchor_stream); + } + } + } + else if (xml) + { + xml_insert_element_with_attribute (ANCHOR, START, "name=\"%s\"", anchor); + xml_insert_element (ANCHOR, END); } - /* Save it in the tag table. */ remember_node (anchor, NULL, NULL, NULL, output_position + output_column, - line_number, TAG_FLAG_ANCHOR); + line_number, fname_for_anchor, TAG_FLAG_ANCHOR); } /* Find NODE in REF_LIST. */ @@ -1114,12 +1378,9 @@ validate_file (tag_table) { line_error (_("Next field of node `%s' not pointed to"), tags->node); - line_number = temp_tag->line_no; - input_filename = temp_tag->filename; - line_error (_("This node (%s) has the bad Prev"), - temp_tag->node); - input_filename = tags->filename; - line_number = tags->line_no; + file_line_error (temp_tag->filename, temp_tag->line_no, + _("This node (%s) has the bad Prev"), + temp_tag->node); temp_tag->flags |= TAG_FLAG_PREV_ERROR; } } @@ -1175,12 +1436,10 @@ validate_file (tag_table) line_error (_("Prev field of node `%s' not pointed to"), tags->node); - line_number = temp_tag->line_no; - input_filename = temp_tag->filename; - line_error (_("This node (%s) has the bad Next"), - temp_tag->node); - input_filename = tags->filename; - line_number = tags->line_no; + file_line_error (temp_tag->filename, + temp_tag->line_no, + _("This node (%s) has the bad Next"), + temp_tag->node); temp_tag->flags |= TAG_FLAG_NEXT_ERROR; } } @@ -1259,13 +1518,9 @@ validate_file (tag_table) if (!nref && !tref) { temp_tag = find_node (tags->up); - line_number = temp_tag->line_no; - input_filename = temp_tag->filename; - line_error ( + file_line_error (temp_tag->filename, temp_tag->line_no, _("Node `%s' lacks menu item for `%s' despite being its Up target"), tags->up, tags->node); - line_number = tags->line_no; - input_filename = tags->filename; } } } diff --git a/contrib/texinfo/makeinfo/node.h b/contrib/texinfo/makeinfo/node.h index e2fc883..735a231 100644 --- a/contrib/texinfo/makeinfo/node.h +++ b/contrib/texinfo/makeinfo/node.h @@ -1,7 +1,7 @@ /* node.h -- declarations for Node. - $Id: node.h,v 1.5 1999/07/11 16:50:19 karl Exp $ + $Id: node.h,v 1.6 2002/01/16 15:52:45 karl Exp $ - Copyright (C) 1996, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1996, 97, 98, 99, 2002 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 @@ -39,6 +39,8 @@ typedef struct tentry int number; /* Number for this node, relevant for HTML splitting -- from use+define order, not just define. */ + char *html_fname; /* The HTML file to which this node is written + (non-NULL only for HTML splitting). */ } TAG_ENTRY; /* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a, diff --git a/contrib/texinfo/makeinfo/sectioning.c b/contrib/texinfo/makeinfo/sectioning.c index b06785b..850fc46 100644 --- a/contrib/texinfo/makeinfo/sectioning.c +++ b/contrib/texinfo/makeinfo/sectioning.c @@ -1,7 +1,7 @@ /* sectioning.c -- all related stuff @chapter, @section... @contents - $Id: sectioning.c,v 1.12 1999/08/17 21:06:50 karl Exp $ + $Id: sectioning.c,v 1.17 2002/02/09 00:54:51 karl Exp $ - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 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 @@ -26,6 +26,7 @@ #include "node.h" #include "toc.h" #include "sectioning.h" +#include "xml.h" /* See comment in sectioning.h. */ section_alist_type section_alist[] = { @@ -210,11 +211,37 @@ what_section (text) return -1; } - void sectioning_underscore (cmd) char *cmd; { + if (xml) + { + char *temp; + int level; + temp = xmalloc (2 + strlen (cmd)); + temp[0] = COMMAND_PREFIX; + strcpy (&temp[1], cmd); + level = what_section (temp); + level -= 2; + free (temp); + xml_close_sections (level); + /* Mark the beginning of the section + If the next command is printindex, we will remove + the section and put an Index instead */ + flush_output (); + xml_last_section_output_position = output_paragraph_offset; + + xml_insert_element (xml_element (cmd), START); + xml_insert_element (TITLE, START); + xml_open_section (level, cmd); + get_rest_of_line (0, &temp); + execute_string ("%s\n", temp); + free (temp); + xml_insert_element (TITLE, END); + } + else + { char character; char *temp; int level; @@ -235,6 +262,7 @@ sectioning_underscore (cmd) { character = scoring_characters[level]; insert_and_underscore (level, character, cmd); + } } } @@ -385,16 +413,22 @@ sectioning_html (level, cmd) old_no_indent = no_indent; no_indent = 1; - add_word_args ("", level + 1); /* level 0 is

    */ + add_word_args ("", level + 2); /* level 0 (chapter) is

    */ /* If we are outside of any node, produce an anchor that the TOC could refer to. */ if (!current_node || !*current_node) { + static const char a_name[] = "", toc_ref_count++); - toc_anchor = substring (starting_pos + 9, + add_word_args ("%sTOC%d\">", a_name, toc_ref_count++); + toc_anchor = substring (starting_pos + sizeof (a_name) - 1, output_paragraph + output_paragraph_offset); + /* This must be added after toc_anchor is extracted, since + toc_anchor cannot include the closing . For details, + see toc.c:toc_add_entry and toc.c:contents_update_html. */ + add_word (""); } starting_pos = output_paragraph + output_paragraph_offset; @@ -431,13 +465,13 @@ sectioning_html (level, cmd) if (section_alist[index].toc == TOC_YES) toc_add_entry (substring (starting_pos, ending_pos), level, current_node, toc_anchor); - + free (temp); if (outstanding_node) outstanding_node = 0; - add_word_args ("", level+1); + add_word_args ("", level + 2); close_paragraph(); filling_enabled = 1; no_indent = old_no_indent; @@ -488,14 +522,8 @@ cm_top () { if (tag->flags & TAG_FLAG_IS_TOP) { - int old_line_number = line_number; - char *old_input_filename = input_filename; - - line_number = tag->line_no; - input_filename = tag->filename; - line_error (_("Here is the %ctop node"), COMMAND_PREFIX); - input_filename = old_input_filename; - line_number = old_line_number; + file_line_error (tag->filename, tag->line_no, + _("Here is the %ctop node"), COMMAND_PREFIX); return; } tag = tag->next_ent; @@ -506,7 +534,7 @@ cm_top () TAG_ENTRY *top_node = find_node ("Top"); top_node_seen = 1; - /* It is an error to use @top before you have used @node. */ + /* It is an error to use @top before using @node. */ if (!tag_table) { char *top_name; @@ -518,21 +546,6 @@ cm_top () free (top_name); return; } - else if (html && splitting) - { - char *next = top_node ? top_node->next : NULL; - - add_word ("

    "); - if (next) - { - add_word (_("Next:")); - add_word ("\n"); - } - } cm_unnumbered (); diff --git a/contrib/texinfo/makeinfo/texinfo.dtd b/contrib/texinfo/makeinfo/texinfo.dtd new file mode 100644 index 0000000..ead278a --- /dev/null +++ b/contrib/texinfo/makeinfo/texinfo.dtd @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/texinfo/makeinfo/texinfo.xsl b/contrib/texinfo/makeinfo/texinfo.xsl new file mode 100644 index 0000000..401e9be --- /dev/null +++ b/contrib/texinfo/makeinfo/texinfo.xsl @@ -0,0 +1,242 @@ + + + + + + + + + + + <xsl:apply-templates select="TEXINFO/SETTITLE" mode="head"/> + + + + + + + + + + + + + + + + + + + +

    + + + + + + + +

    +
    + + + + + + + +

    + + + + + +

    Footnotes

    +
      + +
    +

    +
    + + +

    + + + + + + +

    +
    + + + + + + [ Previous: + + + # + + + + ] + + + + + + [ Up: + + + # + + + + ] + + + + + + [ Next: + + + # + + + + ] + + + + + + +

    Menu

    + +
    + + + + + # + + + + : + +

    +
    + + + + + + + + + + + + + + + + + + +

    +
    + + + +
      + +
    +
    + + +
  • + +
  • +
    + + +
      + +
    +
    + + +
  • + +
  • +
    + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +  
    + 
    +
    + + + + + + + + + + + +
  • +
    + + + diff --git a/contrib/texinfo/makeinfo/toc.c b/contrib/texinfo/makeinfo/toc.c index 41c5ffb..0340f4a 100644 --- a/contrib/texinfo/makeinfo/toc.c +++ b/contrib/texinfo/makeinfo/toc.c @@ -1,7 +1,7 @@ /* toc.c -- table of contents handling. - $Id: toc.c,v 1.14 1999/08/09 20:28:18 karl Exp $ + $Id: toc.c,v 1.21 2002/02/23 19:12:15 karl Exp $ - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 01, 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 @@ -25,6 +25,7 @@ #include "files.h" #include "macro.h" #include "node.h" +#include "html.h" #include "lang.h" #include "makeinfo.h" #include "sectioning.h" @@ -32,7 +33,6 @@ - /* array of toc entries */ static TOC_ENTRY_ELT **toc_entry_alist = NULL; @@ -60,6 +60,7 @@ toc_add_entry (tocname, level, node_name, anchor) char *anchor; { char *tocname_and_node, *expanded_node, *s, *d; + char *filename = NULL; if (!node_name) node_name = ""; @@ -74,52 +75,59 @@ toc_add_entry (tocname, level, node_name, anchor) if (html) { /* We need to insert the expanded node name into the TOC, so - that when we eventually output the TOC, its that separates node from tocname. */ + expansion of HTML-escaping is for the & character, which is + output as "&". 2 is for "> that separates node from tocname. */ d = tocname_and_node = (char *)xmalloc (2 + 5 * strlen (expanded_node) - + strlen (tocname) + 1); + + strlen (tocname) + 1); if (!anchor) - { - for (; *s; s++) - { - if (*s == '&') - { - strcpy (d, "&"); - d += 5; - } - else if (! URL_SAFE_CHAR (*s)) - { - sprintf (d, "%%%x", (unsigned char) *s); - /* do this manually since sprintf returns char * on - SunOS 4 and other old systems. */ - while (*d) - d++; - } - else - *d++ = *s; - } - strcpy (d, "\">"); - } + { + for (; *s; s++) + { + if (*s == '&') + { + strcpy (d, "&"); + d += 5; + } + else if (! URL_SAFE_CHAR (*s)) + { + sprintf (d, "%%%x", (unsigned char) *s); + /* do this manually since sprintf returns char * on + SunOS 4 and other old systems. */ + while (*d) + d++; + } + else + *d++ = *s; + } + strcpy (d, "\">"); + } else - /* Section outside any node, they provided explicit anchor. */ - strcpy (d, anchor); + /* Section outside any node, they provided explicit anchor. */ + strcpy (d, anchor); strcat (d, tocname); free (tocname); /* it was malloc'ed by substring() */ free (expanded_node); @@ -137,6 +145,7 @@ toc_add_entry (tocname, level, node_name, anchor) toc_entry_alist[toc_counter]->containing_node = xstrdup (node_name); toc_entry_alist[toc_counter]->level = level; toc_entry_alist[toc_counter]->number = toc_counter; + toc_entry_alist[toc_counter]->html_file = filename; /* have to be done at least */ return toc_counter++; @@ -192,8 +201,8 @@ toc_free () } -/* print table of contents in HTML, may be we can produce a standalone - HTML file? */ +/* Print table of contents in HTML. */ + static void contents_update_html (fp) FILE *fp; @@ -209,10 +218,10 @@ contents_update_html (fp) flush_output (); /* in case we are writing stdout */ - fprintf (fp, "\n

    %s

    \n