commit bash-20051123 snapshot
[platform/upstream/bash.git] / bashline.c.diff
1 *** ../bash-3.0/bashline.c      Mon Jul  5 23:22:12 2004
2 --- bashline.c  Thu Sep  2 16:00:12 2004
3 ***************
4 *** 101,104 ****
5 --- 101,105 ----
6   
7   /* Helper functions for Readline. */
8 + static int bash_directory_expansion __P((char **));
9   static int bash_directory_completion_hook __P((char **));
10   static int filename_completion_ignore __P((char **));
11 ***************
12 *** 293,297 ****
13         at = strchr (rl_completer_word_break_characters, '@');
14         if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0))
15 !         return;
16   
17         /* We have something to do.  Do it. */
18 --- 294,298 ----
19         at = strchr (rl_completer_word_break_characters, '@');
20         if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0))
21 !         return old_value;
22   
23         /* We have something to do.  Do it. */
24 ***************
25 *** 1407,1414 ****
26           if (*hint_text == '~')
27             {
28 !             int l, tl, vl;
29               vl = strlen (val);
30               tl = strlen (hint_text);
31               l = vl - hint_len;        /* # of chars added */
32               temp = (char *)xmalloc (l + 2 + tl);
33               strcpy (temp, hint_text);
34 --- 1408,1424 ----
35           if (*hint_text == '~')
36             {
37 !             int l, tl, vl, dl;
38 !             char *rd;
39               vl = strlen (val);
40               tl = strlen (hint_text);
41 + #if 0
42               l = vl - hint_len;        /* # of chars added */
43 + #else
44 +             rd = savestring (filename_hint);
45 +             bash_directory_expansion (&rd);
46 +             dl = strlen (rd);
47 +             l = vl - dl;              /* # of chars added */
48 +             free (rd);
49 + #endif
50               temp = (char *)xmalloc (l + 2 + tl);
51               strcpy (temp, hint_text);
52 ***************
53 *** 2188,2191 ****
54 --- 2198,2222 ----
55   }
56   
57 + /* Simulate the expansions that will be performed by
58 +    rl_filename_completion_function.  This must be called with the address of
59 +    a pointer to malloc'd memory. */
60 + static int
61 + bash_directory_expansion (dirname)
62 +      char **dirname;
63 + {
64 +   char *d;
65
66 +   d = savestring (*dirname);
67
68 +   if (rl_directory_rewrite_hook)
69 +     (*rl_directory_rewrite_hook) (&d);
70
71 +   if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d))
72 +     {
73 +       free (*dirname);
74 +       *dirname = d;
75 +     }
76 + }
77 +   
78   /* Handle symbolic link references and other directory name
79      expansions while hacking completion. */
80 ***************
81 *** 2514,2518 ****
82     static int ind;
83     int glen;
84 !   char *ret;
85   
86     if (state == 0)
87 --- 2545,2549 ----
88     static int ind;
89     int glen;
90 !   char *ret, *ttext;
91   
92     if (state == 0)
93 ***************
94 *** 2524,2538 ****
95         FREE (globtext);
96   
97         if (rl_explicit_arg)
98         {
99 !         globorig = savestring (text);
100 !         glen = strlen (text);
101           globtext = (char *)xmalloc (glen + 2);
102 !         strcpy (globtext, text);
103           globtext[glen] = '*';
104           globtext[glen+1] = '\0';
105         }
106         else
107 !         globtext = globorig = savestring (text);
108   
109         matches = shell_glob_filename (globtext);
110 --- 2555,2574 ----
111         FREE (globtext);
112   
113 +       ttext = bash_tilde_expand (text, 0);
114
115         if (rl_explicit_arg)
116         {
117 !         globorig = savestring (ttext);
118 !         glen = strlen (ttext);
119           globtext = (char *)xmalloc (glen + 2);
120 !         strcpy (globtext, ttext);
121           globtext[glen] = '*';
122           globtext[glen+1] = '\0';
123         }
124         else
125 !         globtext = globorig = savestring (ttext);
126
127 !       if (ttext != text)
128 !       free (ttext);
129   
130         matches = shell_glob_filename (globtext);