complete.c (157188) | complete.c (165675) |
---|---|
1/* $FreeBSD: head/contrib/libreadline/complete.c 157188 2006-03-27 23:11:32Z ache $ */ | 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{ | 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, *temp; | 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 | 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 /* Beware -- we're stripping the quotes here. Do this only if we know 974 we are doing filename completion and the application has defined a 975 filename dequoting function. */ 976 temp = (char *)NULL; | 973 /* XXX -- filename dequoting moved into rl_filename_completion_function */ |
977 | 974 |
978 if (found_quote && our_func == rl_filename_completion_function && 979 rl_filename_dequoting_function) 980 { 981 /* delete single and double quotes */ 982 temp = (*rl_filename_dequoting_function) (text, quote_char); 983 text = temp; /* not freeing text is not a memory leak */ 984 } 985 | |
986 matches = rl_completion_matches (text, our_func); | 975 matches = rl_completion_matches (text, our_func); |
987 FREE (temp); | |
988 return matches; 989} 990 991/* Filter out duplicates in MATCHES. This frees up the strings in 992 MATCHES. */ 993static char ** 994remove_duplicate_matches (matches) 995 char **matches; --- 116 unchanged lines hidden (view full) --- 1112 { 1113 for (si = 0; 1114 (c1 = match_list[i][si]) && 1115 (c2 = match_list[i + 1][si]); 1116 si++) 1117#if defined (HANDLE_MULTIBYTE) 1118 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1119 { | 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 { |
1120 mbstate_t ps_back = ps1; | 1108 mbstate_t ps_back; 1109 ps_back = ps1; |
1121 if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2)) 1122 break; 1123 else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1) 1124 si += v - 1; 1125 } 1126 else 1127#endif 1128 if (c1 != c2) --- 841 unchanged lines hidden (view full) --- 1970 temp = tilde_expand (dirname); 1971 free (dirname); 1972 dirname = temp; 1973 } 1974 1975 if (rl_directory_rewrite_hook) 1976 (*rl_directory_rewrite_hook) (&dirname); 1977 | 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. */ |
|
1978 if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname)) 1979 { 1980 free (users_dirname); 1981 users_dirname = savestring (dirname); 1982 } | 1969 if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname)) 1970 { 1971 free (users_dirname); 1972 users_dirname = savestring (dirname); 1973 } |
1983 | 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 } |
1984 directory = opendir (dirname); | 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 } |
|
1985 filename_len = strlen (filename); 1986 1987 rl_filename_completion_desired = 1; 1988 } 1989 1990 /* At this point we should entertain the possibility of hacking wildcarded 1991 filenames, like /usr/man/man<WILD>/te<TAB>. If the directory name 1992 contains globbing characters, then build an array of directories, and --- 220 unchanged lines hidden --- | 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 --- |