texinfo-commits
[Top][All Lists]
Advanced

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

[5552] sloppy dir search


From: Gavin D. Smith
Subject: [5552] sloppy dir search
Date: Sun, 11 May 2014 16:14:42 +0000

Revision: 5552
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5552
Author:   gavin
Date:     2014-05-11 16:14:41 +0000 (Sun, 11 May 2014)
Log Message:
-----------
sloppy dir search

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/Makefile.am
    trunk/info/dir.c
    trunk/info/info.c
    trunk/info/nodes.c
    trunk/info/nodes.h
    trunk/info/session.c

Added Paths:
-----------
    trunk/info/t/dir-file-sloppily.sh

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/ChangeLog     2014-05-11 16:14:41 UTC (rev 5552)
@@ -1,3 +1,12 @@
+2014-05-11  Gavin Smith  <address@hidden>
+
+       * info/dir.c (dir_node, get_dir_node): Function renamed.
+       (lookup_dir_entry): New function.  Case insensitive lookup
+       based on that in info_follow_menus.
+       * info/info.c (get_initial_file): Call lookup_dir_entry.
+       * info/session.c (info_follow_menus): Unnecessary test removed.
+       * info/t/dir-file-sloppily.sh: New test.
+
 2014-05-11  Patrice Dumas  <address@hidden>
 
        * tp/t/test_utils.pl(test): use SKIP and not TODO, as TODO is
@@ -26,6 +35,7 @@
 
        * info/info.c (get_initial_file): Store full path of file found
        from dir entry.
+
 2014-05-10  Gavin Smith  <address@hidden>
 
        * info/info.c (get_initial_file): Special handling of "info -O info"

Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am      2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/Makefile.am      2014-05-11 16:14:41 UTC (rev 5552)
@@ -99,6 +99,7 @@
        t/file-relative-path.sh \
        t/dir.sh \
        t/dir-file.sh \
+       t/dir-file-sloppily.sh \
        t/dir-nondir.sh \
        t/dir-no-file.sh \
        t/dir-file-menu.sh \

Modified: trunk/info/dir.c
===================================================================
--- trunk/info/dir.c    2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/dir.c    2014-05-11 16:14:41 UTC (rev 5552)
@@ -77,7 +77,7 @@
 static NODE *build_dir_node (void);
 
 NODE *
-dir_node (char *dirname)
+get_dir_node (void)
 {
   NODE *node;
 
@@ -312,3 +312,36 @@
   node->contents = contents;
   node->nodelen += textlen;
 }
+
+REFERENCE *
+lookup_dir_entry (char *label)
+{
+  NODE *node = get_dir_node ();
+  REFERENCE *entry;
+
+  entry = info_get_menu_entry_by_label (node, label);
+
+  /* If the item wasn't found, search the list sloppily, e.g. the
+     user typed "buffer" when they really meant "Buffers". */
+  /* FIXME: Should this be placed in info_get_menu_entry_by_label? */
+  if (!entry)
+    {
+      int i;
+      int best_guess = -1;
+
+      for (i = 0; (entry = node->references[i]); i++)
+        {
+          if (mbscasecmp (entry->label, label) == 0)
+            break;
+          else if (best_guess == -1
+                && (mbsncasecmp (entry->label, label, strlen (label)) == 0))
+              best_guess = i;
+        }
+
+      if (!entry && best_guess != -1)
+        entry = node->references[best_guess];
+    }
+
+  return entry;
+}
+

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/info.c   2014-05-11 16:14:41 UTC (rev 5552)
@@ -193,9 +193,8 @@
               && mbscasecmp ((*argv)[0], "info") == 0)
             (*argv)[0] = "info-stnd";
 
-          dir_node = info_get_node (0, 0, PARSE_NODE_DFLT);
+          entry = lookup_dir_entry ((*argv)[0]);
 
-          entry = info_get_menu_entry_by_label (dir_node, (*argv)[0]);
           if (entry)
             {
               initial_file = info_find_fullpath (entry->filename, 0);

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/nodes.c  2014-05-11 16:14:41 UTC (rev 5552)
@@ -957,9 +957,6 @@
   FILE_BUFFER *file_buffer = NULL;
   char *filename = 0, *nodename = 0;
 
-  /* Used to build `dir' menu from `localdir' files found in INFOPATH. */
-  extern NODE *dir_node (void);
-
   info_recent_file_error = NULL;
 
   get_filename_and_nodename (flag, window,
@@ -969,7 +966,7 @@
      the "dir"s and "localdir"s found in INFOPATH. */
   if (is_dir_name (filename))
     {
-      node = dir_node ();
+      node = get_dir_node ();
       goto cleanup_and_exit;
     }
 

Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h  2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/nodes.h  2014-05-11 16:14:41 UTC (rev 5552)
@@ -190,5 +190,9 @@
 extern FILE_BUFFER *make_file_buffer (void);
 
 void forget_info_file (char *filename);
+
+/* Found in dir.c */
+extern NODE *get_dir_node (void);
+extern REFERENCE *lookup_dir_entry (char *label);
 
 #endif /* not NODES_H */

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-05-10 23:50:25 UTC (rev 5551)
+++ trunk/info/session.c        2014-05-11 16:14:41 UTC (rev 5552)
@@ -158,13 +158,7 @@
      none of them were valid. */
   if (!window)
     {
-      /* Used to build `dir' menu from `localdir' files found in INFOPATH. */
-      extern NODE *dir_node (void);
-
-      NODE *node;   
-
-      node = dir_node ();
-      info_set_node_of_window (active_window, node);
+      info_set_node_of_window (active_window, get_dir_node ());
       return;
     }
 }
@@ -2838,7 +2832,7 @@
             {
               if (mbscasecmp (entry->label, arg) == 0)
                 break;
-              else if (!strict && (best_guess == -1)
+              else if (best_guess == -1
                     && (mbsncasecmp (entry->label, arg, strlen (arg)) == 0))
                   best_guess = i;
             }

Added: trunk/info/t/dir-file-sloppily.sh
===================================================================
--- trunk/info/t/dir-file-sloppily.sh                           (rev 0)
+++ trunk/info/t/dir-file-sloppily.sh   2014-05-11 16:14:41 UTC (rev 5552)
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Copyright (C) 2014 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 3, 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, see <http://www.gnu.org/licenses/>.
+
+. t/Init-test.inc
+
+# Follow an reference to "file-menu" in dir without matching label exactly
+$GINFO --output - FiLe-M | grep "^File: file-menu,"


Property changes on: trunk/info/t/dir-file-sloppily.sh
___________________________________________________________________
Added: svn:executable
   + *




reply via email to

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