*** ../bash-3.0/bashline.c Mon Jul 5 23:22:12 2004 --- bashline.c Thu Sep 2 16:00:12 2004 *************** *** 101,104 **** --- 101,105 ---- /* Helper functions for Readline. */ + static int bash_directory_expansion __P((char **)); static int bash_directory_completion_hook __P((char **)); static int filename_completion_ignore __P((char **)); *************** *** 293,297 **** at = strchr (rl_completer_word_break_characters, '@'); if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0)) ! return; /* We have something to do. Do it. */ --- 294,298 ---- at = strchr (rl_completer_word_break_characters, '@'); if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0)) ! return old_value; /* We have something to do. Do it. */ *************** *** 1407,1414 **** if (*hint_text == '~') { ! int l, tl, vl; vl = strlen (val); tl = strlen (hint_text); l = vl - hint_len; /* # of chars added */ temp = (char *)xmalloc (l + 2 + tl); strcpy (temp, hint_text); --- 1408,1424 ---- if (*hint_text == '~') { ! int l, tl, vl, dl; ! char *rd; vl = strlen (val); tl = strlen (hint_text); + #if 0 l = vl - hint_len; /* # of chars added */ + #else + rd = savestring (filename_hint); + bash_directory_expansion (&rd); + dl = strlen (rd); + l = vl - dl; /* # of chars added */ + free (rd); + #endif temp = (char *)xmalloc (l + 2 + tl); strcpy (temp, hint_text); *************** *** 2188,2191 **** --- 2198,2222 ---- } + /* Simulate the expansions that will be performed by + rl_filename_completion_function. This must be called with the address of + a pointer to malloc'd memory. */ + static int + bash_directory_expansion (dirname) + char **dirname; + { + char *d; + + d = savestring (*dirname); + + if (rl_directory_rewrite_hook) + (*rl_directory_rewrite_hook) (&d); + + if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d)) + { + free (*dirname); + *dirname = d; + } + } + /* Handle symbolic link references and other directory name expansions while hacking completion. */ *************** *** 2514,2518 **** static int ind; int glen; ! char *ret; if (state == 0) --- 2545,2549 ---- static int ind; int glen; ! char *ret, *ttext; if (state == 0) *************** *** 2524,2538 **** FREE (globtext); if (rl_explicit_arg) { ! globorig = savestring (text); ! glen = strlen (text); globtext = (char *)xmalloc (glen + 2); ! strcpy (globtext, text); globtext[glen] = '*'; globtext[glen+1] = '\0'; } else ! globtext = globorig = savestring (text); matches = shell_glob_filename (globtext); --- 2555,2574 ---- FREE (globtext); + ttext = bash_tilde_expand (text, 0); + if (rl_explicit_arg) { ! globorig = savestring (ttext); ! glen = strlen (ttext); globtext = (char *)xmalloc (glen + 2); ! strcpy (globtext, ttext); globtext[glen] = '*'; globtext[glen+1] = '\0'; } else ! globtext = globorig = savestring (ttext); ! ! if (ttext != text) ! free (ttext); matches = shell_glob_filename (globtext);