texinfo-commits
[Top][All Lists]
Advanced

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

[5327] Don't return dir entries when called with -a.


From: Sergey Poznyakoff
Subject: [5327] Don't return dir entries when called with -a.
Date: Mon, 19 Aug 2013 09:57:11 +0000

Revision: 5327
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5327
Author:   gray
Date:     2013-08-19 09:57:09 +0000 (Mon, 19 Aug 2013)
Log Message:
-----------
Don't return dir entries when called with -a.  Fix interaction of -a and 
--output.

* info/session.c (info_follow_menus): Add debugging output
on level 3.
In strict mode, return NULL if no matching node was found (by
default initial node is returned).
(dump_nodes_to_file,dump_node_to_file): Take flags in the
last parameter.  If DUMP_APPEND is set, append to the output
file instead of overwriting it.
* info/session.h (DUMP_APPEND, DUMP_SUBNODES): New flags.
* info/filesys.c (info_file_find_next_in_path): Improve
debugging output
* info/info.c (all_files): Set DUMP_APPEND for all but the
first call to dump_node_to_file.
(main): Initialize dump_subnodes.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/filesys.c
    trunk/info/info.c
    trunk/info/session.c
    trunk/info/session.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2013-08-18 18:34:16 UTC (rev 5326)
+++ trunk/ChangeLog     2013-08-19 09:57:09 UTC (rev 5327)
@@ -1,3 +1,22 @@
+2013-08-19  Sergey Poznyakoff  <address@hidden>
+
+       Don't return dir entries when called with -a.  Fix interaction of
+       -a and --output.
+       
+       * info/session.c (info_follow_menus): Add debugging output
+       on level 3.
+       In strict mode, return NULL if no matching node was found (by
+       default initial node is returned).
+       (dump_nodes_to_file,dump_node_to_file): Take flags in the
+       last parameter.  If DUMP_APPEND is set, append to the output
+       file instead of overwriting it.
+       * info/session.h (DUMP_APPEND, DUMP_SUBNODES): New flags.
+       * info/filesys.c (info_file_find_next_in_path): Improve
+       debugging output
+       * info/info.c (all_files): Set DUMP_APPEND for all but the
+       first call to dump_node_to_file.
+       (main): Initialize dump_subnodes.
+
 2013-08-18  Karl Berry  <address@hidden>
 
        * doc/texinfo.texi (Image Syntax): a bit more about Docbook.

Modified: trunk/info/filesys.c
===================================================================
--- trunk/info/filesys.c        2013-08-18 18:34:16 UTC (rev 5326)
+++ trunk/info/filesys.c        2013-08-19 09:57:09 UTC (rev 5327)
@@ -179,9 +179,7 @@
       /* Expand a leading tilde if one is present. */
       if (*temp_dirname == '~')
         {
-          char *expanded_dirname;
-
-          expanded_dirname = tilde_expand_word (temp_dirname);
+          char *expanded_dirname = tilde_expand_word (temp_dirname);
           free (temp_dirname);
           temp_dirname = expanded_dirname;
         }
@@ -208,7 +206,7 @@
             {
               if (S_ISREG (finfo.st_mode))
                 {
-                 debug(1, (_("found %s"), temp));
+                 debug(1, (_("found file %s"), temp));
                   return temp;
                 }
               else if (S_ISDIR (finfo.st_mode))
@@ -223,7 +221,7 @@
                   if (newtemp)
                     {
                       free (temp);
-                     debug(1, (_("found %s"), newtemp));
+                     debug(1, (_("found file %s"), newtemp));
                       return newtemp;
                     }
                 }
@@ -244,7 +242,7 @@
                   statable = (stat (temp, &finfo) == 0);
                   if (statable && (S_ISREG (finfo.st_mode)))
                    {
-                     debug(1, (_("found %s"), temp));
+                     debug(1, (_("found file %s"), temp));
                      return temp;
                    }
                 }

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2013-08-18 18:34:16 UTC (rev 5326)
+++ trunk/info/info.c   2013-08-19 09:57:09 UTC (rev 5327)
@@ -418,7 +418,8 @@
   int i, j;
   int dirok;
   struct namelist_ent *nlist = NULL;
-
+  int dump_flags = dump_subnodes;
+  
   if (user_filename)
     {
       fname = user_filename;
@@ -483,8 +484,10 @@
              if (print_where_p)
                printf ("%s\n", fref[i]->filename);
              else if (user_output_filename)
-               dump_node_to_file (node, user_output_filename,
-                                  dump_subnodes);
+               {
+                 dump_node_to_file (node, user_output_filename, dump_flags);
+                 dump_flags |= DUMP_APPEND;
+               }
              else
                fref[i]->nodename = xstrdup (node->nodename);
              forget_info_file (fref[i]->filename);
@@ -713,6 +716,9 @@
       dump_subnodes = 1;
     }
 
