version 1.27, 2003/03/10 00:56:38 |
version 1.33, 2003/09/14 21:55:39 |
Line 94 char *rl_completer_word_break_characters |
|
Line 94 char *rl_completer_word_break_characters |
|
char *rl_completer_quote_characters = NULL; |
char *rl_completer_quote_characters = NULL; |
CPFunction *rl_completion_entry_function = NULL; |
CPFunction *rl_completion_entry_function = NULL; |
CPPFunction *rl_attempted_completion_function = NULL; |
CPPFunction *rl_attempted_completion_function = NULL; |
|
Function *rl_pre_input_hook = NULL; |
|
Function *rl_startup1_hook = NULL; |
|
Function *rl_getc_function = NULL; |
|
char *rl_terminal_name = NULL; |
|
int rl_already_prompted = 0; |
|
int rl_filename_completion_desired = 0; |
|
int rl_ignore_completion_duplicates = 0; |
|
VFunction *rl_redisplay_function = NULL; |
|
Function *rl_startup_hook = NULL; |
|
Function *rl_completion_display_matches_hook = NULL; |
|
VFunction *rl_prep_term_function = NULL; |
|
VFunction *rl_deprep_term_function = NULL; |
|
|
/* |
/* |
|
* The current prompt string. |
|
*/ |
|
char *rl_prompt = NULL; |
|
/* |
* This is set to character indicating type of completion being done by |
* This is set to character indicating type of completion being done by |
* rl_complete_internal(); this is available for application completion |
* rl_complete_internal(); this is available for application completion |
* functions. |
* functions. |
Line 141 static char *_rl_compat_sub(const char |
|
Line 157 static char *_rl_compat_sub(const char |
|
static int rl_complete_internal(int); |
static int rl_complete_internal(int); |
static int _rl_qsort_string_compare(const void *, const void *); |
static int _rl_qsort_string_compare(const void *, const void *); |
|
|
/* |
|
* needed for prompt switching in readline() |
|
*/ |
|
static char *el_rl_prompt = NULL; |
|
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static char * |
static char * |
_get_prompt(EditLine *el) |
_get_prompt(EditLine *el __attribute__((__unused__))) |
{ |
{ |
return (el_rl_prompt); |
rl_already_prompted = 1; |
|
return (rl_prompt); |
} |
} |
|
|
|
|
Line 221 rl_initialize(void) |
|
Line 233 rl_initialize(void) |
|
el_set(e, EL_HIST, history, h); |
el_set(e, EL_HIST, history, h); |
|
|
/* for proper prompt printing in readline() */ |
/* for proper prompt printing in readline() */ |
el_rl_prompt = strdup(""); |
rl_prompt = strdup(""); |
if (el_rl_prompt == NULL) { |
if (rl_prompt == NULL) { |
history_end(h); |
history_end(h); |
el_end(e); |
el_end(e); |
return -1; |
return -1; |
Line 233 rl_initialize(void) |
|
Line 245 rl_initialize(void) |
|
/* set default mode to "emacs"-style and read setting afterwards */ |
/* set default mode to "emacs"-style and read setting afterwards */ |
/* so this can be overriden */ |
/* so this can be overriden */ |
el_set(e, EL_EDITOR, "emacs"); |
el_set(e, EL_EDITOR, "emacs"); |
|
if (rl_terminal_name != NULL) |
|
el_set(e, EL_TERMINAL, rl_terminal_name); |
|
else |
|
el_get(e, EL_TERMINAL, &rl_terminal_name); |
|
|
/* |
/* |
* Word completition - this has to go AFTER rebinding keys |
* Word completition - this has to go AFTER rebinding keys |
Line 242 rl_initialize(void) |
|
Line 258 rl_initialize(void) |
|
"ReadLine compatible completition function", |
"ReadLine compatible completition function", |
_el_rl_complete); |
_el_rl_complete); |
el_set(e, EL_BIND, "^I", "rl_complete", NULL); |
el_set(e, EL_BIND, "^I", "rl_complete", NULL); |
|
|
/* |
/* |
* Find out where the rl_complete function was added; this is |
* Find out where the rl_complete function was added; this is |
* used later to detect that lastcmd was also rl_complete. |
* used later to detect that lastcmd was also rl_complete. |
Line 266 rl_initialize(void) |
|
Line 281 rl_initialize(void) |
|
rl_line_buffer = memchr(li->buffer, *li->buffer, 1); |
rl_line_buffer = memchr(li->buffer, *li->buffer, 1); |
rl_point = rl_end = 0; |
rl_point = rl_end = 0; |
|
|
|
if (rl_startup_hook) |
|
(*rl_startup_hook)(NULL, 0); |
|
|
return (0); |
return (0); |
} |
} |
|
|
Line 288 readline(const char *prompt) |
|
Line 306 readline(const char *prompt) |
|
/* update prompt accordingly to what has been passed */ |
/* update prompt accordingly to what has been passed */ |
if (!prompt) |
if (!prompt) |
prompt = ""; |
prompt = ""; |
if (strcmp(el_rl_prompt, prompt) != 0) { |
if (strcmp(rl_prompt, prompt) != 0) { |
free(el_rl_prompt); |
free(rl_prompt); |
el_rl_prompt = strdup(prompt); |
rl_prompt = strdup(prompt); |
if (el_rl_prompt == NULL) |
if (rl_prompt == NULL) |
return NULL; |
return NULL; |
} |
} |
|
|
|
if (rl_pre_input_hook) |
|
(*rl_pre_input_hook)(NULL, 0); |
|
|
|
rl_already_prompted = 0; |
|
|
/* get one line from input stream */ |
/* get one line from input stream */ |
ret = el_gets(e, &count); |
ret = el_gets(e, &count); |
|
|
Line 333 using_history(void) |
|
Line 357 using_history(void) |
|
|
|
/* |
/* |
* substitute ``what'' with ``with'', returning resulting string; if |
* substitute ``what'' with ``with'', returning resulting string; if |
* globally == 1, substitutes all occurences of what, otherwise only the |
* globally == 1, substitutes all occurrences of what, otherwise only the |
* first one |
* first one |
*/ |
*/ |
static char * |
static char * |
Line 342 _rl_compat_sub(const char *str, const ch |
|
Line 366 _rl_compat_sub(const char *str, const ch |
|
{ |
{ |
char *result; |
char *result; |
const char *temp, *new; |
const char *temp, *new; |
int len, with_len, what_len, add; |
size_t len, with_len, what_len, add; |
size_t size, i; |
size_t size, i; |
|
|
result = malloc((size = 16)); |
result = malloc((size = 16)); |
Line 526 _history_expand_command(const char *comm |
|
Line 550 _history_expand_command(const char *comm |
|
|
|
line = strdup(event_data); |
line = strdup(event_data); |
if (line == NULL) |
if (line == NULL) |
return NULL; |
return 0; |
for (; *cmd; cmd++) { |
for (; *cmd; cmd++) { |
if (*cmd == ':') |
if (*cmd == ':') |
continue; |
continue; |
Line 544 _history_expand_command(const char *comm |
|
Line 568 _history_expand_command(const char *comm |
|
g_on = 2; |
g_on = 2; |
else if (*cmd == 's' || *cmd == '&') { |
else if (*cmd == 's' || *cmd == '&') { |
char *what, *with, delim; |
char *what, *with, delim; |
int len, from_len; |
size_t len, from_len; |
size_t size; |
size_t size; |
|
|
if (*cmd == '&' && (from == NULL || to == NULL)) |
if (*cmd == '&' && (from == NULL || to == NULL)) |
Line 555 _history_expand_command(const char *comm |
|
Line 579 _history_expand_command(const char *comm |
|
what = realloc(from, size); |
what = realloc(from, size); |
if (what == NULL) { |
if (what == NULL) { |
free(from); |
free(from); |
return NULL; |
return 0; |
} |
} |
len = 0; |
len = 0; |
for (; *cmd && *cmd != delim; cmd++) { |
for (; *cmd && *cmd != delim; cmd++) { |
Line 568 _history_expand_command(const char *comm |
|
Line 592 _history_expand_command(const char *comm |
|
(size <<= 1)); |
(size <<= 1)); |
if (nwhat == NULL) { |
if (nwhat == NULL) { |
free(what); |
free(what); |
return NULL; |
return 0; |
} |
} |
what = nwhat; |
what = nwhat; |
} |
} |
Line 581 _history_expand_command(const char *comm |
|
Line 605 _history_expand_command(const char *comm |
|
if (search) { |
if (search) { |
from = strdup(search); |
from = strdup(search); |
if (from == NULL) |
if (from == NULL) |
return NULL; |
return 0; |
} else { |
} else { |
from = NULL; |
from = NULL; |
return (-1); |
return (-1); |
Line 677 _history_expand_command(const char *comm |
|
Line 701 _history_expand_command(const char *comm |
|
|
|
cmdsize = 1, cmdlen = 0; |
cmdsize = 1, cmdlen = 0; |
if ((tempcmd = malloc(cmdsize)) == NULL) |
if ((tempcmd = malloc(cmdsize)) == NULL) |
return NULL; |
return 0; |
for (i = start; start <= i && i <= end; i++) { |
for (i = start; start <= i && i <= end; i++) { |
int arr_len; |
int arr_len; |
|
|
Line 688 _history_expand_command(const char *comm |
|
Line 712 _history_expand_command(const char *comm |
|
ntempcmd = realloc(tempcmd, cmdsize); |
ntempcmd = realloc(tempcmd, cmdsize); |
if (ntempcmd == NULL) { |
if (ntempcmd == NULL) { |
free(tempcmd); |
free(tempcmd); |
return NULL; |
return 0; |
} |
} |
tempcmd = ntempcmd; |
tempcmd = ntempcmd; |
} |
} |
Line 724 history_expand(char *str, char **output) |
|
Line 748 history_expand(char *str, char **output) |
|
|
|
*output = strdup(str); /* do it early */ |
*output = strdup(str); /* do it early */ |
if (*output == NULL) |
if (*output == NULL) |
return NULL; |
return 0; |
|
|
if (str[0] == history_subst_char) { |
if (str[0] == history_subst_char) { |
/* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */ |
/* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */ |
Line 741 history_expand(char *str, char **output) |
|
Line 765 history_expand(char *str, char **output) |
|
char *nresult = realloc(result, (size += len + 1));\ |
char *nresult = realloc(result, (size += len + 1));\ |
if (nresult == NULL) { \ |
if (nresult == NULL) { \ |
free(*output); \ |
free(*output); \ |
return NULL; \ |
return 0; \ |
} \ |
} \ |
result = nresult; \ |
result = nresult; \ |
} \ |
} \ |
Line 1185 history_search_prefix(const char *str, i |
|
Line 1209 history_search_prefix(const char *str, i |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
history_search_pos(const char *str, int direction, int pos) |
history_search_pos(const char *str, |
|
int direction __attribute__((__unused__)), int pos) |
{ |
{ |
HistEvent ev; |
HistEvent ev; |
int curr_num, off; |
int curr_num, off; |
Line 1419 username_completion_function(const char |
|
Line 1444 username_completion_function(const char |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
static unsigned char |
static unsigned char |
_el_rl_complete(EditLine *el, int ch) |
_el_rl_complete(EditLine *el __attribute__((__unused__)), int ch) |
{ |
{ |
return (unsigned char) rl_complete(0, ch); |
return (unsigned char) rl_complete(0, ch); |
} |
} |
Line 1433 completion_matches(const char *text, CPF |
|
Line 1458 completion_matches(const char *text, CPF |
|
{ |
{ |
char **match_list = NULL, *retstr, *prevstr; |
char **match_list = NULL, *retstr, *prevstr; |
size_t match_list_len, max_equal, which, i; |
size_t match_list_len, max_equal, which, i; |
int matches; |
size_t matches; |
|
|
if (h == NULL || e == NULL) |
if (h == NULL || e == NULL) |
rl_initialize(); |
rl_initialize(); |
|
|
matches = 0; |
matches = 0; |
match_list_len = 1; |
match_list_len = 1; |
while ((retstr = (*genfunc) (text, matches)) != NULL) { |
while ((retstr = (*genfunc) (text, (int)matches)) != NULL) { |
/* allow for list terminator here */ |
/* allow for list terminator here */ |
if (matches + 2 >= match_list_len) { |
if (matches + 3 >= match_list_len) { |
char **nmatch_list; |
char **nmatch_list; |
match_list_len <<= 1; |
while (matches + 3 >= match_list_len) |
|
match_list_len <<= 1; |
nmatch_list = realloc(match_list, |
nmatch_list = realloc(match_list, |
match_list_len * sizeof(char *)); |
match_list_len * sizeof(char *)); |
if (nmatch_list == NULL) { |
if (nmatch_list == NULL) { |
Line 1750 rl_read_key(void) |
|
Line 1776 rl_read_key(void) |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
void |
void |
rl_reset_terminal(const char *p) |
rl_reset_terminal(const char *p __attribute__((__unused__))) |
{ |
{ |
|
|
if (h == NULL || e == NULL) |
if (h == NULL || e == NULL) |