summaryrefslogtreecommitdiff
path: root/shells/bash/files/patch-bashline.c
blob: 24b74307d96633f0e1ba4944f2ff2f82fde8e2df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
--- bashline.c.deo	Tue May  7 12:52:42 2002
+++ bashline.c	Sun Sep  8 18:17:30 2002
@@ -1873,10 +1874,6 @@
     }
 }
 
-/* Define NO_FORCE_FIGNORE if you want to match filenames that would
-   otherwise be ignored if they are the only possible matches. */
-/* #define NO_FORCE_FIGNORE */
-
 /* If FIGNORE is set, then don't match files with the given suffixes when
    completing filenames.  If only one of the possibilities has an acceptable
    suffix, delete the others, else just return and let the completer
@@ -1901,10 +1898,15 @@
 {
   char **newnames;
   int idx, nidx;
-#ifdef NO_FORCE_FIGNORE
   char **oldnames;
   int oidx;
-#endif
+  char *no_force_fignore;
+
+
+/* Set NO_FORCE_FIGNORE if you want to match filenames that would
+   otherwise be ignored if they are the only possible matches. */
+  no_force_fignore = get_string_value ("NO_FORCE_FIGNORE");
+//fprintf(stderr, ">NO_FORCE_FIGNORE< is [%s]\n", no_force_fignore);
 
   /* If there is only one completion, see if it is acceptable.  If it is
      not, free it up.  In any case, short-circuit and return.  This is a
@@ -1912,13 +1914,12 @@
      if there is only one completion; it is the completion itself. */
   if (names[1] == (char *)0)
     {
-#ifndef NO_FORCE_FIGNORE
-      if ((*name_func) (names[0]) == 0)
-	{
-	  free (names[0]);
-	  names[0] = (char *)NULL;
-	}
-#endif
+      if (!no_force_fignore)
+	if ((*name_func) (names[0]) == 0)
+	  {
+	    free (names[0]);
+	    names[0] = (char *)NULL;
+	  }
       return;
     }
 
@@ -1927,10 +1928,11 @@
   for (nidx = 1; names[nidx]; nidx++)
     ;
   newnames = strvec_create (nidx + 1);
-#ifdef NO_FORCE_FIGNORE
-  oldnames = strvec_create (nidx - 1);
-  oidx = 0;
-#endif
+  if (no_force_fignore)
+    {
+      oldnames = strvec_create (nidx - 1);
+      oidx = 0;
+    }
 
   newnames[0] = names[0];
   for (idx = nidx = 1; names[idx]; idx++)
@@ -1938,11 +1940,10 @@
       if ((*name_func) (names[idx]))
 	newnames[nidx++] = names[idx];
       else
-#ifndef NO_FORCE_FIGNORE
-	free (names[idx]);
-#else
-	oldnames[oidx++] = names[idx];
-#endif
+	if (no_force_fignore)
+	  oldnames[oidx++] = names[idx];
+	else
+	  free (names[idx]);
     }
 
   newnames[nidx] = (char *)NULL;
@@ -1950,21 +1951,23 @@
   /* If none are acceptable then let the completer handle it. */
   if (nidx == 1)
     {
-#ifndef NO_FORCE_FIGNORE
-      free (names[0]);
-      names[0] = (char *)NULL;
-#else
-      free (oldnames);
-#endif
+      if (no_force_fignore)
+        free (oldnames);
+      else
+	{
+	  free (names[0]);
+	  names[0] = (char *)NULL;
+	}
       free (newnames);
       return;
     }
 
-#ifdef NO_FORCE_FIGNORE
-  while (oidx)
-    free (oldnames[--oidx]);
-  free (oldnames);
-#endif
+  if (no_force_fignore)
+    {
+      while (oidx)
+	free (oldnames[--oidx]);
+      free (oldnames);
+    }
 
   /* If only one is acceptable, copy it to names[0] and return. */
   if (nidx == 2)