+  if (dump_subnodes)
+    dump_subnodes = DUMP_SUBNODES;
+  
   /* If the user specified --version, then show the version and exit. */
   if (print_version_p)
     {

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2013-08-18 18:34:16 UTC (rev 5326)
+++ trunk/info/session.c        2013-08-19 09:57:09 UTC (rev 5327)
@@ -2823,6 +2823,8 @@
       REFERENCE *entry;
       char *arg = *menus; /* Remember the name of the menu entry we want. */
 
+      debug(3, ("looking for %s in %s", arg, initial_node->filename,
+               initial_node->nodename));
       /* A leading space is certainly NOT part of a node name.  Most
          probably, they typed a space after the separating comma.  The
          strings in menus[] have their whitespace canonicalized, so
@@ -2840,16 +2842,20 @@
          realize it. */
       if (!menu)
         {
+         debug(3, ("no menu found"));
           if (arg == first_arg && !strict)
             {
               node = make_manpage_node (first_arg);
               if (node)
-                goto maybe_got_node;
+               {
+                 debug(3, ("falling back to manpage node"));
+                 goto maybe_got_node;
+               }
             }
          if (err_node)
            *err_node = format_message_node (_("No menu in node `%s'."),
                                             node_printed_rep (initial_node));
-          return initial_node;
+          return strict ? NULL : initial_node;
         }
 
       /* Find the specified menu item. */
@@ -2862,6 +2868,7 @@
           int i;
           int best_guess = -1;
 
+         debug(3, ("no entry found: guessing"));
           for (i = 0; (entry = menu[i]); i++)
             {
               if (mbscasecmp (entry->label, arg) == 0)
@@ -2898,7 +2905,7 @@
            *err_node = format_message_node (_("No menu item `%s' in node 
`%s'."),
                                             arg,
                                             node_printed_rep (initial_node));
-          return initial_node;
+          return strict ? NULL : initial_node;
         }
 
       /* We have found the reference that the user specified.  If no
@@ -2907,6 +2914,8 @@
         entry->filename = xstrdup (initial_node->parent ? initial_node->parent
                                                      : initial_node->filename);
 
+      debug(3, ("entry: %s, %s", entry->filename, entry->nodename));
+      
       /* Try to find this node.  */
       node = info_get_node (entry->filename, entry->nodename, 
                             PARSE_NODE_VERBATIM);
@@ -2926,15 +2935,18 @@
     maybe_got_node:
       if (!node)
         {
+         debug(3, ("no matching node found"));
          if (err_node)
            *err_node = format_message_node (
                     _("Unable to find node referenced by `%s' in `%s'."),
                     entry->label,
                     node_printed_rep (initial_node));
           info_free_references (menu);
-          return initial_node;
+          return strict ? NULL : initial_node;
         }
 
+      debug(3, ("node: %s, %s", node->filename, node->nodename));
+      
       info_free_references (menu);
 
       /* Success.  Go round the loop again.  */
@@ -3480,11 +3492,11 @@
 static void initialize_dumping (void);
 
 /* Dump the nodes specified by FILENAME and NODENAMES to the file named
-   in OUTPUT_FILENAME.  If DUMP_SUBNODES is non-zero, recursively dump
+   in OUTPUT_FILENAME.  If DUMP_SUBNODES is set, recursively dump
    the nodes which appear in the menu of each node dumped. */
 void
 dump_nodes_to_file (char *filename, char **nodenames,
-    char *output_filename, int dump_subnodes)
+                   char *output_filename, int flags)
 {
   register int i;
   FILE *output_stream;
@@ -3494,7 +3506,7 @@
   if (strcmp (output_filename, "-") == 0)
     output_stream = stdout;
   else
-    output_stream = fopen (output_filename, "w");
+    output_stream = fopen (output_filename, flags & DUMP_APPEND ? "a" : "w");
 
   if (!output_stream)
     {
@@ -3505,7 +3517,8 @@
   /* Print each node to stream. */
   initialize_dumping ();
   for (i = 0; nodenames[i]; i++)
-    dump_node_to_stream (filename, nodenames[i], output_stream, dump_subnodes);
+    dump_node_to_stream (filename, nodenames[i], output_stream,
+                        flags & DUMP_SUBNODES);
 
   if (output_stream != stdout)
     fclose (output_stream);
@@ -3598,10 +3611,10 @@
   free (node);
 }
 
-/* Dump NODE to FILENAME.  If DUMP_SUBNODES is non-zero, recursively dump
+/* Dump NODE to FILENAME.  If DUMP_SUBNODES is set, recursively dump
    the nodes which appear in the menu of each node dumped. */
 void
-dump_node_to_file (NODE *node, char *filename, int dump_subnodes)
+dump_node_to_file (NODE *node, char *filename, int flags)
 {
   FILE *output_stream;
   char *nodes_filename;
@@ -3611,7 +3624,7 @@
   if (strcmp (filename, "-") == 0)
     output_stream = stdout;
   else
-    output_stream = fopen (filename, "w");
+    output_stream = fopen (filename, flags & DUMP_APPEND ? "a" : "w");
 
   if (!output_stream)
     {
@@ -3625,8 +3638,10 @@
     nodes_filename = node->filename;
 
   initialize_dumping ();
-  dump_node_to_stream
-    (nodes_filename, node->nodename, output_stream, dump_subnodes);
+  if (flags & DUMP_APPEND)
+    fputc ('\f', output_stream);
+  dump_node_to_stream (nodes_filename, node->nodename,
+                      output_stream, flags & DUMP_SUBNODES);
 
   if (output_stream != stdout)
     fclose (output_stream);

Modified: trunk/info/session.h
===================================================================
--- trunk/info/session.h        2013-08-18 18:34:16 UTC (rev 5326)
+++ trunk/info/session.h        2013-08-19 09:57:09 UTC (rev 5327)
@@ -95,10 +95,15 @@
 extern void info_select_reference (WINDOW *window, REFERENCE *entry);
 extern int info_any_buffered_input_p (void);
 extern void print_node (NODE *node);
+
+#define DUMP_APPEND   0x01
+#define DUMP_SUBNODES 0x02
+
 extern void dump_node_to_file (NODE *node, char *filename,
-    int dump_subnodes);
+                              int flags);
 extern void dump_nodes_to_file (char *filename, char **nodenames,
-    char *output_filename, int dump_subnodes);
+                               char *output_filename, int flags);
+
 extern char *program_name_from_file_name (char *file_name);
 
 /* Do the physical deletion of WINDOW, and forget this window and




reply via email to

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