The way html_output_head is called from insert is IMHO a bad idea:
insert should NOT have any surprises; it should simply output the
character passed to it as an argument.  If it doesn't, several parts
of makeinfo will begin to fall apart, because nobody expects insert or
insert_string to do anything but a simple string insertion into the
output stream.

In my case, a Texinfo file whose first ``executable'' line was just
"@*" produced a monstrocity like "<<p>br>" in HTML mode.  But I can
clearly see other similar problems waiting to happen elsewhere.

The solution isn't nice, unfortunately, because of a too liberal use
of insert_string.  But I think the cure is still better than the
desease...

(While at that, I also fixed a memory leak inside html_output_head,
and made the <head> and <body> tags stand out.)


1999-10-16  Eli Zaretskii  <[EMAIL PROTECTED]>

        * makeinfo/makeinfo.c (insert): Don't call html_output_head here.
        (add_char): Call html_output_head here...
        * makeinfo/cmds.c (cm_sp): ...and here...
        * makeinfo/toc.c (cm_contents, cm_shortcontents): ...and here...
        * makeinfo/node.c (cm_anchor): ...and here.

        * makeinfo/html.c (html_output_head): `free' html_title if
        expanded.  Make <head> and <body> stand out.

--- makeinfo/makeinfo.c~0       Sun Sep 19 17:24:44 1999
+++ makeinfo/makeinfo.c Sat Oct 16 09:28:40 1999
@@ -2117,6 +2117,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 <head> `just in time'.  */
+       if (!executing_string && html && !html_output_head_p)
+         html_output_head ();
+
         if (!paragraph_is_open)
           {
             start_paragraph ();
@@ -2263,13 +2271,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 <head> `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)
     {
--- makeinfo/html.c~0   Sat Sep 18 21:27:40 1999
+++ makeinfo/html.c     Sat Oct 16 09:32:42 1999
@@ -39,7 +39,7 @@ html_output_head ()
   /* The <title> should not have markup.  */
   html_title = title ? text_expansion (title) : _("Untitled");
 
-  add_word_args ("<html lang=\"%s\"><head>\n<title>%s</title>\n",
+  add_word_args ("<html lang=\"%s\">\n<head>\n<title>%s</title>\n",
                  language_table[language_code].abbrev, html_title);
 
   add_word ("<meta http-equiv=\"Content-Type\" content=\"text/html");
@@ -50,7 +50,10 @@ html_output_head ()
   add_word_args ("<meta name=description content=\"%s\">\n", html_title);
   add_word_args ("<meta name=generator content=\"makeinfo %s\">\n", VERSION);
   add_word ("<link href=\"http://texinfo.org/\" rel=generator-home>\n");
-  add_word ("</head><body>\n\n");
+  add_word ("</head>\n\n<body>\n");
+
+  if (title)
+    free (html_title);
 }
 
 
--- makeinfo/toc.c~0    Mon Aug  9 23:28:18 1999
+++ makeinfo/toc.c      Sat Oct 16 10:16:22 1999
@@ -442,6 +442,8 @@ cm_contents (arg)
         }
       else
         {
+         if (!executing_string && html)
+           html_output_head ();
           contents_filename = xstrdup (current_output_filename);
           insert_string (contents_placebo); /* just mark it, for now */
         }
@@ -469,6 +471,8 @@ cm_shortcontents (arg)
         }
       else
         {
+         if (!executing_string && html)
+           html_output_head ();
           shortcontents_filename = xstrdup (current_output_filename);
           insert_string (shortcontents_placebo); /* just mark it, for now */
         }
--- makeinfo/cmds.c~1   Fri Oct 15 19:09:42 1999
+++ makeinfo/cmds.c     Sat Oct 16 10:17:02 1999
@@ -825,6 +825,9 @@ cm_sp ()
       
       close_paragraph ();
 
+      if (lines && html && !executing_string)
+       html_output_head ();
+
       while (lines--)
        {
          if (html)
--- makeinfo/node.c~0   Mon Sep 20 14:31:20 1999
+++ makeinfo/node.c     Sat Oct 16 10:24:44 1999
@@ -872,6 +872,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)
            {

Reply via email to