Deleted Added
sdiff udiff text old ( 157188 ) new ( 165675 )
full compact
1/* $FreeBSD: head/contrib/libreadline/complete.c 165675 2006-12-31 09:22:31Z ache $ */
2/* complete.c -- filename completion for readline. */
3
4/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it

--- 936 unchanged lines hidden (view full) ---

946
947static char **
948gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
949 char *text;
950 int start, end;
951 rl_compentry_func_t *our_func;
952 int found_quote, quote_char;
953{
954 char **matches;
955
956 rl_completion_found_quote = found_quote;
957 rl_completion_quote_character = quote_char;
958
959 /* If the user wants to TRY to complete, but then wants to give
960 up and use the default completion function, they set the
961 variable rl_attempted_completion_function. */
962 if (rl_attempted_completion_function)
963 {
964 matches = (*rl_attempted_completion_function) (text, start, end);
965
966 if (matches || rl_attempted_completion_over)
967 {
968 rl_attempted_completion_over = 0;
969 return (matches);
970 }
971 }
972
973 /* XXX -- filename dequoting moved into rl_filename_completion_function */
974
975 matches = rl_completion_matches (text, our_func);
976 return matches;
977}
978
979/* Filter out duplicates in MATCHES. This frees up the strings in
980 MATCHES. */
981static char **
982remove_duplicate_matches (matches)
983 char **matches;

--- 116 unchanged lines hidden (view full) ---

1100 {
1101 for (si = 0;
1102 (c1 = match_list[i][si]) &&
1103 (c2 = match_list[i + 1][si]);
1104 si++)
1105#if defined (HANDLE_MULTIBYTE)
1106 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1107 {
1108 mbstate_t ps_back;
1109 ps_back = ps1;
1110 if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2))
1111 break;
1112 else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1)
1113 si += v - 1;
1114 }
1115 else
1116#endif
1117 if (c1 != c2)

--- 841 unchanged lines hidden (view full) ---

1959 temp = tilde_expand (dirname);
1960 free (dirname);
1961 dirname = temp;
1962 }
1963
1964 if (rl_directory_rewrite_hook)
1965 (*rl_directory_rewrite_hook) (&dirname);
1966
1967 /* The directory completion hook should perform any necessary
1968 dequoting. */
1969 if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname))
1970 {
1971 free (users_dirname);
1972 users_dirname = savestring (dirname);
1973 }
1974 else if (rl_completion_found_quote && rl_filename_dequoting_function)
1975 {
1976 /* delete single and double quotes */
1977 temp = (*rl_filename_dequoting_function) (users_dirname, rl_completion_quote_character);
1978 free (users_dirname);
1979 users_dirname = temp;
1980 }
1981 directory = opendir (dirname);
1982
1983 /* Now dequote a non-null filename. */
1984 if (filename && *filename && rl_completion_found_quote && rl_filename_dequoting_function)
1985 {
1986 /* delete single and double quotes */
1987 temp = (*rl_filename_dequoting_function) (filename, rl_completion_quote_character);
1988 free (filename);
1989 filename = temp;
1990 }
1991 filename_len = strlen (filename);
1992
1993 rl_filename_completion_desired = 1;
1994 }
1995
1996 /* At this point we should entertain the possibility of hacking wildcarded
1997 filenames, like /usr/man/man<WILD>/te<TAB>. If the directory name
1998 contains globbing characters, then build an array of directories, and

--- 220 unchanged lines hidden ---