bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug with Top and --html?


From: Eli Zaretskii
Subject: Re: bug with Top and --html?
Date: Wed, 30 Jan 2002 21:53:14 +0200

> From: "pascal barbedor" <address@hidden>
> Date: Tue, 29 Jan 2002 20:39:04 +0100
> 
> makeinfo --html file
> gives the subdir, index.html, node1.html and node2.html, all correct
> 
> now in a text editor replace every instance of "Top" with "Racine" and save
> 
> makeinfo --html file
> gives the subdir, and all nodes in index.html. 
> node1.html and node2.html are still there but correspond to the first run

Thanks.

It turns out the limitation to have the Top node could be lifted
altogether.  The patch below does that; please try it.


2002-01-30  Eli Zaretskii  <address@hidden>

        * makeinfo/node.c (cm_node): Don't condition splitting on
        top_node_seen being non-zero.  If current_node is NULL, use the
        current output file name to get at the file name for the previous
        node.  Don't compute a new file name for a node if we didn't close
        the current file.


--- makeinfo/node.c~0   Wed Jan 16 17:52:52 2002
+++ makeinfo/node.c     Wed Jan 30 20:56:16 2002
@@ -526,7 +526,10 @@ cm_node ()
   prev = get_node_token (0);
   up = get_node_token (0);
 
-  if (html && splitting && top_node_seen)
+  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".
@@ -537,11 +540,16 @@ cm_node ()
        {
          char *fname_for_prev_node;
 
-         tem = expand_node_name (current_node);
-         /* NOTE: current_node at this point still holds the name of
-             the previous node.  */
-         fname_for_prev_node = nodename_to_filename (tem);
-         free (tem);
+         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);
@@ -824,7 +832,7 @@ cm_node ()
 
   if (html)
     {
-      if (splitting && top_node_seen && *node)
+      if (splitting && *node && output_stream == NULL)
         {
          char *dirname;
          char filename[PATH_MAX];
@@ -834,55 +842,52 @@ cm_node ()
          strcat (filename, fname_for_this_node);
          free (dirname);
 
-         if (output_stream == NULL)
+         /* 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");
+         else if ((tag->flags & TAG_FLAG_ANCHOR) != 0)
            {
-             /* 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");
-             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");
-               }
-             else
+             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");
+           }
+         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)
                {
-                 /* 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[] = "</body></html>\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)
                    {
-                     static char html_end[] = "</body></html>\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);
+                     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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]