diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-05-10 19:36:21 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-05-10 19:36:21 +0000 |
commit | 16c976bbd7783cd3ab53b106e760777ae76923ca (patch) | |
tree | 228ff462549c6deff6f4af832cb305a75fde94b9 /gnu/lib/libreadline | |
parent | 3a9bff98822feb81effbedf489d56369752101dc (diff) |
Resolve conflicts for GNU readline 4.3p5.
ok deraadt@, otto@, pval@
Diffstat (limited to 'gnu/lib/libreadline')
34 files changed, 9741 insertions, 5602 deletions
diff --git a/gnu/lib/libreadline/Makefile b/gnu/lib/libreadline/Makefile index a9e5d5a2991..fd3e68a1fca 100644 --- a/gnu/lib/libreadline/Makefile +++ b/gnu/lib/libreadline/Makefile @@ -1,11 +1,13 @@ -# $OpenBSD: Makefile,v 1.5 2002/04/19 14:12:03 espie Exp $ +# $OpenBSD: Makefile,v 1.6 2004/05/10 19:36:20 kettenis Exp $ LIB= readline SRCS= readline.c funmap.c keymaps.c vi_mode.c parens.c rltty.c complete.c \ bind.c isearch.c display.c signals.c util.c kill.c undo.c macro.c \ input.c callback.c terminal.c xmalloc.c history.c histsearch.c \ - histexpand.c histfile.c nls.c search.c shell.c savestring.c tilde.c -HDRS= readline.h chardefs.h keymaps.h history.h tilde.h rlstdc.h rlconf.h + histexpand.c histfile.c nls.c search.c shell.c savestring.c tilde.c \ + text.c nls.c misc.c compat.c mbutil.c +HDRS= readline.h chardefs.h keymaps.h history.h tilde.h rlstdc.h rlconf.h \ + rltypedefs.h SUBDIR= doc CPPFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} diff --git a/gnu/lib/libreadline/bind.c b/gnu/lib/libreadline/bind.c index d9947c389df..5f5ff6a9af5 100644 --- a/gnu/lib/libreadline/bind.c +++ b/gnu/lib/libreadline/bind.c @@ -68,9 +68,11 @@ extern char *strchr (), *strrchr (); /* Variables exported by this file. */ Keymap rl_binding_keymap; -static int _rl_read_init_file __P((char *, int)); -static int glean_key_from_name __P((char *)); -static int substring_member_of_array __P((char *, char **)); +static char *_rl_read_file PARAMS((char *, size_t *)); +static void _rl_init_file_error PARAMS((const char *)); +static int _rl_read_init_file PARAMS((const char *, int)); +static int glean_key_from_name PARAMS((char *)); +static int substring_member_of_array PARAMS((char *, const char **)); static int currently_reading_init_file; @@ -83,13 +85,13 @@ static int _rl_prefer_visible_bell = 1; /* */ /* **************************************************************** */ -/* rl_add_defun (char *name, Function *function, int key) +/* rl_add_defun (char *name, rl_command_func_t *function, int key) Add NAME to the list of named functions. Make FUNCTION be the function that gets called. If KEY is not -1, then bind it. */ int rl_add_defun (name, function, key) - char *name; - Function *function; + const char *name; + rl_command_func_t *function; int key; { if (key != -1) @@ -102,7 +104,7 @@ rl_add_defun (name, function, key) int rl_bind_key (key, function) int key; - Function *function; + rl_command_func_t *function; { if (key < 0) return (key); @@ -133,7 +135,7 @@ rl_bind_key (key, function) int rl_bind_key_in_map (key, function, map) int key; - Function *function; + rl_command_func_t *function; Keymap map; { int result; @@ -152,7 +154,7 @@ int rl_unbind_key (key) int key; { - return (rl_bind_key (key, (Function *)NULL)); + return (rl_bind_key (key, (rl_command_func_t *)NULL)); } /* Make KEY do nothing in MAP. @@ -162,13 +164,13 @@ rl_unbind_key_in_map (key, map) int key; Keymap map; { - return (rl_bind_key_in_map (key, (Function *)NULL, map)); + return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map)); } /* Unbind all keys bound to FUNCTION in MAP. */ int rl_unbind_function_in_map (func, map) - Function *func; + rl_command_func_t *func; Keymap map; { register int i, rval; @@ -177,7 +179,7 @@ rl_unbind_function_in_map (func, map) { if (map[i].type == ISFUNC && map[i].function == func) { - map[i].function = (Function *)NULL; + map[i].function = (rl_command_func_t *)NULL; rval = 1; } } @@ -186,10 +188,10 @@ rl_unbind_function_in_map (func, map) int rl_unbind_command_in_map (command, map) - char *command; + const char *command; Keymap map; { - Function *func; + rl_command_func_t *func; func = rl_named_function (command); if (func == 0) @@ -202,8 +204,8 @@ rl_unbind_command_in_map (command, map) place to do bindings is in MAP. */ int rl_set_key (keyseq, function, map) - char *keyseq; - Function *function; + const char *keyseq; + rl_command_func_t *function; Keymap map; { return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map)); @@ -214,7 +216,7 @@ rl_set_key (keyseq, function, map) necessary. The initial place to do bindings is in MAP. */ int rl_macro_bind (keyseq, macro, map) - char *keyseq, *macro; + const char *keyseq, *macro; Keymap map; { char *macro_keys; @@ -239,12 +241,16 @@ rl_macro_bind (keyseq, macro, map) int rl_generic_bind (type, keyseq, data, map) int type; - char *keyseq, *data; + const char *keyseq; + char *data; Keymap map; { char *keys; int keys_len; register int i; + KEYMAP_ENTRY k; + + k.function = 0; /* If no keys to bind to, exit right away. */ if (!keyseq || !*keyseq) @@ -254,7 +260,7 @@ rl_generic_bind (type, keyseq, data, map) return -1; } - keys = xmalloc (1 + (2 * strlen (keyseq))); + keys = (char *)xmalloc (1 + (2 * strlen (keyseq))); /* Translate the ASCII representation of KEYSEQ into an array of characters. Stuff the characters into KEYS, and the length of @@ -268,7 +274,12 @@ rl_generic_bind (type, keyseq, data, map) /* Bind keys, making new keymaps as necessary. */ for (i = 0; i < keys_len; i++) { - int ic = (int) ((unsigned char)keys[i]); + unsigned char uc = keys[i]; + int ic; + + ic = uc; + if (ic < 0 || ic >= KEYMAP_SIZE) + return -1; if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic)) { @@ -281,18 +292,40 @@ rl_generic_bind (type, keyseq, data, map) { if (map[ic].type != ISKMAP) { - if (map[ic].type == ISMACR) - free ((char *)map[ic].function); + /* We allow subsequences of keys. If a keymap is being + created that will `shadow' an existing function or macro + key binding, we save that keybinding into the ANYOTHERKEY + index in the new map. The dispatch code will look there + to find the function to execute if the subsequence is not + matched. ANYOTHERKEY was chosen to be greater than + UCHAR_MAX. */ + k = map[ic]; map[ic].type = ISKMAP; map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap()); } map = FUNCTION_TO_KEYMAP (map, ic); + /* The dispatch code will return this function if no matching + key sequence is found in the keymap. This (with a little + help from the dispatch code in readline.c) allows `a' to be + mapped to something, `abc' to be mapped to something else, + and the function bound to `a' to be executed when the user + types `abx', leaving `bx' in the input queue. */ + if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR)) + { + map[ANYOTHERKEY] = k; + k.function = 0; + } } else { if (map[ic].type == ISMACR) free ((char *)map[ic].function); + else if (map[ic].type == ISKMAP) + { + map = FUNCTION_TO_KEYMAP (map, ic); + ic = ANYOTHERKEY; + } map[ic].function = KEYMAP_TO_FUNCTION (data); map[ic].type = type; @@ -309,7 +342,8 @@ rl_generic_bind (type, keyseq, data, map) non-zero if there was an error parsing SEQ. */ int rl_translate_keyseq (seq, array, len) - char *seq, *array; + const char *seq; + char *array; int *len; { register int i, c, l, temp; @@ -329,7 +363,7 @@ rl_translate_keyseq (seq, array, len) /* Handle special case of backwards define. */ if (strncmp (&seq[i], "C-\\M-", 5) == 0) { - array[l++] = ESC; + array[l++] = ESC; /* ESC is meta-prefix */ i += 5; array[l++] = CTRL (_rl_to_upper (seq[i])); if (seq[i] == '\0') @@ -338,7 +372,7 @@ rl_translate_keyseq (seq, array, len) else if (c == 'M') { i++; - array[l++] = ESC; /* XXX */ + array[l++] = ESC; /* ESC is meta-prefix */ } else if (c == 'C') { @@ -391,16 +425,16 @@ rl_translate_keyseq (seq, array, len) for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++) c = (c * 8) + OCTVALUE (seq[i]); i--; /* auto-increment in for loop */ - array[l++] = c % (largest_char + 1); + array[l++] = c & largest_char; break; case 'x': i++; - for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++) + for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++) c = (c * 16) + HEXVALUE (seq[i]); - if (temp == 3) + if (temp == 2) c = 'x'; i--; /* auto-increment in for loop */ - array[l++] = c % (largest_char + 1); + array[l++] = c & largest_char; break; default: /* backslashes before non-special chars just add the char */ array[l++] = c; @@ -470,7 +504,7 @@ _rl_untranslate_macro_value (seq) char *ret, *r, *s; int c; - r = ret = xmalloc (7 * strlen (seq) + 1); + r = ret = (char *)xmalloc (7 * strlen (seq) + 1); for (s = seq; *s; s++) { c = *s; @@ -513,9 +547,9 @@ _rl_untranslate_macro_value (seq) /* Return a pointer to the function that STRING represents. If STRING doesn't have a matching function, then a NULL pointer is returned. */ -Function * +rl_command_func_t * rl_named_function (string) - char *string; + const char *string; { register int i; @@ -524,7 +558,7 @@ rl_named_function (string) for (i = 0; funmap[i]; i++) if (_rl_stricmp (funmap[i]->name, string) == 0) return (funmap[i]->function); - return ((Function *)NULL); + return ((rl_command_func_t *)NULL); } /* Return the function (or macro) definition which would be invoked via @@ -532,9 +566,9 @@ rl_named_function (string) used. TYPE, if non-NULL, is a pointer to an int which will receive the type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), or ISMACR (macro). */ -Function * +rl_command_func_t * rl_function_of_keyseq (keyseq, map, type) - char *keyseq; + const char *keyseq; Keymap map; int *type; { @@ -545,7 +579,7 @@ rl_function_of_keyseq (keyseq, map, type) for (i = 0; keyseq && keyseq[i]; i++) { - int ic = keyseq[i]; + unsigned char ic = keyseq[i]; if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) { @@ -585,14 +619,14 @@ rl_function_of_keyseq (keyseq, map, type) return (map[ic].function); } } - return ((Function *) NULL); + return ((rl_command_func_t *) NULL); } /* The last key bindings file read. */ static char *last_readline_init_file = (char *)NULL; /* The file we're currently reading key bindings from. */ -static char *current_readline_init_file; +static const char *current_readline_init_file; static int current_readline_init_include_level; static int current_readline_init_lineno; @@ -630,25 +664,15 @@ _rl_read_file (filename, sizep) i = read (file, buffer, file_size); close (file); -#if 0 - if (i < file_size) -#else if (i < 0) -#endif { free (buffer); return ((char *)NULL); } -#if 0 - buffer[file_size] = '\0'; - if (sizep) - *sizep = file_size; -#else buffer[i] = '\0'; if (sizep) *sizep = i; -#endif return (buffer); } @@ -659,7 +683,7 @@ rl_re_read_init_file (count, ignore) int count, ignore; { int r; - r = rl_read_init_file ((char *)NULL); + r = rl_read_init_file ((const char *)NULL); rl_set_keymap_from_edit_mode (); return r; } @@ -673,14 +697,14 @@ rl_re_read_init_file (count, ignore) otherwise errno is returned. */ int rl_read_init_file (filename) - char *filename; + const char *filename; { /* Default the filename. */ if (filename == 0) { filename = last_readline_init_file; if (filename == 0) - filename = get_env_value ("INPUTRC"); + filename = sh_get_env_value ("INPUTRC"); if (filename == 0 || *filename == '\0') filename = DEFAULT_INPUTRC; } @@ -698,7 +722,7 @@ rl_read_init_file (filename) static int _rl_read_init_file (filename, include_level) - char *filename; + const char *filename; int include_level; { register int i; @@ -733,7 +757,7 @@ _rl_read_init_file (filename, include_level) /* Find the end of this line. */ for (i = 0; line + i != end && line[i] != '\n'; i++); -#if defined (__CYGWIN32__) +#if defined (__CYGWIN__) /* ``Be liberal in what you accept.'' */ if (line[i] == '\n' && line[i-1] == '\r') line[i - 1] = '\0'; @@ -765,7 +789,7 @@ _rl_read_init_file (filename, include_level) static void _rl_init_file_error (msg) - char *msg; + const char *msg; { if (currently_reading_init_file) fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file, @@ -780,10 +804,21 @@ _rl_init_file_error (msg) /* */ /* **************************************************************** */ +typedef int _rl_parser_func_t PARAMS((char *)); + +/* Things that mean `Control'. */ +const char *_rl_possible_control_prefixes[] = { + "Control-", "C-", "CTRL-", (const char *)NULL +}; + +const char *_rl_possible_meta_prefixes[] = { + "Meta", "M-", (const char *)NULL +}; + /* Conditionals. */ /* Calling programs set this to have their argv[0]. */ -char *rl_readline_name = "other"; +const char *rl_readline_name = "other"; /* Stack of previous values of parsing_conditionalized_out. */ static unsigned char *if_stack = (unsigned char *)NULL; @@ -905,7 +940,8 @@ static int parser_include (args) char *args; { - char *old_init_file, *e; + const char *old_init_file; + char *e; int old_line_number, old_include_level, r; if (_rl_parsing_conditionalized_out) @@ -918,7 +954,7 @@ parser_include (args) e = strchr (args, '\n'); if (e) *e = '\0'; - r = _rl_read_init_file (args, old_include_level + 1); + r = _rl_read_init_file ((const char *)args, old_include_level + 1); current_readline_init_file = old_init_file; current_readline_init_lineno = old_line_number; @@ -929,14 +965,14 @@ parser_include (args) /* Associate textual names with actual functions. */ static struct { - char *name; - Function *function; + const char *name; + _rl_parser_func_t *function; } parser_directives [] = { { "if", parser_if }, { "endif", parser_endif }, { "else", parser_else }, { "include", parser_include }, - { (char *)0x0, (Function *)0x0 } + { (char *)0x0, (_rl_parser_func_t *)0x0 } }; /* Handle a parser directive. STATEMENT is the line of the directive @@ -1061,7 +1097,7 @@ rl_parse_and_bind (string) /* Make VAR point to start of variable name. */ while (*var && whitespace (*var)) var++; - /* Make value point to start of value string. */ + /* Make VALUE point to start of value string. */ value = var; while (*value && !whitespace (*value)) value++; if (*value) @@ -1131,7 +1167,7 @@ rl_parse_and_bind (string) char *seq; register int j, k, passc; - seq = xmalloc (1 + strlen (string)); + seq = (char *)xmalloc (1 + strlen (string)); for (j = 1, k = passc = 0; string[j]; j++) { /* Allow backslash to quote characters, but leave them in place. @@ -1180,16 +1216,16 @@ rl_parse_and_bind (string) key = glean_key_from_name (kname); /* Add in control and meta bits. */ - if (substring_member_of_array (string, possible_control_prefixes)) + if (substring_member_of_array (string, _rl_possible_control_prefixes)) key = CTRL (_rl_to_upper (key)); - if (substring_member_of_array (string, possible_meta_prefixes)) + if (substring_member_of_array (string, _rl_possible_meta_prefixes)) key = META (key); /* Temporary. Handle old-style keyname with macro-binding. */ if (*funname == '\'' || *funname == '"') { - unsigned char useq[2]; + char useq[2]; int fl = strlen (funname); useq[0] = key; useq[1] = '\0'; @@ -1221,22 +1257,27 @@ rl_parse_and_bind (string) #define V_SPECIAL 0x1 static struct { - char *name; + const char *name; int *value; int flags; } boolean_varlist [] = { { "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL }, + { "byte-oriented", &rl_byte_oriented, 0 }, { "completion-ignore-case", &_rl_completion_case_fold, 0 }, { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 }, { "disable-completion", &rl_inhibit_completion, 0 }, { "enable-keypad", &_rl_enable_keypad, 0 }, { "expand-tilde", &rl_complete_with_tilde_expansion, 0 }, + { "history-preserve-point", &_rl_history_preserve_point, 0 }, { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 }, { "input-meta", &_rl_meta_flag, 0 }, { "mark-directories", &_rl_complete_mark_directories, 0 }, { "mark-modified-lines", &_rl_mark_modified_lines, 0 }, + { "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 }, + { "match-hidden-files", &_rl_match_hidden_files, 0 }, { "meta-flag", &_rl_meta_flag, 0 }, { "output-meta", &_rl_output_meta_chars, 0 }, + { "page-completions", &_rl_page_completions, 0 }, { "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL }, { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 }, { "show-all-if-ambiguous", &_rl_complete_show_all, 0 }, @@ -1248,7 +1289,7 @@ static struct { static int find_boolean_var (name) - char *name; + const char *name; { register int i; @@ -1265,7 +1306,7 @@ static void hack_special_boolean_var (i) int i; { - char *name; + const char *name; name = boolean_varlist[i].name; @@ -1280,6 +1321,8 @@ hack_special_boolean_var (i) } } +typedef int _rl_sv_func_t PARAMS((const char *)); + /* These *must* correspond to the array indices for the appropriate string variable. (Though they're not used right now.) */ #define V_BELLSTYLE 0 @@ -1292,17 +1335,17 @@ hack_special_boolean_var (i) #define V_INT 2 /* Forward declarations */ -static int sv_bell_style __P((char *)); -static int sv_combegin __P((char *)); -static int sv_compquery __P((char *)); -static int sv_editmode __P((char *)); -static int sv_isrchterm __P((char *)); -static int sv_keymap __P((char *)); +static int sv_bell_style PARAMS((const char *)); +static int sv_combegin PARAMS((const char *)); +static int sv_compquery PARAMS((const char *)); +static int sv_editmode PARAMS((const char *)); +static int sv_isrchterm PARAMS((const char *)); +static int sv_keymap PARAMS((const char *)); static struct { - char *name; + const char *name; int flags; - Function *set_func; + _rl_sv_func_t *set_func; } string_varlist[] = { { "bell-style", V_STRING, sv_bell_style }, { "comment-begin", V_STRING, sv_combegin }, @@ -1315,7 +1358,7 @@ static struct { static int find_string_var (name) - char *name; + const char *name; { register int i; @@ -1339,7 +1382,7 @@ bool_to_int (value) int rl_variable_bind (name, value) - char *name, *value; + const char *name, *value; { register int i; int v; @@ -1367,7 +1410,7 @@ rl_variable_bind (name, value) static int sv_editmode (value) - char *value; + const char *value; { if (_rl_strnicmp (value, "vi", 2) == 0) { @@ -1388,7 +1431,7 @@ sv_editmode (value) static int sv_combegin (value) - char *value; + const char *value; { if (value && *value) { @@ -1401,7 +1444,7 @@ sv_combegin (value) static int sv_compquery (value) - char *value; + const char *value; { int nval = 100; @@ -1417,7 +1460,7 @@ sv_compquery (value) static int sv_keymap (value) - char *value; + const char *value; { Keymap kmap; @@ -1430,28 +1473,26 @@ sv_keymap (value) return 1; } -#define _SET_BELL(v) do { _rl_bell_preference = v; return 0; } while (0) - static int sv_bell_style (value) - char *value; + const char *value; { if (value == 0 || *value == '\0') - _SET_BELL (AUDIBLE_BELL); + _rl_bell_preference = AUDIBLE_BELL; else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0) - _SET_BELL (NO_BELL); + _rl_bell_preference = NO_BELL; else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0) - _SET_BELL (AUDIBLE_BELL); + _rl_bell_preference = AUDIBLE_BELL; else if (_rl_stricmp (value, "visible") == 0) - _SET_BELL (VISIBLE_BELL); + _rl_bell_preference = VISIBLE_BELL; else return 1; + return 0; } -#undef _SET_BELL static int sv_isrchterm (value) - char *value; + const char *value; { int beg, end, delim; char *v; @@ -1477,7 +1518,7 @@ sv_isrchterm (value) v[end] = '\0'; /* The value starts at v + beg. Translate it into a character string. */ - _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1); + _rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1); rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end); _rl_isearch_terminators[end] = '\0'; @@ -1489,7 +1530,7 @@ sv_isrchterm (value) For example, `Space' returns ' '. */ typedef struct { - char *name; + const char *name; int value; } assoc_list; @@ -1523,7 +1564,7 @@ glean_key_from_name (name) /* Auxiliary functions to manage keymaps. */ static struct { - char *name; + const char *name; Keymap map; } keymap_names[] = { { "emacs", emacs_standard_keymap }, @@ -1541,12 +1582,12 @@ static struct { Keymap rl_get_keymap_by_name (name) - char *name; + const char *name; { register int i; for (i = 0; keymap_names[i].name; i++) - if (strcmp (name, keymap_names[i].name) == 0) + if (_rl_stricmp (name, keymap_names[i].name) == 0) return (keymap_names[i].map); return ((Keymap) NULL); } @@ -1558,7 +1599,7 @@ rl_get_keymap_name (map) register int i; for (i = 0; keymap_names[i].name; i++) if (map == keymap_names[i].map) - return (keymap_names[i].name); + return ((char *)keymap_names[i].name); return ((char *)NULL); } @@ -1616,7 +1657,7 @@ void rl_list_funmap_names () { register int i; - char **funmap_names; + const char **funmap_names; funmap_names = rl_funmap_names (); @@ -1643,17 +1684,18 @@ _rl_get_keyname (key) pairs for possible inclusion in an inputrc file, we don't want to do any special meta processing on KEY. */ -#if 0 +#if 1 + /* XXX - Experimental */ /* We might want to do this, but the old version of the code did not. */ /* If this is an escape character, we don't want to do any more processing. Just add the special ESC key sequence and return. */ if (c == ESC) { - keyseq[0] = '\\'; - keyseq[1] = 'e'; - keyseq[2] = '\0'; - return keyseq; + keyname[0] = '\\'; + keyname[1] = 'e'; + keyname[2] = '\0'; + return keyname; } #endif @@ -1706,7 +1748,7 @@ _rl_get_keyname (key) sequences that are used to invoke FUNCTION in MAP. */ char ** rl_invoking_keyseqs_in_map (function, map) - Function *function; + rl_command_func_t *function; Keymap map; { register int key; @@ -1735,7 +1777,7 @@ rl_invoking_keyseqs_in_map (function, map) if (result_index + 2 > result_size) { result_size += 10; - result = (char **) xrealloc (result, result_size * sizeof (char *)); + result = (char **)xrealloc (result, result_size * sizeof (char *)); } result[result_index++] = keyname; @@ -1765,7 +1807,12 @@ rl_invoking_keyseqs_in_map (function, map) char *keyname = (char *)xmalloc (len); if (key == ESC) +#if 0 snprintf(keyname, len, "\\e"); +#else + /* XXX - experimental */ + snprintf(keyname, len, "\\M-"); +#endif else if (CTRL_CHAR (key)) snprintf(keyname, len, "\\C-%c", _rl_to_lower (UNCTRL (key))); else if (key == RUBOUT) @@ -1788,7 +1835,7 @@ rl_invoking_keyseqs_in_map (function, map) if (result_index + 2 > result_size) { result_size += 10; - result = (char **) xrealloc (result, result_size * sizeof (char *)); + result = (char **)xrealloc (result, result_size * sizeof (char *)); } result[result_index++] = keyname; @@ -1807,7 +1854,7 @@ rl_invoking_keyseqs_in_map (function, map) sequences that can be used to invoke FUNCTION using the current keymap. */ char ** rl_invoking_keyseqs (function) - Function *function; + rl_command_func_t *function; { return (rl_invoking_keyseqs_in_map (function, _rl_keymap)); } @@ -1820,8 +1867,8 @@ rl_function_dumper (print_readably) int print_readably; { register int i; - char **names; - char *name; + const char **names; + const char *name; names = rl_funmap_names (); @@ -1829,7 +1876,7 @@ rl_function_dumper (print_readably) for (i = 0; name = names[i]; i++) { - Function *function; + rl_command_func_t *function; char **invokers; function = rl_named_function (name); @@ -1912,11 +1959,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix) { case ISMACR: keyname = _rl_get_keyname (key); -#if 0 - out = (char *)map[key].function; -#else out = _rl_untranslate_macro_value ((char *)map[key].function); -#endif + if (print_readably) fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "", keyname, @@ -1926,9 +1970,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix) keyname, out ? out : ""); free (keyname); -#if 1 free (out); -#endif break; case ISFUNC: break; @@ -1937,7 +1979,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix) if (key == ESC) { int len = 3 + prefix_len; - keyname = xmalloc (len); + keyname = (char *)xmalloc (len); if (prefix) strlcpy (keyname, prefix, len); keyname[prefix_len] = '\\'; @@ -1986,7 +2028,7 @@ rl_variable_dumper (print_readably) int print_readably; { int i; - char *kname; + const char *kname; for (i = 0; boolean_varlist[i].name; i++) { @@ -2018,7 +2060,7 @@ rl_variable_dumper (print_readably) if (print_readably) fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT); else - fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : ""); + fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT); /* completion-query-items */ if (print_readably) @@ -2032,15 +2074,6 @@ rl_variable_dumper (print_readably) else fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi"); - /* keymap */ - kname = rl_get_keymap_name (_rl_keymap); - if (kname == 0) - kname = rl_get_keymap_name_from_edit_mode (); - if (print_readably) - fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none"); - else - fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none"); - /* isearch-terminators */ if (_rl_isearch_terminators) { @@ -2055,6 +2088,15 @@ rl_variable_dumper (print_readably) free (disp); } + + /* keymap */ + kname = rl_get_keymap_name (_rl_keymap); + if (kname == 0) + kname = rl_get_keymap_name_from_edit_mode (); + if (print_readably) + fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none"); + else + fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none"); } /* Print all of the current variables and their values to @@ -2071,18 +2113,24 @@ rl_dump_variables (count, key) return (0); } -/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. */ +/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right + now, this is always used to attempt to bind the arrow keys, hence the + check for rl_vi_movement_mode. */ void _rl_bind_if_unbound (keyseq, default_func) - char *keyseq; - Function *default_func; + const char *keyseq; + rl_command_func_t *default_func; { - Function *func; + rl_command_func_t *func; if (keyseq) { func = rl_function_of_keyseq (keyseq, _rl_keymap, (int *)NULL); +#if defined (VI_MODE) + if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode) +#else if (!func || func == rl_do_lowercase_version) +#endif rl_set_key (keyseq, default_func, _rl_keymap); } } @@ -2090,7 +2138,8 @@ _rl_bind_if_unbound (keyseq, default_func) /* Return non-zero if any members of ARRAY are a substring in STRING. */ static int substring_member_of_array (string, array) - char *string, **array; + char *string; + const char **array; { while (*array) { diff --git a/gnu/lib/libreadline/chardefs.h b/gnu/lib/libreadline/chardefs.h index edab93b5b1a..a537be220b0 100644 --- a/gnu/lib/libreadline/chardefs.h +++ b/gnu/lib/libreadline/chardefs.h @@ -27,10 +27,14 @@ #if defined (HAVE_CONFIG_H) # if defined (HAVE_STRING_H) +# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) +# include <memory.h> +# endif # include <string.h> -# else -# include <strings.h> # endif /* HAVE_STRING_H */ +# if defined (HAVE_STRINGS_H) +# include <strings.h> +# endif /* HAVE_STRINGS_H */ #else # include <string.h> #endif /* !HAVE_CONFIG_H */ @@ -40,7 +44,10 @@ #endif #ifdef CTRL -#undef CTRL +# undef CTRL +#endif +#ifdef UNCTRL +# undef UNCTRL #endif /* Some character stuff. */ @@ -51,7 +58,7 @@ #define meta_character_bit 0x080 /* x0000000, must be on. */ #define largest_char 255 /* Largest character value. */ -#define CTRL_CHAR(c) ((c) < control_character_threshold && ((signed char)c) >= 0) +#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0)) #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) #define CTRL(c) ((c) & control_character_mask) @@ -60,33 +67,59 @@ #define UNMETA(c) ((c) & (~meta_character_bit)) #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) -/* Old versions -#define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) -#define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) -#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') -*/ +#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) +# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#endif + +#define NON_NEGATIVE(c) ((unsigned char)(c) == (c)) + +/* Some systems define these; we want our definitions. */ +#undef ISPRINT -#define _rl_lowercase_p(c) (islower(c)) -#define _rl_uppercase_p(c) (isupper(c)) -#define _rl_digit_p(x) (isdigit (x)) +#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c)) +#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c)) +#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c)) +#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c)) +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) +#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c)) +#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c)) -#define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c)) -#define ALPHABETIC(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c)) +#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c)) +#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c)) +#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') -/* Old versions -# define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c)) -# define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c)) -*/ +#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c)) +#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c)) #ifndef _rl_to_upper -# define _rl_to_upper(c) (islower(c) ? toupper(c) : (c)) -# define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c)) +# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c)) +# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c)) #endif #ifndef _rl_digit_value -#define _rl_digit_value(x) ((x) - '0') +# define _rl_digit_value(x) ((x) - '0') +#endif + +#ifndef _rl_isident +# define _rl_isident(c) (ISALNUM(c) || (c) == '_') #endif +#ifndef ISOCTAL +# define ISOCTAL(c) ((c) >= '0' && (c) <= '7') +#endif +#define OCTVALUE(c) ((c) - '0') + +#define HEXVALUE(c) \ + (((c) >= 'a' && (c) <= 'f') \ + ? (c)-'a'+10 \ + : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') + #ifndef NEWLINE #define NEWLINE '\n' #endif @@ -123,18 +156,4 @@ #endif #define ESC CTRL('[') -#ifndef ISOCTAL -#define ISOCTAL(c) ((c) >= '0' && (c) <= '7') -#endif -#define OCTVALUE(c) ((c) - '0') - -#ifndef isxdigit -# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) -#endif - -#define HEXVALUE(c) \ - (((c) >= 'a' && (c) <= 'f') \ - ? (c)-'a'+10 \ - : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') - #endif /* _CHARDEFS_H_ */ diff --git a/gnu/lib/libreadline/complete.c b/gnu/lib/libreadline/complete.c index ea0f8612211..724745d8d65 100644 --- a/gnu/lib/libreadline/complete.c +++ b/gnu/lib/libreadline/complete.c @@ -49,24 +49,13 @@ extern int errno; #endif /* !errno */ #include <pwd.h> -#if !defined (HAVE_GETPW_DECLS) -extern struct passwd *getpwent (); -#endif /* USG && !HAVE_GETPW_DECLS */ - -/* ISC systems don't define getpwent() if _POSIX_SOURCE is defined. */ -#if defined (isc386) && defined (_POSIX_SOURCE) -# if defined (__STDC__) -extern struct passwd *getpwent (void); -# else -extern struct passwd *getpwent (); -# endif /* !__STDC__ */ -#endif /* isc386 && _POSIX_SOURCE */ #include "posixdir.h" #include "posixstat.h" /* System-specific feature definitions and include files. */ #include "rldefs.h" +#include "rlmbutil.h" /* Some standard library routines. */ #include "readline.h" @@ -79,6 +68,21 @@ typedef int QSFUNC (const void *, const void *); typedef int QSFUNC (); #endif +#ifdef HAVE_LSTAT +# define LSTAT lstat +#else +# define LSTAT stat +#endif + +/* Unix version of a hidden file. Could be different on other systems. */ +#define HIDDEN_FILE(fname) ((fname)[0] == '.') + +/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is + defined. */ +#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE) +extern struct passwd *getpwent PARAMS((void)); +#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */ + /* If non-zero, then this is the address of a function to call when completing a word would normally display the list of possible matches. This function is called instead of actually doing the display. @@ -86,28 +90,34 @@ typedef int QSFUNC (); where MATCHES is the array of strings that matched, NUM_MATCHES is the number of strings in that array, and MAX_LENGTH is the length of the longest string in that array. */ -VFunction *rl_completion_display_matches_hook = (VFunction *)NULL; - -/* Forward declarations for functions defined and used in this file. */ -char *filename_completion_function __P((char *, int)); -char **completion_matches __P((char *, CPFunction *)); +rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)NULL; #if defined (VISIBLE_STATS) # if !defined (X_OK) # define X_OK 1 # endif -static int stat_char __P((char *)); +static int stat_char PARAMS((char *)); #endif -static char *rl_quote_filename __P((char *, int, char *)); -static char *rl_strpbrk __P((char *, char *)); +static char *rl_quote_filename PARAMS((char *, int, char *)); + +static void set_completion_defaults PARAMS((int)); +static int get_y_or_n PARAMS((int)); +static int _rl_internal_pager PARAMS((int)); +static char *printable_part PARAMS((char *)); +static int print_filename PARAMS((char *, char *)); -static char **remove_duplicate_matches __P((char **)); -static void insert_match __P((char *, int, int, char *)); -static int append_to_match __P((char *, int, int)); -static void insert_all_matches __P((char **, int, char *)); -static void display_matches __P((char **)); -static int compute_lcd_of_matches __P((char **, int, char *)); +static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int)); + +static char **remove_duplicate_matches PARAMS((char **)); +static void insert_match PARAMS((char *, int, int, char *)); +static int append_to_match PARAMS((char *, int, int, int)); +static void insert_all_matches PARAMS((char **, int, char *)); +static void display_matches PARAMS((char **)); +static int compute_lcd_of_matches PARAMS((char **, int, const char *)); +static int postprocess_matches PARAMS((char ***, int)); + +static char *make_quoted_replacement PARAMS((char *, int, char *)); /* **************************************************************** */ /* */ @@ -123,6 +133,12 @@ int _rl_complete_show_all = 0; /* If non-zero, completed directory names have a slash appended. */ int _rl_complete_mark_directories = 1; +/* If non-zero, the symlinked directory completion behavior introduced in + readline-4.2a is disabled, and symlinks that point to directories have + a slash appended (subject to the value of _rl_complete_mark_directories). + This is user-settable via the mark-symlinked-directories variable. */ +int _rl_complete_mark_symlink_dirs = 0; + /* If non-zero, completions are printed horizontally in alphabetical order, like `ls -x'. */ int _rl_print_completions_horizontally; @@ -134,6 +150,10 @@ int _rl_completion_case_fold = 1; int _rl_completion_case_fold; #endif +/* If non-zero, don't match hidden files (filenames beginning with a `.' on + Unix) when doing filename completion. */ +int _rl_match_hidden_files = 1; + /* Global variables available to applications using readline. */ #if defined (VISIBLE_STATS) @@ -146,15 +166,17 @@ int rl_visible_stats = 0; /* If non-zero, then this is the address of a function to call when completing on a directory name. The function is called with the address of a string (the current directory name) as an arg. */ -Function *rl_directory_completion_hook = (Function *)NULL; +rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL; + +rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL; /* Non-zero means readline completion functions perform tilde expansion. */ int rl_complete_with_tilde_expansion = 0; /* Pointer to the generator function for completion_matches (). - NULL means to use filename_completion_function (), the default filename + NULL means to use rl_filename_completion_function (), the default filename completer. */ -Function *rl_completion_entry_function = (Function *)NULL; +rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL; /* Pointer to alternative function to create matches. Function is called with TEXT, START, and END. @@ -163,7 +185,7 @@ Function *rl_completion_entry_function = (Function *)NULL; If this function exists and returns NULL then call the value of rl_completion_entry_function to try to match, otherwise use the array of strings returned. */ -CPPFunction *rl_attempted_completion_function = (CPPFunction *)NULL; +rl_completion_func_t *rl_attempted_completion_function = (rl_completion_func_t *)NULL; /* Non-zero means to suppress normal filename completion after the user-specified completion function has been called. */ @@ -179,32 +201,34 @@ int rl_completion_type = 0; she is sure she wants to see them all. */ int rl_completion_query_items = 100; +int _rl_page_completions = 1; + /* The basic list of characters that signal a break between words for the completer routine. The contents of this variable is what breaks words in the shell, i.e. " \t\n\"\\'`@$><=" */ -char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{("; +const char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{("; /* }) */ /* List of basic quoting characters. */ -char *rl_basic_quote_characters = "\"'"; +const char *rl_basic_quote_characters = "\"'"; /* The list of characters that signal a break between words for rl_complete_internal. The default list is the contents of rl_basic_word_break_characters. */ -char *rl_completer_word_break_characters = (char *)NULL; +const char *rl_completer_word_break_characters = (const char *)NULL; /* List of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring rl_completer_word_break_characters are treated as any other character, unless they also appear within this list. */ -char *rl_completer_quote_characters = (char *)NULL; +const char *rl_completer_quote_characters = (const char *)NULL; /* List of characters that should be quoted in filenames by the completer. */ -char *rl_filename_quote_characters = (char *)NULL; +const char *rl_filename_quote_characters = (const char *)NULL; /* List of characters that are word break characters, but should be left in TEXT when it is passed to the completion function. The shell uses this to help determine what kind of completing to do. */ -char *rl_special_prefixes = (char *)NULL; +const char *rl_special_prefixes = (const char *)NULL; /* If non-zero, then disallow duplicates in the matches. */ int rl_ignore_completion_duplicates = 1; @@ -230,29 +254,45 @@ int rl_filename_quoting_desired = 1; the list of matches as required, but all elements of the array must be free()'d if they are deleted. The main intent of this function is to implement FIGNORE a la SunOS csh. */ -Function *rl_ignore_some_completions_function = (Function *)NULL; +rl_compignore_func_t *rl_ignore_some_completions_function = (rl_compignore_func_t *)NULL; /* Set to a function to quote a filename in an application-specific fashion. Called with the text to quote, the type of match found (single or multiple) and a pointer to the quoting character to be used, which the function can reset if desired. */ -CPFunction *rl_filename_quoting_function = rl_quote_filename; +rl_quote_func_t *rl_filename_quoting_function = rl_quote_filename; /* Function to call to remove quoting characters from a filename. Called before completion is attempted, so the embedded quotes do not interfere with matching names in the file system. Readline doesn't do anything with this; it's set only by applications. */ -CPFunction *rl_filename_dequoting_function = (CPFunction *)NULL; +rl_dequote_func_t *rl_filename_dequoting_function = (rl_dequote_func_t *)NULL; /* Function to call to decide whether or not a word break character is quoted. If a character is quoted, it does not break words for the completer. */ -Function *rl_char_is_quoted_p = (Function *)NULL; +rl_linebuf_func_t *rl_char_is_quoted_p = (rl_linebuf_func_t *)NULL; + +/* If non-zero, the completion functions don't append anything except a + possible closing quote. This is set to 0 by rl_complete_internal and + may be changed by an application-specific completion function. */ +int rl_completion_suppress_append = 0; /* Character appended to completed words when at the end of the line. The default is a space. */ int rl_completion_append_character = ' '; +/* If non-zero, a slash will be appended to completed filenames that are + symbolic links to directory names, subject to the value of the + mark-directories variable (which is user-settable). This exists so + that application completion functions can override the user's preference + (set via the mark-symlinked-directories variable) if appropriate. + It's set to the value of _rl_complete_mark_symlink_dirs in + rl_complete_internal before any application-specific completion + function is called, so without that function doing anything, the user's + preferences are honored. */ +int rl_completion_mark_symlink_dirs; + /* If non-zero, inhibit completion (temporarily). */ int rl_inhibit_completion; @@ -269,13 +309,13 @@ static int completion_changed_buffer; /* Complete the word at or before point. You have supplied the function that does the initial simple matching selection algorithm (see - completion_matches ()). The default is to do filename completion. */ + rl_completion_matches ()). The default is to do filename completion. */ int rl_complete (ignore, invoking_key) int ignore, invoking_key; { if (rl_inhibit_completion) - return (rl_insert (ignore, invoking_key)); + return (_rl_insert_char (ignore, invoking_key)); else if (rl_last_func == rl_complete && !completion_changed_buffer) return (rl_complete_internal ('?')); else if (_rl_complete_show_all) @@ -299,52 +339,90 @@ rl_insert_completions (ignore, invoking_key) return (rl_complete_internal ('*')); } +/* Return the correct value to pass to rl_complete_internal performing + the same tests as rl_complete. This allows consecutive calls to an + application's completion function to list possible completions and for + an application-specific completion function to honor the + show-all-if-ambiguous readline variable. */ +int +rl_completion_mode (cfunc) + rl_command_func_t *cfunc; +{ + if (rl_last_func == cfunc && !completion_changed_buffer) + return '?'; + else if (_rl_complete_show_all) + return '!'; + else + return TAB; +} + /************************************/ /* */ /* Completion utility functions */ /* */ /************************************/ -/* Find the first occurrence in STRING1 of any character from STRING2. - Return a pointer to the character in STRING1. */ -static char * -rl_strpbrk (string1, string2) - char *string1, *string2; +/* Set default values for readline word completion. These are the variables + that application completion functions can change or inspect. */ +static void +set_completion_defaults (what_to_do) + int what_to_do; { - register char *scan; + /* Only the completion entry function can change these. */ + rl_filename_completion_desired = 0; + rl_filename_quoting_desired = 1; + rl_completion_type = what_to_do; + rl_completion_suppress_append = 0; - for (; *string1; string1++) - { - for (scan = string2; *scan; scan++) - { - if (*string1 == *scan) - { - return (string1); - } - } - } - return ((char *)NULL); + /* The completion entry function may optionally change this. */ + rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs; } /* The user must press "y" or "n". Non-zero return means "y" pressed. */ static int -get_y_or_n () +get_y_or_n (for_pager) + int for_pager; { int c; for (;;) { + RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (c == 'y' || c == 'Y' || c == ' ') return (1); if (c == 'n' || c == 'N' || c == RUBOUT) return (0); if (c == ABORT_CHAR) _rl_abort_internal (); - ding (); + if (for_pager && (c == NEWLINE || c == RETURN)) + return (2); + if (for_pager && (c == 'q' || c == 'Q')) + return (0); + rl_ding (); } } +static int +_rl_internal_pager (lines) + int lines; +{ + int i; + + fprintf (rl_outstream, "--More--"); + fflush (rl_outstream); + i = get_y_or_n (1); + _rl_erase_entire_line (); + if (i == 0) + return -1; + else if (i == 2) + return (lines - 1); + else + return 0; +} + #if defined (VISIBLE_STATS) /* Return the character which best describes FILENAME. `@' for symbolic links @@ -405,19 +483,41 @@ stat_char (filename) /* Return the portion of PATHNAME that should be output when listing possible completions. If we are hacking filename completion, we are only interested in the basename, the portion following the - final slash. Otherwise, we return what we were passed. */ + final slash. Otherwise, we return what we were passed. Since + printing empty strings is not very informative, if we're doing + filename completion, and the basename is the empty string, we look + for the previous slash and return the portion following that. If + there's no previous slash, we just return what we were passed. */ static char * printable_part (pathname) char *pathname; { - char *temp; + char *temp, *x; - temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL; + if (rl_filename_completion_desired == 0) /* don't need to do anything */ + return (pathname); + + temp = strrchr (pathname, '/'); #if defined (__MSDOS__) - if (rl_filename_completion_desired && temp == 0 && isalpha (pathname[0]) && pathname[1] == ':') + if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':') temp = pathname + 1; #endif - return (temp ? ++temp : pathname); + + if (temp == 0 || *temp == '\0') + return (pathname); + /* If the basename is NULL, we might have a pathname like '/usr/src/'. + Look for a previous slash and, if one is found, return the portion + following that slash. If there's no previous slash, just return the + pathname we were passed. */ + else if (temp[1] == '\0') + { + for (x = temp - 1; x > pathname; x--) + if (*x == '/') + break; + return ((*x == '/') ? x + 1 : pathname); + } + else + return ++temp; } /* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and we @@ -517,7 +617,7 @@ rl_quote_filename (s, rtype, qcp) char *r; int len = strlen(s) + 2; - r = xmalloc (len); + r = (char *)xmalloc (len); *r = *rl_completer_quote_characters; strlcpy (r + 1, s, len - 1); if (qcp) @@ -528,7 +628,7 @@ rl_quote_filename (s, rtype, qcp) /* Find the bounds of the current word for completion purposes, and leave rl_point set to the end of the word. This function skips quoted substrings (characters between matched pairs of characters in - rl_completer_quote_characters. First we try to find an unclosed + rl_completer_quote_characters). First we try to find an unclosed quoted substring on which to do matching. If one is not found, we use the word break characters to find the boundaries of the current word. We call an application-specific function to decide whether or not a @@ -540,8 +640,8 @@ rl_quote_filename (s, rtype, qcp) quote, or backslash) anywhere in the string. DP, if non-null, is set to the value of the delimiter character that caused a word break. */ -static char -find_completion_word (fp, dp) +char +_rl_find_completion_word (fp, dp) int *fp, *dp; { int scan, end, found_quote, delimiter, pass_next, isbrk; @@ -565,7 +665,11 @@ find_completion_word (fp, dp) continue; } - if (rl_line_buffer[scan] == '\\') + /* Shell-like semantics for single quotes -- don't allow backslash + to quote anything in single quotes, especially not the closing + quote. If you don't like this, take out the check on the value + of quote_char. */ + if (quote_char != '\'' && rl_line_buffer[scan] == '\\') { pass_next = 1; found_quote |= RL_QF_BACKSLASH; @@ -592,6 +696,8 @@ find_completion_word (fp, dp) found_quote |= RL_QF_SINGLE_QUOTE; else if (quote_char == '"') found_quote |= RL_QF_DOUBLE_QUOTE; + else + found_quote |= RL_QF_OTHER_QUOTE; } } } @@ -601,7 +707,11 @@ find_completion_word (fp, dp) /* We didn't find an unclosed quoted substring upon which to do completion, so use the word break characters to find the substring on which to complete. */ +#if defined (HANDLE_MULTIBYTE) + while (rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY)) +#else while (--rl_point) +#endif { scan = rl_line_buffer[rl_point]; @@ -665,7 +775,7 @@ static char ** gen_completion_matches (text, start, end, our_func, found_quote, quote_char) char *text; int start, end; - Function *our_func; + rl_compentry_func_t *our_func; int found_quote, quote_char; { char **matches, *temp; @@ -689,7 +799,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) filename dequoting function. */ temp = (char *)NULL; - if (found_quote && our_func == (Function *)filename_completion_function && + if (found_quote && our_func == rl_filename_completion_function && rl_filename_dequoting_function) { /* delete single and double quotes */ @@ -697,7 +807,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) text = temp; /* not freeing text is not a memory leak */ } - matches = completion_matches (text, (CPFunction *)our_func); + matches = rl_completion_matches (text, our_func); FREE (temp); return matches; } @@ -769,10 +879,15 @@ static int compute_lcd_of_matches (match_list, matches, text) char **match_list; int matches; - char *text; + const char *text; { register int i, c1, c2, si; int low; /* Count of max-matched characters. */ +#if defined (HANDLE_MULTIBYTE) + int v; + mbstate_t ps1, ps2; + wchar_t wc1, wc2; +#endif /* If only one match, just use that. Otherwise, compare each member of the list with the next, finding out where they @@ -786,12 +901,33 @@ compute_lcd_of_matches (match_list, matches, text) for (i = 1, low = 100000; i < matches; i++) { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + memset (&ps1, 0, sizeof (mbstate_t)); + memset (&ps2, 0, sizeof (mbstate_t)); + } +#endif if (_rl_completion_case_fold) { for (si = 0; (c1 = _rl_to_lower(match_list[i][si])) && (c2 = _rl_to_lower(match_list[i + 1][si])); si++) +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + v = mbrtowc (&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1); + mbrtowc (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2); + wc1 = towlower (wc1); + wc2 = towlower (wc2); + if (wc1 != wc2) + break; + else if (v > 1) + si += v - 1; + } + else +#endif if (c1 != c2) break; } @@ -801,6 +937,17 @@ compute_lcd_of_matches (match_list, matches, text) (c1 = match_list[i][si]) && (c2 = match_list[i + 1][si]); si++) +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + mbstate_t ps_back = ps1; + if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2)) + break; + else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1) + si += v - 1; + } + else +#endif if (c1 != c2) break; } @@ -820,8 +967,37 @@ compute_lcd_of_matches (match_list, matches, text) } else { - match_list[0] = xmalloc (low + 1); - strncpy (match_list[0], match_list[1], low); + match_list[0] = (char *)xmalloc (low + 1); + + /* XXX - this might need changes in the presence of multibyte chars */ + + /* If we are ignoring case, try to preserve the case of the string + the user typed in the face of multiple matches differing in case. */ + if (_rl_completion_case_fold) + { + /* sort the list to get consistent answers. */ + qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare); + + si = strlen (text); + if (si <= low) + { + for (i = 1; i <= matches; i++) + if (strncmp (match_list[i], text, si) == 0) + { + strncpy (match_list[0], match_list[i], low); + break; + } + /* no casematch, use first entry */ + if (i > matches) + strncpy (match_list[0], match_list[1], low); + } + else + /* otherwise, just use the text the user typed. */ + strncpy (match_list[0], text, low); + } + else + strncpy (match_list[0], match_list[1], low); + match_list[0][low] = '\0'; } @@ -838,6 +1014,9 @@ postprocess_matches (matchesp, matching_filenames) matches = *matchesp; + if (matches == 0) + return 0; + /* It seems to me that in all the cases we handle we would like to ignore duplicate possiblilities. Scan for the text to insert being identical to the other completions. */ @@ -890,17 +1069,17 @@ rl_display_match_list (matches, len, max) char **matches; int len, max; { - int count, limit, printed_len; + int count, limit, printed_len, lines; int i, j, k, l; char *temp; /* How many items of MAX length can we fit in the screen window? */ max += 2; - limit = screenwidth / max; - if (limit != 1 && (limit * max == screenwidth)) + limit = _rl_screenwidth / max; + if (limit != 1 && (limit * max == _rl_screenwidth)) limit--; - /* Avoid a possible floating exception. If max > screenwidth, + /* Avoid a possible floating exception. If max > _rl_screenwidth, limit will be 0 and a divide-by-zero fault will result. */ if (limit == 0) limit = 1; @@ -916,8 +1095,9 @@ rl_display_match_list (matches, len, max) if (rl_ignore_completion_duplicates == 0) qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare); - crlf (); + rl_crlf (); + lines = 0; if (_rl_print_completions_horizontally == 0) { /* Print the sorted items, up-and-down alphabetically, like ls. */ @@ -938,7 +1118,14 @@ rl_display_match_list (matches, len, max) } l += count; } - crlf (); + rl_crlf (); + lines++; + if (_rl_page_completions && lines >= (_rl_screenheight - 1) && i < count) + { + lines = _rl_internal_pager (lines); + if (lines < 0) + return; + } } } else @@ -952,13 +1139,22 @@ rl_display_match_list (matches, len, max) if (matches[i+1]) { if (i && (limit > 1) && (i % limit) == 0) - crlf (); + { + rl_crlf (); + lines++; + if (_rl_page_completions && lines >= _rl_screenheight - 1) + { + lines = _rl_internal_pager (lines); + if (lines < 0) + return; + } + } else for (k = 0; k < max - printed_len; k++) putc (' ', rl_outstream); } } - crlf (); + rl_crlf (); } } @@ -987,9 +1183,9 @@ display_matches (matches) if (matches[1] == 0) { temp = printable_part (matches[0]); - crlf (); + rl_crlf (); print_filename (temp, matches[0]); - crlf (); + rl_crlf (); rl_forced_update_display (); rl_display_fixed = 1; @@ -1021,12 +1217,12 @@ display_matches (matches) see them all. */ if (len >= rl_completion_query_items) { - crlf (); + rl_crlf (); fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len); fflush (rl_outstream); - if (get_y_or_n () == 0) + if (get_y_or_n (0) == 0) { - crlf (); + rl_crlf (); rl_forced_update_display (); rl_display_fixed = 1; @@ -1074,7 +1270,7 @@ make_quoted_replacement (match, mtype, qc) This also checks whether the common prefix of several matches needs to be quoted. */ should_quote = rl_filename_quote_characters - ? (rl_strpbrk (match, rl_filename_quote_characters) != 0) + ? (_rl_strpbrk (match, rl_filename_quote_characters) != 0) : 0; do_replace = should_quote ? mtype : NO_MATCH; @@ -1120,14 +1316,20 @@ insert_match (match, start, mtype, qc) just-inserted match. If the user has specified that directories should be marked by a trailing `/', append one of those instead. The default trailing character is a space. Returns the number of characters - appended. */ + appended. If NONTRIVIAL_MATCH is set, we test for a symlink (if the OS + has them) and don't add a suffix for a symlink to a directory. A + nontrivial match is one that actually adds to the word being completed. + The variable rl_completion_mark_symlink_dirs controls this behavior + (it's initially set to the what the user has chosen, indicated by the + value of _rl_complete_mark_symlink_dirs, but may be modified by an + application's completion function). */ static int -append_to_match (text, delimiter, quote_char) +append_to_match (text, delimiter, quote_char, nontrivial_match) char *text; - int delimiter, quote_char; + int delimiter, quote_char, nontrivial_match; { char temp_string[4], *filename; - int temp_string_index; + int temp_string_index, s; struct stat finfo; temp_string_index = 0; @@ -1136,7 +1338,7 @@ append_to_match (text, delimiter, quote_char) if (delimiter) temp_string[temp_string_index++] = delimiter; - else if (rl_completion_append_character) + else if (rl_completion_suppress_append == 0 && rl_completion_append_character) temp_string[temp_string_index++] = rl_completion_append_character; temp_string[temp_string_index++] = '\0'; @@ -1144,21 +1346,39 @@ append_to_match (text, delimiter, quote_char) if (rl_filename_completion_desired) { filename = tilde_expand (text); - if (stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode)) + s = (nontrivial_match && rl_completion_mark_symlink_dirs == 0) + ? LSTAT (filename, &finfo) + : stat (filename, &finfo); + if (s == 0 && S_ISDIR (finfo.st_mode)) { - if (_rl_complete_mark_directories && rl_line_buffer[rl_point] != '/') - rl_insert_text ("/"); + if (_rl_complete_mark_directories) + { + /* This is clumsy. Avoid putting in a double slash if point + is at the end of the line and the previous character is a + slash. */ + if (rl_point && rl_line_buffer[rl_point] == '\0' && rl_line_buffer[rl_point - 1] == '/') + ; + else if (rl_line_buffer[rl_point] != '/') + rl_insert_text ("/"); + } } +#ifdef S_ISLNK + /* Don't add anything if the filename is a symlink and resolves to a + directory. */ + else if (s == 0 && S_ISLNK (finfo.st_mode) && + stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode)) + ; +#endif else { - if (rl_point == rl_end) + if (rl_point == rl_end && temp_string_index) rl_insert_text (temp_string); } free (filename); } else { - if (rl_point == rl_end) + if (rl_point == rl_end && temp_string_index) rl_insert_text (temp_string); } @@ -1204,12 +1424,15 @@ insert_all_matches (matches, point, qc) rl_end_undo_group (); } -static void -free_match_list (matches) +void +_rl_free_match_list (matches) char **matches; { register int i; + if (matches == 0) + return; + for (i = 0; matches[i]; i++) free (matches[i]); free (matches); @@ -1227,20 +1450,19 @@ rl_complete_internal (what_to_do) int what_to_do; { char **matches; - Function *our_func; - int start, end, delimiter, found_quote, i; + rl_compentry_func_t *our_func; + int start, end, delimiter, found_quote, i, nontrivial_lcd; char *text, *saved_line_buffer; char quote_char; - /* Only the completion entry function can change these. */ - rl_filename_completion_desired = 0; - rl_filename_quoting_desired = 1; - rl_completion_type = what_to_do; + RL_SETSTATE(RL_STATE_COMPLETING); + + set_completion_defaults (what_to_do); saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; our_func = rl_completion_entry_function ? rl_completion_entry_function - : (Function *)filename_completion_function; + : rl_filename_completion_function; /* We now look backwards for the start of a filename/variable word. */ end = rl_point; @@ -1250,38 +1472,38 @@ rl_complete_internal (what_to_do) if (rl_point) /* This (possibly) changes rl_point. If it returns a non-zero char, we know we have an open quote. */ - quote_char = find_completion_word (&found_quote, &delimiter); + quote_char = _rl_find_completion_word (&found_quote, &delimiter); start = rl_point; rl_point = end; text = rl_copy_text (start, end); matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char); + /* nontrivial_lcd is set if the common prefix adds something to the word + being completed. */ + nontrivial_lcd = matches && strcmp (text, matches[0]) != 0; free (text); if (matches == 0) { - ding (); + rl_ding (); FREE (saved_line_buffer); + completion_changed_buffer = 0; + RL_UNSETSTATE(RL_STATE_COMPLETING); return (0); } -#if 0 - /* If we are matching filenames, our_func will have been set to - filename_completion_function */ - i = our_func == (Function *)filename_completion_function; -#else /* If we are matching filenames, the attempted completion function will have set rl_filename_completion_desired to a non-zero value. The basic - filename_completion_function does this. */ + rl_filename_completion_function does this. */ i = rl_filename_completion_desired; -#endif if (postprocess_matches (&matches, i) == 0) { - ding (); + rl_ding (); FREE (saved_line_buffer); completion_changed_buffer = 0; + RL_UNSETSTATE(RL_STATE_COMPLETING); return (0); } @@ -1309,10 +1531,10 @@ rl_complete_internal (what_to_do) break; } else if (rl_editing_mode != vi_mode) - ding (); /* There are other matches remaining. */ + rl_ding (); /* There are other matches remaining. */ } else - append_to_match (matches[0], delimiter, quote_char); + append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd); break; @@ -1326,12 +1548,13 @@ rl_complete_internal (what_to_do) default: fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do); - ding (); + rl_ding (); FREE (saved_line_buffer); + RL_UNSETSTATE(RL_STATE_COMPLETING); return 1; } - free_match_list (matches); + _rl_free_match_list (matches); /* Check to see if the line has changed through all of this manipulation. */ if (saved_line_buffer) @@ -1340,6 +1563,7 @@ rl_complete_internal (what_to_do) free (saved_line_buffer); } + RL_UNSETSTATE(RL_STATE_COMPLETING); return 0; } @@ -1362,9 +1586,9 @@ rl_complete_internal (what_to_do) when there are no more matches. */ char ** -completion_matches (text, entry_function) - char *text; - CPFunction *entry_function; +rl_completion_matches (text, entry_function) + const char *text; + rl_compentry_func_t *entry_function; { /* Number of slots in match_list. */ int match_list_size; @@ -1409,8 +1633,8 @@ completion_matches (text, entry_function) TEXT contains a partial username preceded by a random character (usually `~'). */ char * -username_completion_function (text, state) - char *text; +rl_username_completion_function (text, state) + const char *text; int state; { #if defined (__WIN32__) || defined (__OPENNT) @@ -1448,7 +1672,7 @@ username_completion_function (text, state) else { int len = 2 + strlen(entry->pw_name); - value = xmalloc (len); + value = (char *)xmalloc (len); *value = *text; @@ -1467,8 +1691,8 @@ username_completion_function (text, state) because of all the pathnames that must be followed when looking up the completion for a command. */ char * -filename_completion_function (text, state) - char *text; +rl_filename_completion_function (text, state) + const char *text; int state; { static DIR *directory = (DIR *)NULL; @@ -1504,7 +1728,7 @@ filename_completion_function (text, state) #if defined (__MSDOS__) /* special hack for //X/... */ - if (dirname[0] == '/' && dirname[1] == '/' && isalpha (dirname[2]) && dirname[3] == '/') + if (dirname[0] == '/' && dirname[1] == '/' && ISALPHA ((unsigned char)dirname[2]) && dirname[3] == '/') temp = strrchr (dirname + 3, '/'); #endif @@ -1515,7 +1739,7 @@ filename_completion_function (text, state) } #if defined (__MSDOS__) /* searches from current directory on the drive */ - else if (isalpha (dirname[0]) && dirname[1] == ':') + else if (ISALPHA ((unsigned char)dirname[0]) && dirname[1] == ':') { /* XXX DOS strlcpy anyone? */ strlcpy (filename, dirname + 2, filename_len); @@ -1540,6 +1764,9 @@ filename_completion_function (text, state) dirname = temp; } + if (rl_directory_rewrite_hook) + (*rl_directory_rewrite_hook) (&dirname); + if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname)) { free (users_dirname); @@ -1563,10 +1790,14 @@ filename_completion_function (text, state) entry = (struct dirent *)NULL; while (directory && (entry = readdir (directory))) { - /* Special case for no filename. - All entries except "." and ".." match. */ + /* Special case for no filename. If the user has disabled the + `match-hidden-files' variable, skip filenames beginning with `.'. + All other entries except "." and ".." match. */ if (filename_len == 0) { + if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name)) + continue; + if (entry->d_name[0] != '.' || (entry->d_name[1] && (entry->d_name[1] != '.' || entry->d_name[2]))) @@ -1628,7 +1859,7 @@ filename_completion_function (text, state) { dirlen = strlen (dirname); templen = 2 + dirlen + D_NAMLEN (entry); - temp = xmalloc (templen); + temp = (char *)xmalloc (templen); strlcpy (temp, dirname, templen); /* Canonicalization cuts off any final slash present. We may need to add it back. */ @@ -1641,9 +1872,15 @@ filename_completion_function (text, state) else { dirlen = strlen (users_dirname); - templen = 1 + dirlen + D_NAMLEN (entry); - temp = xmalloc (templen); + templen = 2 + dirlen + D_NAMLEN (entry); + temp = (char *)xmalloc (templen); strlcpy (temp, users_dirname, templen); + /* Make sure that temp has a trailing slash here. */ + if (users_dirname[dirlen - 1] != '/') + { + temp[dirlen++] = '/'; + temp[dirlen] = '\0'; + } } strlcat (temp, entry->d_name, templen); @@ -1668,7 +1905,7 @@ int rl_menu_complete (count, ignore) int count, ignore; { - Function *our_func; + rl_compentry_func_t *our_func; int matching_filenames, found_quote; static char *orig_text; @@ -1686,19 +1923,17 @@ rl_menu_complete (count, ignore) /* Clean up from previous call, if any. */ FREE (orig_text); if (matches) - free_match_list (matches); + _rl_free_match_list (matches); match_list_index = match_list_size = 0; matches = (char **)NULL; /* Only the completion entry function can change these. */ - rl_filename_completion_desired = 0; - rl_filename_quoting_desired = 1; - rl_completion_type = '%'; + set_completion_defaults ('%'); our_func = rl_completion_entry_function ? rl_completion_entry_function - : (Function *)filename_completion_function; + : rl_filename_completion_function; /* We now look backwards for the start of a filename/variable word. */ orig_end = rl_point; @@ -1708,7 +1943,7 @@ rl_menu_complete (count, ignore) if (rl_point) /* This (possibly) changes rl_point. If it returns a non-zero char, we know we have an open quote. */ - quote_char = find_completion_word (&found_quote, &delimiter); + quote_char = _rl_find_completion_word (&found_quote, &delimiter); orig_start = rl_point; rl_point = orig_end; @@ -1717,19 +1952,14 @@ rl_menu_complete (count, ignore) matches = gen_completion_matches (orig_text, orig_start, orig_end, our_func, found_quote, quote_char); -#if 0 - /* If we are matching filenames, our_func will have been set to - filename_completion_function */ - matching_filenames = our_func == (Function *)filename_completion_function; -#else /* If we are matching filenames, the attempted completion function will have set rl_filename_completion_desired to a non-zero value. The basic - filename_completion_function does this. */ + rl_filename_completion_function does this. */ matching_filenames = rl_filename_completion_desired; -#endif + if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0) { - ding (); + rl_ding (); FREE (matches); matches = (char **)0; FREE (orig_text); @@ -1750,7 +1980,7 @@ rl_menu_complete (count, ignore) if (matches == 0 || match_list_size == 0) { - ding (); + rl_ding (); FREE (matches); matches = (char **)0; completion_changed_buffer = 0; @@ -1763,13 +1993,14 @@ rl_menu_complete (count, ignore) if (match_list_index == 0 && match_list_size > 1) { - ding (); + rl_ding (); insert_match (orig_text, orig_start, MULT_MATCH, "e_char); } else { insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char); - append_to_match (matches[match_list_index], delimiter, quote_char); + append_to_match (matches[match_list_index], delimiter, quote_char, + strcmp (orig_text, matches[match_list_index])); } completion_changed_buffer = 1; diff --git a/gnu/lib/libreadline/config.h b/gnu/lib/libreadline/config.h index 4cce5702f5b..392187fc18f 100644 --- a/gnu/lib/libreadline/config.h +++ b/gnu/lib/libreadline/config.h @@ -1,5 +1,5 @@ /* config.h. Generated automatically by configure. */ -/* config.h.in. Generated automatically from configure.in by autoheader. */ +/* config.h.in. Maintained by hand. */ /* Define if on MINIX. */ /* #undef _MINIX */ @@ -7,14 +7,34 @@ /* Define as the return type of signal handlers (int or void). */ #define RETSIGTYPE void +/* Characteristics of the compiler. */ +/* #undef const */ + +/* #undef size_t */ + +/* #undef ssize_t */ + +#define PROTOTYPES 1 + +/* #undef __CHAR_UNSIGNED__ */ + /* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ /* #undef STAT_MACROS_BROKEN */ #define VOID_SIGHANDLER 1 +/* Define if you have the isascii function. */ +#define HAVE_ISASCII 1 + +/* Define if you have the isxdigit function. */ +#define HAVE_ISXDIGIT 1 + /* Define if you have the lstat function. */ #define HAVE_LSTAT 1 +/* Define if you have the mbsrtowcs function. */ +/* #undef HAVE_MBSRTOWCS */ + /* Define if you have the memmove function. */ #define HAVE_MEMMOVE 1 @@ -27,32 +47,59 @@ /* Define if you have the setenv function. */ #define HAVE_SETENV 1 -/* Define if you have the strcasecmp function. */ -#define HAVE_STRCASECMP 1 - /* Define if you have the setlocale function. */ #define HAVE_SETLOCALE 1 -/* Define if you have the tcgetattr function. */ -#define HAVE_TCGETATTR 1 +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 /* Define if you have the strcoll function. */ #define HAVE_STRCOLL 1 /* #undef STRCOLL_BROKEN */ +/* Define if you have the strpbrk function. */ +#define HAVE_STRPBRK 1 + +/* Define if you have the tcgetattr function. */ +#define HAVE_TCGETATTR 1 + +/* Define if you have the vsnprintf function. */ +#define HAVE_VSNPRINTF 1 + +/* Define if you have the wcwidth function. */ +/* #undef HAVE_WCWIDTH */ + /* Define if you have the <dirent.h> header file. */ #define HAVE_DIRENT_H 1 +/* Define if you have the <langinfo.h> header file. */ +#define HAVE_LANGINFO_H 1 + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + /* Define if you have the <ndir.h> header file. */ /* #undef HAVE_NDIR_H */ +/* Define if you have the <stdarg.h> header file. */ +#define HAVE_STDARG_H 1 + /* Define if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 /* Define if you have the <string.h> header file. */ #define HAVE_STRING_H 1 +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + /* Define if you have the <sys/dir.h> header file. */ /* #undef HAVE_SYS_DIR_H */ @@ -89,15 +136,21 @@ /* Define if you have the <varargs.h> header file. */ #define HAVE_VARARGS_H 1 -/* Define if you have the <stdarg.h> header file. */ -#define HAVE_STDARG_H 1 +/* Define if you have the <wchar.h> header file. */ +/* #undef HAVE_WCHAR_H */ -#define HAVE_LOCALE_H 1 +/* Define if you have the <varargs.h> header file. */ +/* #undef HAVE_WCTYPE_H */ + +/* #undef HAVE_MBSTATE_T */ + +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ +/* #undef HAVE_LANGINFO_CODESET */ /* Definitions pulled in from aclocal.m4. */ #define VOID_SIGHANDLER 1 -#define GWINSZ_IN_SYS_IOCTL 1 +/* #undef GWINSZ_IN_SYS_IOCTL */ #define STRUCT_WINSIZE_IN_SYS_IOCTL 1 @@ -109,7 +162,7 @@ /* #undef SPEED_T_IN_SYS_TYPES */ -/* #undef HAVE_GETPW_DECLS */ +#define HAVE_GETPW_DECLS 1 #define STRUCT_DIRENT_HAS_D_INO 1 @@ -125,7 +178,6 @@ #define HAVE_POSIX_SIGSETJMP 1 -/* config.h.bot */ /* modify settings or make new ones based on what autoconf tells us. */ /* Ultrix botches type-ahead when switching from canonical to diff --git a/gnu/lib/libreadline/configure b/gnu/lib/libreadline/configure index 9529856ea2b..9a057c9015a 100644 --- a/gnu/lib/libreadline/configure +++ b/gnu/lib/libreadline/configure @@ -1,131 +1,158 @@ #! /bin/sh +# From configure.in for Readline 4.3, version 2.45, from autoconf version 2.52. +# Guess values for system-dependent variables and create Makefiles. +# Generated by Autoconf 2.52 for readline 4.3. +# +# Report bugs to <bug-readline@gnu.org>. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. -# From configure.in for Readline 4.1, version 2.22, from autoconf version 2.13 -LIBVERSION=4.1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file +as_executable_p="test -f" +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= +# Initializations. +# ac_default_prefix=/usr/local -# Any additions from configure.in: -ac_help="$ac_help ---with-curses use the curses library instead of the termcap library" +cross_compiling=no +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +ac_unique_file="readline.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif" # Initialize some variables set by options. +ac_init_help= +ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. -build=NONE -cache_file=./config.cache +cache_file=/dev/null exec_prefix=NONE -host=NONE no_create= -nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE @@ -134,10 +161,15 @@ program_transform_name=s,x,x, silent= site= srcdir= -target=NONE verbose= x_includes=NONE x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' @@ -151,17 +183,16 @@ oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 +# Identity of this package. +PACKAGE_NAME='readline' +PACKAGE_TARNAME='readline' +PACKAGE_VERSION='4.3' +PACKAGE_STRING='readline 4.3' +PACKAGE_BUGREPORT='bug-readline@gnu.org' ac_prev= for ac_option do - # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" @@ -169,59 +200,59 @@ do continue fi - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. - case "$ac_option" in + case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; + bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) - ac_prev=build ;; + ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; + build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) - datadir="$ac_optarg" ;; + datadir=$ac_optarg ;; -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "enable_${ac_feature}='$ac_optarg'" ;; + eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -230,95 +261,47 @@ do -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; + exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; -host | --host | --hos | --ho) - ac_prev=host ;; + ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; + host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; + includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; + infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; + libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; + libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ @@ -327,12 +310,12 @@ EOF -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; + localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; + mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. @@ -353,26 +336,26 @@ EOF -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; + oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; + prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; + program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; + program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ @@ -389,7 +372,7 @@ EOF | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; + program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) @@ -399,7 +382,7 @@ EOF ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; + sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ @@ -410,58 +393,57 @@ EOF | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; + sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; + site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; + srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; + sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; + ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; + target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac - eval "with_${ac_package}='$ac_optarg'" ;; + eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. @@ -472,98 +454,98 @@ EOF ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; + x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; + x_libraries=$ac_optarg ;; - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } fi -exec 5>./config.log -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; esac done -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: should be removed in autoconf 3.0. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=readline.h +test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then @@ -574,13 +556,316 @@ else fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + { echo "$as_me: error: cannot find sources in $srcdir" >&2 + { (exit 1); exit 1; }; } fi fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<EOF +\`configure' configures readline 4.3 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +EOF + + cat <<EOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +EOF + + cat <<\EOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST build programs to run on HOST [BUILD] +EOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of readline 4.3:";; + esac + cat <<\EOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-shared build shared libraries [default=YES] + --enable-static build static libraries [default=YES] + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-curses use the curses library instead of the termcap + library + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have + headers in a nonstandard directory <include dir> + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to <bug-readline@gnu.org>. +EOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue + cd $ac_subdir + # A "../" for each directory in /$ac_subdir. + ac_dots=`echo $ac_subdir | + sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` + + case $srcdir in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_subdir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_sub_srcdir/configure.gnu; then + echo + $SHELL $ac_sub_srcdir/configure.gnu --help=recursive + elif test -f $ac_sub_srcdir/configure; then + echo + $SHELL $ac_sub_srcdir/configure --help=recursive + elif test -f $ac_sub_srcdir/configure.ac || + test -f $ac_sub_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\EOF +readline configure 4.3 +generated by GNU Autoconf 2.52 + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +EOF + exit 0 +fi +exec 5>config.log +cat >&5 <<EOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by readline $as_me 4.3, which was +generated by GNU Autoconf 2.52. Invocation command line was + + $ $0 $@ + +EOF +{ +cat <<_ASUNAME +## ---------- ## +## Platform. ## +## ---------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +PATH = $PATH + +_ASUNAME +} >&5 + +cat >&5 <<EOF +## ------------ ## +## Core tests. ## +## ------------ ## + +EOF + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell meta-characters. +ac_configure_args= +ac_sep= +for ac_arg +do + case $ac_arg in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + ac_sep=" " ;; + *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" + ac_sep=" " ;; + esac + # Get rid of the leading space. +done + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + echo >&5 + echo "## ----------------- ##" >&5 + echo "## Cache variables. ##" >&5 + echo "## ----------------- ##" >&5 + echo >&5 + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} >&5 + sed "/^$/d" confdefs.h >conftest.log + if test -s conftest.log; then + echo >&5 + echo "## ------------ ##" >&5 + echo "## confdefs.h. ##" >&5 + echo "## ------------ ##" >&5 + echo >&5 + cat conftest.log >&5 + fi + (echo; echo) >&5 + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" >&5 + echo "$as_me: exit $exit_status" >&5 + rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h +# Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then @@ -591,47 +876,110 @@ if test -z "$CONFIG_SITE"; then fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" + { echo "$as_me:879: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + cat "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:890: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi else - echo "creating cache $cache_file" - > $cache_file + { echo "$as_me:898: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:914: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:918: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:924: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:926: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:928: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. It doesn't matter if + # we pass some twice (in addition to the command line arguments). + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val" + ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:947: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:949: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } fi ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac +echo "#! $SHELL" >conftest.sh +echo "exit 0" >>conftest.sh +chmod +x conftest.sh +if { (echo "$as_me:969: PATH=\".;.\"; conftest.sh") >&5 + (PATH=".;."; conftest.sh) 2>&5 + ac_status=$? + echo "$as_me:972: \$? = $ac_status" >&5 + (exit $ac_status); }; then + ac_path_separator=';' else - ac_n= ac_c='\c' ac_t= + ac_path_separator=: fi - - - - - +PATH_SEPARATOR="$ac_path_separator" +rm -f conftest.sh ac_aux_dir= -for ac_dir in ${GNUSYSTEM_AUX_DIR} ./support $srcdir/./support; do +for ac_dir in ${GNUSYSTEM_AUX_DIR} ./support $srcdir/./support; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" @@ -640,269 +988,711 @@ for ac_dir in ${GNUSYSTEM_AUX_DIR} ./support $srcdir/./support; do ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break fi done if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in ./support $srcdir/./support" 1>&2; exit 1; } + { { echo "$as_me:998: error: cannot find install-sh or install.sh in ./support $srcdir/./support" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in ./support $srcdir/./support" >&2;} + { (exit 1); exit 1; }; } fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. +ac_config_headers="$ac_config_headers config.h" +LIBVERSION=4.3 # Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:661: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:1012: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:1016: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:1025: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:1029: error: $ac_config_sub $ac_cv_build_alias failed." >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:1034: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +echo "$as_me:1041: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:1050: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:1055: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` opt_curses=no -opt_shared=no # Check whether --with-curses or --without-curses was given. if test "${with_curses+set}" = set; then withval="$with_curses" opt_curses=$withval -fi - +fi; if test "$opt_curses" = "yes"; then prefer_curses=yes fi +opt_static_libs=yes +opt_shared_libs=yes + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + opt_shared_libs=$enableval +fi; +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + opt_static_libs=$enableval +fi; + +echo "" +echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}" +echo "" + # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 -# Extract the first word of "gcc", so it can be a program name with args. +echo "$as_me:1095: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:1115: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:1119: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:1132: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}gcc" +echo "$as_me:1147: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1155: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1158: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:702: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:1167: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="gcc" +echo "$as_me:1182: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1190: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1193: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:1206: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="gcc" - break - fi - done - IFS="$ac_save_ifs" + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}cc" +echo "$as_me:1221: found $ac_dir/$ac_word" >&5 +break +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:1229: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:1232: result: no" >&5 +echo "${ECHO_T}no" >&6 fi +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:1241: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="cc" +echo "$as_me:1256: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1264: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1267: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:732: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:1280: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - break - fi - done - IFS="$ac_save_ifs" + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue +fi +ac_cv_prog_CC="cc" +echo "$as_me:1300: found $ac_dir/$ac_word" >&5 +break +done + if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift - if test $# -gt 0; then + if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - set dummy "$ac_dir/$ac_word" "$@" + set dummy "$ac_dir/$ac_word" ${1+"$@"} shift ac_cv_prog_CC="$@" fi fi fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:1322: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:1325: result: no" >&5 +echo "${ECHO_T}no" >&6 fi - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:783: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:1336: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="$ac_tool_prefix$ac_prog" +echo "$as_me:1351: found $ac_dir/$ac_word" >&5 +break +done + fi fi -CC="$ac_cv_prog_CC" +CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 + echo "$as_me:1359: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi - test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } + echo "$as_me:1362: result: no" >&5 +echo "${ECHO_T}no" >&6 fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:815: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:1375: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="$ac_prog" +echo "$as_me:1390: found $ac_dir/$ac_word" >&5 +break +done -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1398: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1401: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi -cat > conftest.$ac_ext << EOF + test -n "$ac_ct_CC" && break +done -#line 826 "configure" + CC=$ac_ct_CC +fi + +fi + +test -z "$CC" && { { echo "$as_me:1413: error: no acceptable cc found in \$PATH" >&5 +echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:1418:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:1421: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:1424: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:1426: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:1429: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:1431: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:1434: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line 1438 "configure" #include "confdefs.h" -main(){return(0);} -EOF -if { (eval echo configure:831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - ac_cv_prog_cc_works=yes - # If we can't run a trivial program, we are probably using a cross compiler. - if (./conftest; exit) 2>/dev/null; then - ac_cv_prog_cc_cross=no +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:1454: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:1457: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:1460: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. +for ac_file in `ls a.exe conftest.exe 2>/dev/null; + ls a.out conftest 2>/dev/null; + ls a.* conftest.* 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + a.out ) # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool --akim. + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:1483: error: C compiler cannot create executables" >&5 +echo "$as_me: error: C compiler cannot create executables" >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:1489: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:1494: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:1500: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1503: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no else - ac_cv_prog_cc_cross=yes + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:1510: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&2;} + { (exit 1); exit 1; }; } + fi fi -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_cv_prog_cc_works=no fi -rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 -if test $ac_cv_prog_cc_works = no; then - { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } -fi -echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:857: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 -echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 -cross_compiling=$ac_cv_prog_cc_cross - -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:862: checking whether we are using GNU C" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.c <<EOF -#ifdef __GNUC__ - yes; -#endif -EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:871: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_gcc=yes +echo "$as_me:1518: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:1525: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:1527: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:1530: checking for executable suffix" >&5 +echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 +if { (eval echo "$as_me:1532: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:1535: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done else - ac_cv_prog_gcc=no -fi -fi + { { echo "$as_me:1551: error: cannot compute EXEEXT: cannot compile and link" >&5 +echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:1557: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:1563: checking for object suffix" >&5 +echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1569 "configure" +#include "confdefs.h" -echo "$ac_t""$ac_cv_prog_gcc" 1>&6 +int +main () +{ -if test $ac_cv_prog_gcc = yes; then - GCC=yes + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:1581: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1584: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done else - GCC= -fi + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:1596: error: cannot compute OBJEXT: cannot compile" >&5 +echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:1603: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:1607: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 1613 "configure" +#include "confdefs.h" + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:890: checking whether ${CC-cc} accepts -g" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1628: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1631: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1634: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1637: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:1649: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:1655: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo 'void f(){}' > conftest.c -if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + cat >conftest.$ac_ext <<_ACEOF +#line 1661 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1673: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1676: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1679: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1682: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else - ac_cv_prog_cc_g=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest.$ac_ext fi - -echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +echo "$as_me:1692: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" + CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" @@ -916,182 +1706,417 @@ else CFLAGS= fi fi +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1719: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1722: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1725: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1728: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include <stdlib.h>' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line 1740 "configure" +#include "confdefs.h" +#include <stdlib.h> +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1753: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1756: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1759: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1762: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line 1772 "configure" +#include "confdefs.h" +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1784: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1787: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1790: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1793: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:922: checking how to run the C preprocessor" >&5 +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:1825: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext <<EOF -#line 937 "configure" + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line 1846 "configure" #include "confdefs.h" #include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then + Syntax error +_ACEOF +if { (eval echo "$as_me:1851: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1857: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext <<EOF -#line 954 "configure" + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line 1880 "configure" #include "confdefs.h" -#include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:960: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:1884: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1890: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext <<EOF -#line 971 "configure" + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:1927: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line 1937 "configure" #include "confdefs.h" #include <assert.h> -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:977: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then + Syntax error +_ACEOF +if { (eval echo "$as_me:1942: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1948: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then : else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 + echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* + # Broken: fails on valid input. +continue fi -rm -f conftest* +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line 1971 "configure" +#include "confdefs.h" +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:1975: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:1981: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Passes both tests. +ac_preproc_ok=: +break fi - CPP="$ac_cv_prog_CPP" +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : else - ac_cv_prog_CPP="$CPP" + { { echo "$as_me:2009: error: C preprocessor \"$CPP\" fails sanity check" >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} + { (exit 1); exit 1; }; } fi -echo "$ac_t""$CPP" 1>&6 -ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:1003: checking for minix/config.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +echo "$as_me:2020: checking for minix/config.h" >&5 +echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 +if test "${ac_cv_header_minix_config_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1008 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 2026 "configure" #include "confdefs.h" #include <minix/config.h> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1013: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" +_ACEOF +if { (eval echo "$as_me:2030: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2036: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_minix_config_h=yes +else + echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" + ac_cv_header_minix_config_h=no fi -rm -f conftest* +rm -f conftest.err conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:2055: result: $ac_cv_header_minix_config_h" >&5 +echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 +if test $ac_cv_header_minix_config_h = yes; then MINIX=yes else - echo "$ac_t""no" 1>&6 -MINIX= + MINIX= fi if test "$MINIX" = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\EOF #define _POSIX_SOURCE 1 EOF - cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define _POSIX_1_SOURCE 2 EOF - cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define _MINIX 1 EOF fi - # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS. test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O" -if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1056: checking whether ${CC-cc} needs -traditional" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test $ac_cv_c_compiler_gnu = yes; then + echo "$as_me:2083: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6 +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" - cat > conftest.$ac_ext <<EOF -#line 1062 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 2090 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* ac_cv_prog_gcc_traditional=yes else - rm -rf conftest* ac_cv_prog_gcc_traditional=no fi rm -f conftest* - if test $ac_cv_prog_gcc_traditional = no; then - cat > conftest.$ac_ext <<EOF -#line 1080 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 2105 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then - rm -rf conftest* ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi - -echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 +echo "$as_me:2118: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6 if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi @@ -1104,31 +2129,39 @@ fi # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1113: checking for a BSD compatible install" >&5 +echo "$as_me:2137: checking for a BSD compatible install" >&5 +echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + ac_save_IFS=$IFS; IFS=$ac_path_separator for ac_dir in $PATH; do + IFS=$ac_save_IFS # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + case $ac_dir/ in + / | ./ | .// | /cC/* \ + | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ + | /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then + if $as_executable_p "$ac_dir/$ac_prog"; then if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : + elif test $ac_prog = install && + grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 @@ -1138,105 +2171,581 @@ else ;; esac done - IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" + INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. - INSTALL="$ac_install_sh" + INSTALL=$ac_install_sh fi fi -echo "$ac_t""$INSTALL" 1>&6 +echo "$as_me:2186: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1168: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:2199: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_AR="ar" - break - fi - done - IFS="$ac_save_ifs" + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_AR="" +echo "$as_me:2214: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" fi fi -AR="$ac_cv_prog_AR" +AR=$ac_cv_prog_AR if test -n "$AR"; then - echo "$ac_t""$AR" 1>&6 + echo "$as_me:2223: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:2226: result: no" >&5 +echo "${ECHO_T}no" >&6 fi test -n "$ARFLAGS" || ARFLAGS="cr" -# Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1198: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:2234: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" +echo "$as_me:2249: found $ac_dir/$ac_word" >&5 +break +done + fi fi -RANLIB="$ac_cv_prog_RANLIB" +RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 + echo "$as_me:2257: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 else - echo "$ac_t""no" 1>&6 + echo "$as_me:2260: result: no" >&5 +echo "${ECHO_T}no" >&6 fi +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:2269: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_RANLIB="ranlib" +echo "$as_me:2284: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:2293: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:2296: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi MAKE_SHELL=/bin/sh +echo "$as_me:2307: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line 2315 "configure" +#include "confdefs.h" +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:2364: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2367: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2370: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2373: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:2390: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:2393: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +echo "$as_me:2398: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2404 "configure" +#include "confdefs.h" + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2462: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2465: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2468: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2471: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_const=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2481: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\EOF +#define const +EOF + +fi + +echo "$as_me:2491: checking for function prototypes" >&5 +echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 +if test "$ac_cv_prog_cc_stdc" != no; then + echo "$as_me:2494: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\EOF +#define PROTOTYPES 1 +EOF + +else + echo "$as_me:2502: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:2506: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2512 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +_ACEOF +if { (eval echo "$as_me:2520: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2526: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line 2548 "configure" +#include "confdefs.h" +#include <string.h> -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1230: checking return type of signal handlers" >&5 -if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : else - cat > conftest.$ac_ext <<EOF -#line 1235 "configure" + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line 2566 "configure" +#include "confdefs.h" +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +#line 2587 "configure" +#include "confdefs.h" +#include <ctype.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:2613: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2616: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:2618: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2621: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_header_stdc=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:2634: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:2650: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2656 "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2662: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2665: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2668: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2671: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2681: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +EOF + +fi +done + +echo "$as_me:2691: checking whether char is unsigned" >&5 +echo $ECHO_N "checking whether char is unsigned... $ECHO_C" >&6 +if test "${ac_cv_c_char_unsigned+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2697 "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +int _array_ [1 - 2 * !(((char) -1) < 0)] + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2709: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2712: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2715: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2718: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_char_unsigned=no +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_char_unsigned=yes +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2728: result: $ac_cv_c_char_unsigned" >&5 +echo "${ECHO_T}$ac_cv_c_char_unsigned" >&6 +if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then + cat >>confdefs.h <<\EOF +#define __CHAR_UNSIGNED__ 1 +EOF + +fi + +echo "$as_me:2737: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2743 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> #ifdef signal -#undef signal +# undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); @@ -1244,36 +2753,152 @@ extern "C" void (*signal (int, void (*)(int)))(int); void (*signal ()) (); #endif -int main() { +int +main () +{ int i; -; return 0; } -EOF -if { (eval echo configure:1252: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2765: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2768: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2771: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2774: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_type_signal=void else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_type_signal=int + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_signal=int fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:2784: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6 -echo "$ac_t""$ac_cv_type_signal" 1>&6 -cat >> confdefs.h <<EOF +cat >>confdefs.h <<EOF #define RETSIGTYPE $ac_cv_type_signal EOF +echo "$as_me:2791: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2797 "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2812: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2815: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2818: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2821: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_size_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2831: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<EOF +#define size_t unsigned +EOF +fi -echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 -echo "configure:1272: checking whether stat file-mode macros are broken" >&5 -if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:2843: checking for ssize_t" >&5 +echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6 +if test "${ac_cv_type_ssize_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1277 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 2849 "configure" +#include "confdefs.h" +$ac_includes_default +int +main () +{ +if ((ssize_t *) 0) + return 0; +if (sizeof (ssize_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2864: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2867: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2870: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2873: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_ssize_t=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_type_ssize_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2883: result: $ac_cv_type_ssize_t" >&5 +echo "${ECHO_T}$ac_cv_type_ssize_t" >&6 +if test $ac_cv_type_ssize_t = yes; then + : +else + +cat >>confdefs.h <<EOF +#define ssize_t int +EOF + +fi + +echo "$as_me:2895: checking whether stat file-mode macros are broken" >&5 +echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6 +if test "${ac_cv_header_stat_broken+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2901 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/stat.h> @@ -1302,409 +2927,516 @@ You lose. # endif #endif -EOF +_ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "You lose" >/dev/null 2>&1; then - rm -rf conftest* ac_cv_header_stat_broken=yes else - rm -rf conftest* ac_cv_header_stat_broken=no fi rm -f conftest* fi - -echo "$ac_t""$ac_cv_header_stat_broken" 1>&6 +echo "$as_me:2940: result: $ac_cv_header_stat_broken" >&5 +echo "${ECHO_T}$ac_cv_header_stat_broken" >&6 if test $ac_cv_header_stat_broken = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\EOF #define STAT_MACROS_BROKEN 1 EOF fi ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1332: checking for $ac_hdr that defines DIR" >&5 -if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1337 "configure" +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +echo "$as_me:2953: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2959 "configure" #include "confdefs.h" #include <sys/types.h> #include <$ac_hdr> -int main() { -DIR *dirp = 0; -; return 0; } -EOF -if { (eval echo configure:1345: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=yes" + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2974: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2977: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2980: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2983: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_Header=no" fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 +echo "$as_me:2993: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 EOF - ac_header_dirent=$ac_hdr; break -else - echo "$ac_t""no" 1>&6 + +ac_header_dirent=$ac_hdr; break fi + done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then -echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1370: checking for opendir in -ldir" >&5 -ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:3006: checking for opendir in -ldir" >&5 +echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6 +if test "${ac_cv_lib_dir_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-ldir $LIBS" -cat > conftest.$ac_ext <<EOF -#line 1378 "configure" +cat >conftest.$ac_ext <<_ACEOF +#line 3014 "configure" #include "confdefs.h" + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir(); - -int main() { -opendir() -; return 0; } -EOF -if { (eval echo configure:1389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3033: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3036: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3039: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3042: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dir_opendir=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_dir_opendir=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:3053: result: $ac_cv_lib_dir_opendir" >&5 +echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6 +if test $ac_cv_lib_dir_opendir = yes; then LIBS="$LIBS -ldir" -else - echo "$ac_t""no" 1>&6 fi else -echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:1411: checking for opendir in -lx" >&5 -ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:3060: checking for opendir in -lx" >&5 +echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6 +if test "${ac_cv_lib_x_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lx $LIBS" -cat > conftest.$ac_ext <<EOF -#line 1419 "configure" +cat >conftest.$ac_ext <<_ACEOF +#line 3068 "configure" #include "confdefs.h" + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char opendir(); - -int main() { -opendir() -; return 0; } -EOF -if { (eval echo configure:1430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char opendir (); +int +main () +{ +opendir (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3087: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3090: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3093: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3096: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_x_opendir=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_x_opendir=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:3107: result: $ac_cv_lib_x_opendir" >&5 +echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6 +if test $ac_cv_lib_x_opendir = yes; then LIBS="$LIBS -lx" -else - echo "$ac_t""no" 1>&6 fi fi - for ac_func in lstat memmove putenv select setenv setlocale \ - strcasecmp tcgetattr + strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1457: checking for $ac_func" >&5 -if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:3119: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1462 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3125 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func(); below. */ + which can conflict with char $ac_func (); below. */ #include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $ac_func(); - -int main() { + builtin and then its argument prototype would still apply. */ +char $ac_func (); +char (*f) (); +int +main () +{ /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -$ac_func(); +f = $ac_func; #endif -; return 0; } -EOF -if { (eval echo configure:1485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_$ac_func=yes" + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3156: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3159: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3162: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3165: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_$ac_func=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +eval "$as_ac_var=no" fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi - -if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - cat >> confdefs.h <<EOF -#define $ac_tr_func 1 +echo "$as_me:3175: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 EOF - -else - echo "$ac_t""no" 1>&6 + fi done - -echo $ac_n "checking for working strcoll""... $ac_c" 1>&6 -echo "configure:1511: checking for working strcoll" >&5 -if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3185: checking for working strcoll" >&5 +echo $ECHO_N "checking for working strcoll... $ECHO_C" >&6 +if test "${ac_cv_func_strcoll_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_strcoll_works=no else - cat > conftest.$ac_ext <<EOF -#line 1519 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3194 "configure" #include "confdefs.h" -#include <string.h> +$ac_includes_default +int main () { - exit (strcoll ("abc", "def") >= 0 || - strcoll ("ABC", "DEF") >= 0 || - strcoll ("123", "456") >= 0); +exit (strcoll ("abc", "def") >= 0 || + strcoll ("ABC", "DEF") >= 0 || + strcoll ("123", "456") >= 0) + ; + return 0; } -EOF -if { (eval echo configure:1529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3208: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3211: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3213: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3216: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then ac_cv_func_strcoll_works=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_func_strcoll_works=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_strcoll_works=no fi -rm -fr conftest* +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi - -echo "$ac_t""$ac_cv_func_strcoll_works" 1>&6 +echo "$as_me:3228: result: $ac_cv_func_strcoll_works" >&5 +echo "${ECHO_T}$ac_cv_func_strcoll_works" >&6 if test $ac_cv_func_strcoll_works = yes; then - cat >> confdefs.h <<\EOF + +cat >>confdefs.h <<\EOF #define HAVE_STRCOLL 1 EOF fi - -for ac_hdr in unistd.h stdlib.h varargs.h stdarg.h string.h \ - sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ - termcap.h termios.h termio.h sys/file.h locale.h +for ac_header in unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \ + limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ + termcap.h termios.h termio.h sys/file.h locale.h memory.h do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1558: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1563 "configure" +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:3243: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3249 "configure" #include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:3253: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:3259: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" + eval "$as_ac_Header=no" fi -rm -f conftest* +rm -f conftest.err conftest.$ac_ext fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 +echo "$as_me:3278: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 EOF - -else - echo "$ac_t""no" 1>&6 + fi done - - -echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6 -echo "configure:1597: checking for type of signal functions" >&5 -if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3288: checking for type of signal functions" >&5 +echo $ECHO_N "checking for type of signal functions... $ECHO_C" >&6 +if test "${bash_cv_signal_vintage+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - - cat > conftest.$ac_ext <<EOF -#line 1603 "configure" + + cat >conftest.$ac_ext <<_ACEOF +#line 3295 "configure" #include "confdefs.h" #include <signal.h> -int main() { +int +main () +{ sigset_t ss; struct sigaction sa; sigemptyset(&ss); sigsuspend(&ss); sigaction(SIGINT, &sa, (struct sigaction *) 0); sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); - -; return 0; } -EOF -if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3313: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3316: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3319: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3322: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_signal_vintage=posix else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - - cat > conftest.$ac_ext <<EOF -#line 1625 "configure" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +#line 3330 "configure" #include "confdefs.h" #include <signal.h> -int main() { +int +main () +{ int mask = sigmask(SIGINT); sigsetmask(mask); sigblock(mask); sigpause(mask); - -; return 0; } -EOF -if { (eval echo configure:1635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3345: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3348: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3351: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3354: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_signal_vintage=4.2bsd else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - - cat > conftest.$ac_ext <<EOF -#line 1644 "configure" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +#line 3362 "configure" #include "confdefs.h" #include <signal.h> RETSIGTYPE foo() { } -int main() { +int +main () +{ int mask = sigmask(SIGINT); sigset(SIGINT, foo); sigrelse(SIGINT); sighold(SIGINT); sigpause(SIGINT); - -; return 0; } -EOF -if { (eval echo configure:1657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3380: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3383: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3386: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3389: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_signal_vintage=svr3 else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_signal_vintage=v7 - + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_signal_vintage=v7 + fi -rm -f conftest* - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_signal_vintage" 1>&6 +echo "$as_me:3408: result: $bash_cv_signal_vintage" >&5 +echo "${ECHO_T}$bash_cv_signal_vintage" >&6 if test "$bash_cv_signal_vintage" = posix; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define HAVE_POSIX_SIGNALS 1 EOF elif test "$bash_cv_signal_vintage" = "4.2bsd"; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define HAVE_BSD_SIGNALS 1 EOF elif test "$bash_cv_signal_vintage" = svr3; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define HAVE_USG_SIGHOLD 1 EOF fi - - -echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6 -echo "configure:1698: checking if signal handlers must be reinstalled when invoked" >&5 -if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3427: checking if signal handlers must be reinstalled when invoked" >&5 +echo $ECHO_N "checking if signal handlers must be reinstalled when invoked... $ECHO_C" >&6 +if test "${bash_cv_must_reinstall_sighandlers+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - echo "configure: warning: cannot check signal handling if cross compiling -- defaulting to no" 1>&2 + { echo "$as_me:3433: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&5 +echo "$as_me: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&2;} bash_cv_must_reinstall_sighandlers=no else - cat > conftest.$ac_ext <<EOF -#line 1708 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3439 "configure" #include "confdefs.h" #include <signal.h> @@ -1750,43 +3482,51 @@ main() exit(nsigint != 2); } -EOF -if { (eval echo configure:1755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3487: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3490: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3492: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3495: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_must_reinstall_sighandlers=no else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_must_reinstall_sighandlers=yes + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_must_reinstall_sighandlers=yes fi -rm -fr conftest* +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi -echo "$ac_t""$bash_cv_must_reinstall_sighandlers" 1>&6 +echo "$as_me:3508: result: $bash_cv_must_reinstall_sighandlers" >&5 +echo "${ECHO_T}$bash_cv_must_reinstall_sighandlers" >&6 if test $bash_cv_must_reinstall_sighandlers = yes; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define MUST_REINSTALL_SIGHANDLERS 1 EOF fi - - -echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6 -echo "configure:1780: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 -if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3517: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 +echo $ECHO_N "checking for presence of POSIX-style sigsetjmp/siglongjmp... $ECHO_C" >&6 +if test "${bash_cv_func_sigsetjmp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - echo "configure: warning: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" 1>&2 + { echo "$as_me:3523: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&5 +echo "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&2;} bash_cv_func_sigsetjmp=missing else - cat > conftest.$ac_ext <<EOF -#line 1790 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3529 "configure" #include "confdefs.h" #ifdef HAVE_UNISTD_H @@ -1826,115 +3566,100 @@ siglongjmp(xx, 10); exit(1); #endif } -EOF -if { (eval echo configure:1831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3571: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3574: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3576: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3579: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_func_sigsetjmp=present else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_func_sigsetjmp=missing + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_func_sigsetjmp=missing fi -rm -fr conftest* +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi -echo "$ac_t""$bash_cv_func_sigsetjmp" 1>&6 +echo "$as_me:3592: result: $bash_cv_func_sigsetjmp" >&5 +echo "${ECHO_T}$bash_cv_func_sigsetjmp" >&6 if test $bash_cv_func_sigsetjmp = present; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define HAVE_POSIX_SIGSETJMP 1 EOF fi -echo $ac_n "checking for lstat""... $ac_c" 1>&6 -echo "configure:1854: checking for lstat" >&5 -if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3601: checking for lstat" >&5 +echo $ECHO_N "checking for lstat... $ECHO_C" >&6 +if test "${bash_cv_func_lstat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 1859 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3607 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/stat.h> -int main() { - lstat(".",(struct stat *)0); -; return 0; } -EOF -if { (eval echo configure:1869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* +int +main () +{ + lstat(".",(struct stat *)0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3622: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3625: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3628: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3631: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_func_lstat=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_func_lstat=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_func_lstat=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi - -echo "$ac_t""$bash_cv_func_lstat" 1>&6 +echo "$as_me:3641: result: $bash_cv_func_lstat" >&5 +echo "${ECHO_T}$bash_cv_func_lstat" >&6 if test $bash_cv_func_lstat = yes; then - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\EOF #define HAVE_LSTAT 1 EOF fi -echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6 -echo "configure:1890: checking whether programs are able to redeclare getpw functions" >&5 -if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 1895 "configure" -#include "confdefs.h" -#include <sys/types.h> -#include <pwd.h> -extern struct passwd *getpwent(); -extern struct passwd *getpwuid(); -extern struct passwd *getpwnam(); -int main() { -struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root"); -; return 0; } -EOF -if { (eval echo configure:1906: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_can_redecl_getpw=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_can_redecl_getpw=no -fi -rm -f conftest* -fi - -echo "$ac_t""$bash_cv_can_redecl_getpw" 1>&6 -if test $bash_cv_can_redecl_getpw = no; then -cat >> confdefs.h <<\EOF -#define HAVE_GETPW_DECLS 1 -EOF - -fi - - -echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6 -echo "configure:1928: checking whether or not strcoll and strcmp differ" >&5 -if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3650: checking whether or not strcoll and strcmp differ" >&5 +echo $ECHO_N "checking whether or not strcoll and strcmp differ... $ECHO_C" >&6 +if test "${bash_cv_func_strcoll_broken+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then - echo "configure: warning: cannot check strcoll if cross compiling -- defaulting to no" 1>&2 + { echo "$as_me:3656: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&5 +echo "$as_me: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&2;} bash_cv_func_strcoll_broken=no else - cat > conftest.$ac_ext <<EOF -#line 1938 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3662 "configure" #include "confdefs.h" #include <stdio.h> @@ -1972,274 +3697,476 @@ char *v[]; exit (r1 > 0 && r2 > 0); } -EOF -if { (eval echo configure:1977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3702: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3705: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3707: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3710: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_func_strcoll_broken=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - bash_cv_func_strcoll_broken=no + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_func_strcoll_broken=no fi -rm -fr conftest* +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi - fi -echo "$ac_t""$bash_cv_func_strcoll_broken" 1>&6 +echo "$as_me:3723: result: $bash_cv_func_strcoll_broken" >&5 +echo "${ECHO_T}$bash_cv_func_strcoll_broken" >&6 if test $bash_cv_func_strcoll_broken = yes; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define STRCOLL_BROKEN 1 EOF fi - -echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6 -echo "configure:2001: checking whether signal handlers are of type void" >&5 -if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3732: checking whether getpw functions are declared in pwd.h" >&5 +echo $ECHO_N "checking whether getpw functions are declared in pwd.h... $ECHO_C" >&6 +if test "${bash_cv_getpw_declared+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2006 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3738 "configure" #include "confdefs.h" + #include <sys/types.h> -#include <signal.h> -#ifdef signal -#undef signal -#endif -#ifdef __cplusplus -extern "C" +#ifdef HAVE_UNISTD_H +# include <unistd.h> #endif -void (*signal ()) (); -int main() { -int i; -; return 0; } -EOF -if { (eval echo configure:2021: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_void_sighandler=yes +#include <pwd.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "getpwuid" >/dev/null 2>&1; then + bash_cv_getpw_declared=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_void_sighandler=no + bash_cv_getpw_declared=no fi rm -f conftest* + fi -echo "$ac_t""$bash_cv_void_sighandler" 1>&6 -if test $bash_cv_void_sighandler = yes; then -cat >> confdefs.h <<\EOF -#define VOID_SIGHANDLER 1 + +echo "$as_me:3758: result: $bash_cv_getpw_declared" >&5 +echo "${ECHO_T}$bash_cv_getpw_declared" >&6 +if test $bash_cv_getpw_declared = yes; then +cat >>confdefs.h <<\EOF +#define HAVE_GETPW_DECLS 1 EOF fi -echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2041: checking for TIOCGWINSZ in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3767: checking POSIX termios" >&5 +echo $ECHO_N "checking POSIX termios... $ECHO_C" >&6 +if test "${ac_cv_sys_posix_termios+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2046 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3773 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <unistd.h> +#include <termios.h> +int +main () +{ +/* SunOS 4.0.3 has termios.h but not the library calls. */ + tcgetattr(0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3788: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3791: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3794: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3797: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sys_posix_termios=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_sys_posix_termios=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:3807: result: $ac_cv_sys_posix_termios" >&5 +echo "${ECHO_T}$ac_cv_sys_posix_termios" >&6 + +if test $ac_cv_sys_posix_termios = yes; then + echo "$as_me:3811: checking whether termios.h defines TIOCGWINSZ" >&5 +echo $ECHO_N "checking whether termios.h defines TIOCGWINSZ... $ECHO_C" >&6 +if test "${ac_cv_sys_tiocgwinsz_in_termios_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3817 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <termios.h> +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + ac_cv_sys_tiocgwinsz_in_termios_h=yes +else + ac_cv_sys_tiocgwinsz_in_termios_h=no +fi +rm -f conftest* + +fi +echo "$as_me:3835: result: $ac_cv_sys_tiocgwinsz_in_termios_h" >&5 +echo "${ECHO_T}$ac_cv_sys_tiocgwinsz_in_termios_h" >&6 + +fi +if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then + echo "$as_me:3840: checking whether sys/ioctl.h defines TIOCGWINSZ" >&5 +echo $ECHO_N "checking whether sys/ioctl.h defines TIOCGWINSZ... $ECHO_C" >&6 +if test "${ac_cv_sys_tiocgwinsz_in_sys_ioctl_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3846 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/ioctl.h> -int main() { -int x = TIOCGWINSZ; -; return 0; } -EOF -if { (eval echo configure:2054: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - bash_cv_tiocgwinsz_in_ioctl=yes +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "yes" >/dev/null 2>&1; then + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_tiocgwinsz_in_ioctl=no + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no fi rm -f conftest* + fi +echo "$as_me:3864: result: $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&5 +echo "${ECHO_T}$ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&6 -echo "$ac_t""$bash_cv_tiocgwinsz_in_ioctl" 1>&6 -if test $bash_cv_tiocgwinsz_in_ioctl = yes; then -cat >> confdefs.h <<\EOF + if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then + +cat >>confdefs.h <<\EOF #define GWINSZ_IN_SYS_IOCTL 1 EOF + fi +fi + +echo "$as_me:3876: checking whether signal handlers are of type void" >&5 +echo $ECHO_N "checking whether signal handlers are of type void... $ECHO_C" >&6 +if test "${bash_cv_void_sighandler+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 3882 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <signal.h> +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" +#endif +void (*signal ()) (); +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3902: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3905: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3908: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3911: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_void_sighandler=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_void_sighandler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:3921: result: $bash_cv_void_sighandler" >&5 +echo "${ECHO_T}$bash_cv_void_sighandler" >&6 +if test $bash_cv_void_sighandler = yes; then +cat >>confdefs.h <<\EOF +#define VOID_SIGHANDLER 1 +EOF + fi -echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2075: checking for TIOCSTAT in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3930: checking for TIOCSTAT in sys/ioctl.h" >&5 +echo $ECHO_N "checking for TIOCSTAT in sys/ioctl.h... $ECHO_C" >&6 +if test "${bash_cv_tiocstat_in_ioctl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2080 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3936 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/ioctl.h> -int main() { +int +main () +{ int x = TIOCSTAT; -; return 0; } -EOF -if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3949: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3952: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3955: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3958: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_tiocstat_in_ioctl=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_tiocstat_in_ioctl=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_tiocstat_in_ioctl=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_tiocstat_in_ioctl" 1>&6 -if test $bash_cv_tiocstat_in_ioctl = yes; then -cat >> confdefs.h <<\EOF +echo "$as_me:3969: result: $bash_cv_tiocstat_in_ioctl" >&5 +echo "${ECHO_T}$bash_cv_tiocstat_in_ioctl" >&6 +if test $bash_cv_tiocstat_in_ioctl = yes; then +cat >>confdefs.h <<\EOF #define TIOCSTAT_IN_SYS_IOCTL 1 EOF fi -echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:2109: checking for FIONREAD in sys/ioctl.h" >&5 -if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:3978: checking for FIONREAD in sys/ioctl.h" >&5 +echo $ECHO_N "checking for FIONREAD in sys/ioctl.h... $ECHO_C" >&6 +if test "${bash_cv_fionread_in_ioctl+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2114 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 3984 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/ioctl.h> -int main() { +int +main () +{ int x = FIONREAD; -; return 0; } -EOF -if { (eval echo configure:2122: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3997: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4000: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4003: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4006: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_fionread_in_ioctl=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_fionread_in_ioctl=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_fionread_in_ioctl=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_fionread_in_ioctl" 1>&6 -if test $bash_cv_fionread_in_ioctl = yes; then -cat >> confdefs.h <<\EOF +echo "$as_me:4017: result: $bash_cv_fionread_in_ioctl" >&5 +echo "${ECHO_T}$bash_cv_fionread_in_ioctl" >&6 +if test $bash_cv_fionread_in_ioctl = yes; then +cat >>confdefs.h <<\EOF #define FIONREAD_IN_SYS_IOCTL 1 EOF fi -echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:2143: checking for speed_t in sys/types.h" >&5 -if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:4026: checking for speed_t in sys/types.h" >&5 +echo $ECHO_N "checking for speed_t in sys/types.h... $ECHO_C" >&6 +if test "${bash_cv_speed_t_in_sys_types+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2148 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 4032 "configure" #include "confdefs.h" #include <sys/types.h> -int main() { +int +main () +{ speed_t x; -; return 0; } -EOF -if { (eval echo configure:2155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4044: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4047: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4050: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4053: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_speed_t_in_sys_types=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_speed_t_in_sys_types=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_speed_t_in_sys_types=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_speed_t_in_sys_types" 1>&6 -if test $bash_cv_speed_t_in_sys_types = yes; then -cat >> confdefs.h <<\EOF +echo "$as_me:4064: result: $bash_cv_speed_t_in_sys_types" >&5 +echo "${ECHO_T}$bash_cv_speed_t_in_sys_types" >&6 +if test $bash_cv_speed_t_in_sys_types = yes; then +cat >>confdefs.h <<\EOF #define SPEED_T_IN_SYS_TYPES 1 EOF fi -echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6 -echo "configure:2176: checking for struct winsize in sys/ioctl.h and termios.h" >&5 -if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:4073: checking for struct winsize in sys/ioctl.h and termios.h" >&5 +echo $ECHO_N "checking for struct winsize in sys/ioctl.h and termios.h... $ECHO_C" >&6 +if test "${bash_cv_struct_winsize_header+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2181 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 4079 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/ioctl.h> -int main() { +int +main () +{ struct winsize x; -; return 0; } -EOF -if { (eval echo configure:2189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4092: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4095: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4098: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4101: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_struct_winsize_header=ioctl_h else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - cat > conftest.$ac_ext <<EOF -#line 2197 "configure" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cat >conftest.$ac_ext <<_ACEOF +#line 4108 "configure" #include "confdefs.h" #include <sys/types.h> #include <termios.h> -int main() { +int +main () +{ struct winsize x; -; return 0; } -EOF -if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4121: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4124: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4127: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4130: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_struct_winsize_header=termios_h else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_struct_winsize_header=other + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_struct_winsize_header=other fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi if test $bash_cv_struct_winsize_header = ioctl_h; then - echo "$ac_t""sys/ioctl.h" 1>&6 - cat >> confdefs.h <<\EOF + echo "$as_me:4145: result: sys/ioctl.h" >&5 +echo "${ECHO_T}sys/ioctl.h" >&6 + cat >>confdefs.h <<\EOF #define STRUCT_WINSIZE_IN_SYS_IOCTL 1 EOF elif test $bash_cv_struct_winsize_header = termios_h; then - echo "$ac_t""termios.h" 1>&6 - cat >> confdefs.h <<\EOF + echo "$as_me:4152: result: termios.h" >&5 +echo "${ECHO_T}termios.h" >&6 + cat >>confdefs.h <<\EOF #define STRUCT_WINSIZE_IN_TERMIOS 1 EOF else - echo "$ac_t""not found" 1>&6 + echo "$as_me:4159: result: not found" >&5 +echo "${ECHO_T}not found" >&6 fi - -echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6 -echo "configure:2238: checking if struct dirent has a d_ino member" >&5 -if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:4163: checking if struct dirent has a d_ino member" >&5 +echo $ECHO_N "checking if struct dirent has a d_ino member... $ECHO_C" >&6 +if test "${bash_cv_dirent_has_dino+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2243 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 4169 "configure" #include "confdefs.h" #include <stdio.h> @@ -2262,40 +4189,53 @@ else # endif #endif /* HAVE_DIRENT_H */ -int main() { +int +main () +{ struct dirent d; int z; z = d.d_ino; -; return 0; } -EOF -if { (eval echo configure:2272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4203: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4206: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4209: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4212: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_dirent_has_dino=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_dirent_has_dino=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_dirent_has_dino=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_dirent_has_dino" 1>&6 +echo "$as_me:4223: result: $bash_cv_dirent_has_dino" >&5 +echo "${ECHO_T}$bash_cv_dirent_has_dino" >&6 if test $bash_cv_dirent_has_dino = yes; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define STRUCT_DIRENT_HAS_D_INO 1 EOF fi - -echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6 -echo "configure:2294: checking if struct dirent has a d_fileno member" >&5 -if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +echo "$as_me:4232: checking if struct dirent has a d_fileno member" >&5 +echo $ECHO_N "checking if struct dirent has a d_fileno member... $ECHO_C" >&6 +if test "${bash_cv_dirent_has_d_fileno+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat > conftest.$ac_ext <<EOF -#line 2299 "configure" + cat >conftest.$ac_ext <<_ACEOF +#line 4238 "configure" #include "confdefs.h" #include <stdio.h> @@ -2318,33 +4258,46 @@ else # endif #endif /* HAVE_DIRENT_H */ -int main() { +int +main () +{ struct dirent d; int z; z = d.d_fileno; -; return 0; } -EOF -if { (eval echo configure:2328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4272: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4275: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4278: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4281: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then bash_cv_dirent_has_d_fileno=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - bash_cv_dirent_has_d_fileno=no + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_dirent_has_d_fileno=no fi -rm -f conftest* +rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$ac_t""$bash_cv_dirent_has_d_fileno" 1>&6 +echo "$as_me:4292: result: $bash_cv_dirent_has_d_fileno" >&5 +echo "${ECHO_T}$bash_cv_dirent_has_d_fileno" >&6 if test $bash_cv_dirent_has_d_fileno = yes; then -cat >> confdefs.h <<\EOF +cat >>confdefs.h <<\EOF #define STRUCT_DIRENT_HAS_D_FILENO 1 EOF fi - case "$host_os" in aix*) prefer_curses=yes ;; esac @@ -2352,128 +4305,224 @@ esac if test "X$bash_cv_termcap_lib" = "X"; then _bash_needmsg=yes else -echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 -echo "configure:2357: checking which library has the termcap functions" >&5 +echo "$as_me:4308: checking which library has the termcap functions" >&5 +echo $ECHO_N "checking which library has the termcap functions... $ECHO_C" >&6 _bash_needmsg= fi -if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 +if test "${bash_cv_termcap_lib+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 -echo "configure:2364: checking for tgetent in -ltermcap" >&5 -ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:4315: checking for tgetent in -ltermcap" >&5 +echo $ECHO_N "checking for tgetent in -ltermcap... $ECHO_C" >&6 +if test "${ac_cv_lib_termcap_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-ltermcap $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2372 "configure" +cat >conftest.$ac_ext <<_ACEOF +#line 4323 "configure" #include "confdefs.h" + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4342: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4345: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4348: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4351: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_termcap_tgetent=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_termcap_tgetent=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:4362: result: $ac_cv_lib_termcap_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_termcap_tgetent" >&6 +if test $ac_cv_lib_termcap_tgetent = yes; then bash_cv_termcap_lib=libtermcap else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6 -echo "configure:2402: checking for tgetent in -lcurses" >&5 -ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:4367: checking for tgetent in -ltinfo" >&5 +echo $ECHO_N "checking for tgetent in -ltinfo... $ECHO_C" >&6 +if test "${ac_cv_lib_tinfo_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" -LIBS="-lcurses $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2410 "configure" + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltinfo $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 4375 "configure" #include "confdefs.h" + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4394: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4397: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4400: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4403: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_tinfo_tgetent=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_tinfo_tgetent=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:4414: result: $ac_cv_lib_tinfo_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_tinfo_tgetent" >&6 +if test $ac_cv_lib_tinfo_tgetent = yes; then + bash_cv_termcap_lib=libtinfo +else + echo "$as_me:4419: checking for tgetent in -lcurses" >&5 +echo $ECHO_N "checking for tgetent in -lcurses... $ECHO_C" >&6 +if test "${ac_cv_lib_curses_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line 4427 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4446: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4449: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4452: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4455: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_curses_tgetent=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_curses_tgetent=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:4466: result: $ac_cv_lib_curses_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_curses_tgetent" >&6 +if test $ac_cv_lib_curses_tgetent = yes; then bash_cv_termcap_lib=libcurses else - echo "$ac_t""no" 1>&6 -echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6 -echo "configure:2440: checking for tgetent in -lncurses" >&5 -ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 + echo "$as_me:4471: checking for tgetent in -lncurses" >&5 +echo $ECHO_N "checking for tgetent in -lncurses... $ECHO_C" >&6 +if test "${ac_cv_lib_ncurses_tgetent+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_save_LIBS="$LIBS" + ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" -cat > conftest.$ac_ext <<EOF -#line 2448 "configure" +cat >conftest.$ac_ext <<_ACEOF +#line 4479 "configure" #include "confdefs.h" + /* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif /* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char tgetent(); - -int main() { -tgetent() -; return 0; } -EOF -if { (eval echo configure:2459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" + builtin and then its argument prototype would still apply. */ +char tgetent (); +int +main () +{ +tgetent (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4498: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4501: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4504: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4507: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ncurses_tgetent=yes else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_lib_ncurses_tgetent=no fi -rm -f conftest* -LIBS="$ac_save_LIBS" - +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 +echo "$as_me:4518: result: $ac_cv_lib_ncurses_tgetent" >&5 +echo "${ECHO_T}$ac_cv_lib_ncurses_tgetent" >&6 +if test $ac_cv_lib_ncurses_tgetent = yes; then bash_cv_termcap_lib=libncurses else - echo "$ac_t""no" 1>&6 -bash_cv_termcap_lib=gnutermcap + bash_cv_termcap_lib=gnutermcap +fi + fi fi @@ -2483,10 +4532,11 @@ fi fi if test "X$_bash_needmsg" = "Xyes"; then -echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 -echo "configure:2488: checking which library has the termcap functions" >&5 +echo "$as_me:4535: checking which library has the termcap functions" >&5 +echo $ECHO_N "checking which library has the termcap functions... $ECHO_C" >&6 fi -echo "$ac_t""using $bash_cv_termcap_lib" 1>&6 +echo "$as_me:4538: result: using $bash_cv_termcap_lib" >&5 +echo "${ECHO_T}using $bash_cv_termcap_lib" >&6 if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then LDFLAGS="$LDFLAGS -L./lib/termcap" TERMCAP_LIB="./lib/termcap/libtermcap.a" @@ -2494,6 +4544,9 @@ TERMCAP_DEP="./lib/termcap/libtermcap.a" elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then TERMCAP_LIB=-ltermcap TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libtinfo; then +TERMCAP_LIB=-ltinfo +TERMCAP_DEP= elif test $bash_cv_termcap_lib = libncurses; then TERMCAP_LIB=-lncurses TERMCAP_DEP= @@ -2503,11 +4556,388 @@ TERMCAP_DEP= fi if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then - TERMCAP_LIB=-ltermcap #default + if test "$prefer_curses" = yes; then + TERMCAP_LIB=-lcurses + else + TERMCAP_LIB=-ltermcap #default + fi +fi + +for ac_header in wctype.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:4569: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4575 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4579: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4585: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:4604: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +EOF + +fi +done + +for ac_header in wchar.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:4617: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4623 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4627: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4633: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:4652: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +EOF + +fi +done + +for ac_header in langinfo.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:4665: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4671 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4675: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:4681: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_ext +fi +echo "$as_me:4700: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<EOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +EOF + +fi +done + +echo "$as_me:4710: checking for mbsrtowcs" >&5 +echo $ECHO_N "checking for mbsrtowcs... $ECHO_C" >&6 +if test "${ac_cv_func_mbsrtowcs+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4716 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char mbsrtowcs (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char mbsrtowcs (); +char (*f) (); + +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_mbsrtowcs) || defined (__stub___mbsrtowcs) +choke me +#else +f = mbsrtowcs; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4747: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4750: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4753: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4756: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_mbsrtowcs=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_mbsrtowcs=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:4766: result: $ac_cv_func_mbsrtowcs" >&5 +echo "${ECHO_T}$ac_cv_func_mbsrtowcs" >&6 +if test $ac_cv_func_mbsrtowcs = yes; then + cat >>confdefs.h <<\EOF +#define HAVE_MBSRTOWCS 1 +EOF + +fi + +echo "$as_me:4775: checking for wcwidth" >&5 +echo $ECHO_N "checking for wcwidth... $ECHO_C" >&6 +if test "${ac_cv_func_wcwidth+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4781 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char wcwidth (); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char wcwidth (); +char (*f) (); + +int +main () +{ +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_wcwidth) || defined (__stub___wcwidth) +choke me +#else +f = wcwidth; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4812: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4815: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4818: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4821: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_wcwidth=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_func_wcwidth=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:4831: result: $ac_cv_func_wcwidth" >&5 +echo "${ECHO_T}$ac_cv_func_wcwidth" >&6 +if test $ac_cv_func_wcwidth = yes; then + cat >>confdefs.h <<\EOF +#define HAVE_WCWIDTH 1 +EOF + +fi + +echo "$as_me:4840: checking for mbstate_t" >&5 +echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6 +if test "${bash_cv_have_mbstate_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + { { echo "$as_me:4846: error: cannot run test program while cross compiling" >&5 +echo "$as_me: error: cannot run test program while cross compiling" >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +#line 4851 "configure" +#include "confdefs.h" + +#include <wchar.h> +int +main () +{ + mbstate_t ps; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:4863: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4866: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:4868: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4871: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_have_mbstate_t=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_have_mbstate_t=no +fi +rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:4883: result: $bash_cv_have_mbstate_t" >&5 +echo "${ECHO_T}$bash_cv_have_mbstate_t" >&6 +if test $bash_cv_have_mbstate_t = yes; then + cat >>confdefs.h <<\EOF +#define HAVE_MBSTATE_T 1 +EOF + +fi + +echo "$as_me:4892: checking for nl_langinfo and CODESET" >&5 +echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6 +if test "${bash_cv_langinfo_codeset+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 4898 "configure" +#include "confdefs.h" +#include <langinfo.h> +int +main () +{ +char* cs = nl_langinfo(CODESET); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:4910: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4913: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4916: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4919: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_langinfo_codeset=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +bash_cv_langinfo_codeset=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:4929: result: $bash_cv_langinfo_codeset" >&5 +echo "${ECHO_T}$bash_cv_langinfo_codeset" >&6 +if test $bash_cv_langinfo_codeset = yes; then + cat >>confdefs.h <<\EOF +#define HAVE_LANGINFO_CODESET 1 +EOF + fi case "$host_cpu" in *cray*) LOCAL_CFLAGS=-DCRAY ;; +*s390*) LOCAL_CFLAGS=-fsigned-char ;; esac case "$host_os" in @@ -2520,29 +4950,33 @@ esac # ${srcdir}/support/shobj-conf # if test -f ${srcdir}/support/shobj-conf; then - echo $ac_n "checking configuration for building shared libraries""... $ac_c" 1>&6 -echo "configure:2525: checking configuration for building shared libraries" >&5 + echo "$as_me:4953: checking configuration for building shared libraries" >&5 +echo $ECHO_N "checking configuration for building shared libraries... $ECHO_C" >&6 eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}` - - - - - - - - - - - - - echo "$ac_t""$SHLIB_STATUS" 1>&6 + + echo "$as_me:4957: result: $SHLIB_STATUS" >&5 +echo "${ECHO_T}$SHLIB_STATUS" >&6 + + # SHLIB_STATUS is either `supported' or `unsupported'. If it's + # `unsupported', turn off any default shared library building + if test "$SHLIB_STATUS" = 'unsupported'; then + opt_shared_libs=no + fi # shared library versioning # quoted for m4 so I can use character classes SHLIB_MAJOR=`expr "$LIBVERSION" : '\([0-9]\)\..*'` SHLIB_MINOR=`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'` - - + +fi + +if test "$opt_static_libs" = "yes"; then + STATIC_TARGET=static + STATIC_INSTALL_TARGET=install-static +fi +if test "$opt_shared_libs" = "yes"; then + SHARED_TARGET=shared + SHARED_INSTALL_TARGET=install-shared fi case "$host_os" in @@ -2550,409 +4984,882 @@ msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file *) BUILD_DIR=`pwd` ;; esac - - - - - - - - - - - - - - - - - -trap '' 1 2 15 -cat > confcache <<\EOF +ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile shlib/Makefile" +ac_config_commands="$ac_config_commands default" +cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. # -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. # -EOF +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' fi -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - DEFS=-DHAVE_CONFIG_H -# Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS <<EOF -#! /bin/sh +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:5068: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL # Generated automatically by configure. # Run this file to recreate the current configuration. -# This directory was configured as follows, -# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# -# $0 $ac_configure_args -# # Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. +# configure, is in config.log if it exists. -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option +debug=false +SHELL=\${CONFIG_SHELL-$SHELL} +ac_cs_invocation="\$0 \$@" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +exec 6>&1 + +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\EOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to <bug-autoconf@gnu.org>." +EOF + +cat >>$CONFIG_STATUS <<EOF +ac_cs_version="\\ +readline config.status 4.3 +configured by $0, generated by GNU Autoconf 2.52, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +EOF + +cat >>$CONFIG_STATUS <<\EOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 do - case "\$ac_option" in + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + shift + set dummy "$ac_option" "$ac_optarg" ${1+"$@"} + shift + ;; + -*);; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_need_defaults=false;; + esac + + case $1 in + # Handling of the options. +EOF +cat >>$CONFIG_STATUS <<EOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; + echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" + exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; +EOF +cat >>$CONFIG_STATUS <<\EOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:5244: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + shift + CONFIG_FILES="$CONFIG_FILES $1" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + shift + CONFIG_HEADERS="$CONFIG_HEADERS $1" + ac_need_defaults=false;; + + # This is an error. + -*) { { echo "$as_me:5263: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +exec 5>>config.log +cat >&5 << _ACEOF + +## ----------------------- ## +## Running config.status. ## +## ----------------------- ## + +This file was extended by $as_me (readline 4.3) 2.52, executed with + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + > $ac_cs_invocation +on `(hostname || uname -n) 2>/dev/null | sed 1q` + +_ACEOF +EOF + +cat >>$CONFIG_STATUS <<\EOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; + "shlib/Makefile" ) CONFIG_FILES="$CONFIG_FILES shlib/Makefile" ;; + "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:5304: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; esac done -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/cs$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} -trap 'rm -fr `echo "Makefile doc/Makefile examples/Makefile shlib/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF -cat >> $CONFIG_STATUS <<EOF -# Protect against being on the right side of a sed subst in config.status. -sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; - s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@CC@%$CC%g -s%@CPP@%$CPP%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@AR@%$AR%g -s%@RANLIB@%$RANLIB%g -s%@MAKE_SHELL@%$MAKE_SHELL%g -s%@SHOBJ_CC@%$SHOBJ_CC%g -s%@SHOBJ_CFLAGS@%$SHOBJ_CFLAGS%g -s%@SHOBJ_LD@%$SHOBJ_LD%g -s%@SHOBJ_LDFLAGS@%$SHOBJ_LDFLAGS%g -s%@SHOBJ_XLDFLAGS@%$SHOBJ_XLDFLAGS%g -s%@SHOBJ_LIBS@%$SHOBJ_LIBS%g -s%@SHOBJ_STATUS@%$SHOBJ_STATUS%g -s%@SHLIB_STATUS@%$SHLIB_STATUS%g -s%@SHLIB_XLDFLAGS@%$SHLIB_XLDFLAGS%g -s%@SHLIB_LIBSUFF@%$SHLIB_LIBSUFF%g -s%@SHLIB_LIBVERSION@%$SHLIB_LIBVERSION%g -s%@SHLIB_LIBS@%$SHLIB_LIBS%g -s%@SHLIB_MAJOR@%$SHLIB_MAJOR%g -s%@SHLIB_MINOR@%$SHLIB_MINOR%g -s%@BUILD_DIR@%$BUILD_DIR%g -s%@LOCAL_CFLAGS@%$LOCAL_CFLAGS%g -s%@LOCAL_LDFLAGS@%$LOCAL_LDFLAGS%g -s%@LOCAL_DEFS@%$LOCAL_DEFS%g -s%@ARFLAGS@%$ARFLAGS%g -s%@LIBVERSION@%$LIBVERSION%g -s%@TERMCAP_LIB@%$TERMCAP_LIB%g +cat >>$CONFIG_STATUS <<EOF + +# +# CONFIG_FILES section. +# +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@DEFS@,$DEFS,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@CPP@,$CPP,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@AR@,$AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@MAKE_SHELL@,$MAKE_SHELL,;t t +s,@SHOBJ_CC@,$SHOBJ_CC,;t t +s,@SHOBJ_CFLAGS@,$SHOBJ_CFLAGS,;t t +s,@SHOBJ_LD@,$SHOBJ_LD,;t t +s,@SHOBJ_LDFLAGS@,$SHOBJ_LDFLAGS,;t t +s,@SHOBJ_XLDFLAGS@,$SHOBJ_XLDFLAGS,;t t +s,@SHOBJ_LIBS@,$SHOBJ_LIBS,;t t +s,@SHOBJ_STATUS@,$SHOBJ_STATUS,;t t +s,@SHLIB_STATUS@,$SHLIB_STATUS,;t t +s,@SHLIB_XLDFLAGS@,$SHLIB_XLDFLAGS,;t t +s,@SHLIB_LIBSUFF@,$SHLIB_LIBSUFF,;t t +s,@SHLIB_LIBVERSION@,$SHLIB_LIBVERSION,;t t +s,@SHLIB_LIBS@,$SHLIB_LIBS,;t t +s,@SHLIB_MAJOR@,$SHLIB_MAJOR,;t t +s,@SHLIB_MINOR@,$SHLIB_MINOR,;t t +s,@STATIC_TARGET@,$STATIC_TARGET,;t t +s,@SHARED_TARGET@,$SHARED_TARGET,;t t +s,@STATIC_INSTALL_TARGET@,$STATIC_INSTALL_TARGET,;t t +s,@SHARED_INSTALL_TARGET@,$SHARED_INSTALL_TARGET,;t t +s,@BUILD_DIR@,$BUILD_DIR,;t t +s,@LOCAL_CFLAGS@,$LOCAL_CFLAGS,;t t +s,@LOCAL_LDFLAGS@,$LOCAL_LDFLAGS,;t t +s,@LOCAL_DEFS@,$LOCAL_DEFS,;t t +s,@ARFLAGS@,$ARFLAGS,;t t +s,@LIBVERSION@,$LIBVERSION,;t t +s,@TERMCAP_LIB@,$TERMCAP_LIB,;t t CEOF -EOF -cat >> $CONFIG_STATUS <<\EOF +EOF -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" + cat >>$CONFIG_STATUS <<\EOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <<EOF +fi # test -n "$CONFIG_FILES" -CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile examples/Makefile shlib/Makefile"} EOF -cat >> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then +cat >>$CONFIG_STATUS <<\EOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`" # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` else ac_dir_suffix= ac_dots= fi - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + case $srcdir in + .) ac_srcdir=. + if test -z "$ac_dots"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; + ac_srcdir=$ac_dots$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_dots$srcdir ;; esac - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_dots$INSTALL ;; esac - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac + if test x"$ac_file" != x-; then + { echo "$as_me:5549: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + configure_input="Generated automatically from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:5567: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:5580: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +EOF +cat >>$CONFIG_STATUS <<EOF + sed "$ac_vpsub +$extrasub +EOF +cat >>$CONFIG_STATUS <<\EOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* +done +EOF +cat >>$CONFIG_STATUS <<\EOF + +# +# CONFIG_HEADER section. +# # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' +ac_uD=',;t' -if test "${CONFIG_HEADERS+set}" != set; then -EOF -cat >> $CONFIG_STATUS <<EOF - CONFIG_HEADERS="config.h" -EOF -cat >> $CONFIG_STATUS <<\EOF -fi -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; esac - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - cat $ac_file_inputs > conftest.in + test x"$ac_file" != x- && { echo "$as_me:5641: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:5652: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:5665: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in EOF -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\EOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +cat >>conftest.undefs <<\EOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, EOF -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # egrep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail -while : +while grep . conftest.undefs >/dev/null do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\EOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated automatically by configure. */" >$tmp/config.h else - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if cmp -s $ac_file $tmp/config.h 2>/dev/null; then + { echo "$as_me:5782: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + fi + rm -f $ac_file + mv $tmp/config.h $ac_file fi - rm -f $ac_file - mv conftest.h $ac_file + else + cat $tmp/config.h + rm -f $tmp/config.h fi -fi; done - +done EOF -cat >> $CONFIG_STATUS <<EOF +cat >>$CONFIG_STATUS <<\EOF -EOF -cat >> $CONFIG_STATUS <<\EOF +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + case $ac_dest in + default ) # Makefile uses this timestamp file to record whether config.h is up to date. echo > stamp-h + ;; + esac +done +EOF -exit 0 +cat >>$CONFIG_STATUS <<\EOF + +{ (exit 0); exit 0; } EOF chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 +ac_clean_files=$ac_clean_files_save + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi diff --git a/gnu/lib/libreadline/display.c b/gnu/lib/libreadline/display.c index c26bdf44c7a..98055047354 100644 --- a/gnu/lib/libreadline/display.c +++ b/gnu/lib/libreadline/display.c @@ -43,6 +43,7 @@ /* System-specific feature definitions and include files. */ #include "rldefs.h" +#include "rlmbutil.h" /* Termcap library stuff. */ #include "tcap.h" @@ -59,14 +60,21 @@ extern char *strchr (), *strrchr (); #endif /* !strchr && !__STDC__ */ #if defined (HACK_TERMCAP_MOTION) -extern char *term_forward_char; +extern char *_rl_term_forward_char; #endif -static void update_line __P((char *, char *, int, int, int, int)); -static void space_to_eol __P((int)); -static void delete_chars __P((int)); -static void insert_some_chars __P((char *, int)); -static void cr __P((void)); +static void update_line PARAMS((char *, char *, int, int, int, int)); +static void space_to_eol PARAMS((int)); +static void delete_chars PARAMS((int)); +static void insert_some_chars PARAMS((char *, int, int)); +static void cr PARAMS((void)); + +#if defined (HANDLE_MULTIBYTE) +static int _rl_col_width PARAMS((const char *, int, int)); +static int *_rl_wrapped_line; +#else +# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s)) +#endif static int *inv_lbreaks, *vis_lbreaks; static int inv_lbsize, vis_lbsize; @@ -103,7 +111,7 @@ static int inv_lbsize, vis_lbsize; RL_DISPLAY_FIXED variable. This is good for efficiency. */ /* Application-specific redisplay function. */ -VFunction *rl_redisplay_function = rl_redisplay; +rl_voidfunc_t *rl_redisplay_function = rl_redisplay; /* Global variables declared here. */ /* What YOU turn on when you have handled all redisplay yourself. */ @@ -142,27 +150,40 @@ static int forced_display; /* Default and initial buffer size. Can grow. */ static int line_size = 1024; +/* Variables to keep track of the expanded prompt string, which may + include invisible characters. */ + static char *local_prompt, *local_prompt_prefix; -static int visible_length, prefix_length; +static int prompt_visible_length, prompt_prefix_length; /* The number of invisible characters in the line currently being displayed on the screen. */ static int visible_wrap_offset; -/* static so it can be shared between rl_redisplay and update_line */ +/* The number of invisible characters in the prompt string. Static so it + can be shared between rl_redisplay and update_line */ static int wrap_offset; -/* The index of the last invisible_character in the prompt string. */ -static int last_invisible; +/* The index of the last invisible character in the prompt string. */ +static int prompt_last_invisible; /* The length (buffer offset) of the first line of the last (possibly multi-line) buffer displayed on the screen. */ static int visible_first_line_len; +/* Number of invisible characters on the first physical line of the prompt. + Only valid when the number of physical characters in the prompt exceeds + (or is equal to) _rl_screenwidth. */ +static int prompt_invis_chars_first_line; + +static int prompt_last_screen_line; + /* Expand the prompt string S and return the number of visible characters in *LP, if LP is not null. This is currently more-or-less a placeholder for expansion. LIP, if non-null is a place to store the - index of the last invisible character in the returned string. */ + index of the last invisible character in the returned string. NIFLP, + if non-zero, is a place to store the number of invisible characters in + the first prompt line. */ /* Current implementation: \001 (^A) start non-visible characters @@ -172,12 +193,12 @@ static int visible_first_line_len; \002 are assumed to be `visible'. */ static char * -expand_prompt (pmt, lp, lip) +expand_prompt (pmt, lp, lip, niflp) char *pmt; - int *lp, *lip; + int *lp, *lip, *niflp; { char *r, *ret, *p; - int l, rl, last, ignoring; + int l, rl, last, ignoring, ninvis, invfl; /* Short-circuit if we can. */ if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0) @@ -189,9 +210,11 @@ expand_prompt (pmt, lp, lip) } l = strlen (pmt); - r = ret = xmalloc (l + 1); - - for (rl = ignoring = last = 0, p = pmt; p && *p; p++) + r = ret = (char *)xmalloc (l + 1); + + invfl = 0; /* invisible chars in first line of prompt */ + + for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++) { /* This code strips the invisible character string markers RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ @@ -211,14 +234,23 @@ expand_prompt (pmt, lp, lip) *r++ = *p; if (!ignoring) rl++; + else + ninvis++; + if (rl == _rl_screenwidth) + invfl = ninvis; } } + if (rl < _rl_screenwidth) + invfl = ninvis; + *r = '\0'; if (lp) *lp = rl; if (lip) *lip = last; + if (niflp) + *niflp = invfl; return ret; } @@ -230,7 +262,7 @@ _rl_strip_prompt (pmt) { char *ret; - ret = expand_prompt (pmt, (int *)NULL, (int *)NULL); + ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL); return ret; } @@ -242,8 +274,8 @@ _rl_strip_prompt (pmt) * (portion after the final newline) * local_prompt_prefix = portion before last newline of rl_display_prompt, * expanded via expand_prompt - * visible_length = number of visible characters in local_prompt - * prefix_length = number of visible characters in local_prompt_prefix + * prompt_visible_length = number of visible characters in local_prompt + * prompt_prefix_length = number of visible characters in local_prompt_prefix * * This function is called once per call to readline(). It may also be * called arbitrarily to expand the primary prompt. @@ -259,12 +291,11 @@ rl_expand_prompt (prompt) int c; /* Clear out any saved values. */ - if (local_prompt) - free (local_prompt); - if (local_prompt_prefix) - free (local_prompt_prefix); + FREE (local_prompt); + FREE (local_prompt_prefix); + local_prompt = local_prompt_prefix = (char *)0; - last_invisible = visible_length = 0; + prompt_last_invisible = prompt_visible_length = 0; if (prompt == 0 || *prompt == 0) return (0); @@ -272,22 +303,28 @@ rl_expand_prompt (prompt) p = strrchr (prompt, '\n'); if (!p) { - /* The prompt is only one line. */ - local_prompt = expand_prompt (prompt, &visible_length, &last_invisible); + /* The prompt is only one logical line, though it might wrap. */ + local_prompt = expand_prompt (prompt, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line); local_prompt_prefix = (char *)0; - return (visible_length); + return (prompt_visible_length); } else { /* The prompt spans multiple lines. */ t = ++p; - local_prompt = expand_prompt (p, &visible_length, &last_invisible); + local_prompt = expand_prompt (p, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line); c = *t; *t = '\0'; /* The portion of the prompt string up to and including the final newline is now null-terminated. */ - local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL); + local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, + (int *)NULL, + &prompt_invis_chars_first_line); *t = c; - return (prefix_length); + return (prompt_prefix_length); } } @@ -306,16 +343,16 @@ init_line_structures (minsize) { if (line_size < minsize) line_size = minsize; - visible_line = xmalloc (line_size); - invisible_line = xmalloc (line_size); + visible_line = (char *)xmalloc (line_size); + invisible_line = (char *)xmalloc (line_size); } else if (line_size < minsize) /* ensure it can hold MINSIZE chars */ { line_size *= 2; if (line_size < minsize) line_size = minsize; - visible_line = xrealloc (visible_line, line_size); - invisible_line = xrealloc (invisible_line, line_size); + visible_line = (char *)xrealloc (visible_line, line_size); + invisible_line = (char *)xrealloc (invisible_line, line_size); } for (n = minsize; n < line_size; n++) @@ -330,6 +367,9 @@ init_line_structures (minsize) inv_lbsize = vis_lbsize = 256; inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int)); vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int)); +#if defined (HANDLE_MULTIBYTE) + _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int)); +#endif inv_lbreaks[0] = vis_lbreaks[0] = 0; } } @@ -343,6 +383,13 @@ rl_redisplay () int c_pos, inv_botlin, lb_botlin, lb_linenum; int newlines, lpos, temp; char *prompt_this_line; +#if defined (HANDLE_MULTIBYTE) + wchar_t wc; + size_t wc_bytes; + int wc_width; + mbstate_t ps; + int _rl_wrapped_multicolumn = 0; +#endif if (!readline_echoing_p) return; @@ -392,14 +439,14 @@ rl_redisplay () if (temp >= line_size) { line_size = (temp + 1024) - (temp % 1024); - visible_line = xrealloc (visible_line, line_size); - line = invisible_line = xrealloc (invisible_line, line_size); + visible_line = (char *)xrealloc (visible_line, line_size); + line = invisible_line = (char *)xrealloc (invisible_line, line_size); } strncpy (line + out, local_prompt, local_len); out += local_len; } line[out] = '\0'; - wrap_offset = local_len - visible_length; + wrap_offset = local_len - prompt_visible_length; } else { @@ -426,13 +473,13 @@ rl_redisplay () if (temp >= line_size) { line_size = (temp + 1024) - (temp % 1024); - visible_line = xrealloc (visible_line, line_size); - line = invisible_line = xrealloc (invisible_line, line_size); + visible_line = (char *)xrealloc (visible_line, line_size); + line = invisible_line = (char *)xrealloc (invisible_line, line_size); } strncpy (line + out, prompt_this_line, pmtlen); out += pmtlen; line[out] = '\0'; - wrap_offset = 0; + wrap_offset = prompt_invis_chars_first_line = 0; } #define CHECK_INV_LBREAKS() \ @@ -443,51 +490,126 @@ rl_redisplay () inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ } \ } while (0) - + +#if defined (HANDLE_MULTIBYTE) #define CHECK_LPOS() \ do { \ lpos++; \ - if (lpos >= screenwidth) \ + if (lpos >= _rl_screenwidth) \ { \ if (newlines >= (inv_lbsize - 2)) \ { \ inv_lbsize *= 2; \ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \ } \ inv_lbreaks[++newlines] = out; \ + _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \ lpos = 0; \ } \ } while (0) +#else +#define CHECK_LPOS() \ + do { \ + lpos++; \ + if (lpos >= _rl_screenwidth) \ + { \ + if (newlines >= (inv_lbsize - 2)) \ + { \ + inv_lbsize *= 2; \ + inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + } \ + inv_lbreaks[++newlines] = out; \ + lpos = 0; \ + } \ + } while (0) +#endif /* inv_lbreaks[i] is where line i starts in the buffer. */ inv_lbreaks[newlines = 0] = 0; lpos = out - wrap_offset; +#if defined (HANDLE_MULTIBYTE) + memset (_rl_wrapped_line, 0, vis_lbsize); +#endif + + /* prompt_invis_chars_first_line is the number of invisible characters in + the first physical line of the prompt. + wrap_offset - prompt_invis_chars_first_line is the number of invis + chars on the second line. */ - /* XXX - what if lpos is already >= screenwidth before we start drawing the + /* what if lpos is already >= _rl_screenwidth before we start drawing the contents of the command line? */ - while (lpos >= screenwidth) + while (lpos >= _rl_screenwidth) { - /* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt - string with invisible characters that is longer than the screen - width. XXX - this doesn't work right if invisible characters have - to be put on the second screen line -- it adds too much (the number - of invisible chars after the screenwidth). */ - temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0); + /* fix from Darin Johnson <darin@acuson.com> for prompt string with + invisible characters that is longer than the screen width. The + prompt_invis_chars_first_line variable could be made into an array + saying how many invisible characters there are per line, but that's + probably too much work for the benefit gained. How many people have + prompts that exceed two physical lines? */ + temp = ((newlines + 1) * _rl_screenwidth) + +#if 0 + ((newlines == 0) ? prompt_invis_chars_first_line : 0) + +#else + ((newlines == 0 && local_prompt_prefix == 0) ? prompt_invis_chars_first_line : 0) + +#endif + ((newlines == 1) ? wrap_offset : 0); inv_lbreaks[++newlines] = temp; - lpos -= screenwidth; + lpos -= _rl_screenwidth; } + prompt_last_screen_line = newlines; + + /* Draw the rest of the line (after the prompt) into invisible_line, keeping + track of where the cursor is (c_pos), the number of the line containing + the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin). + It maintains an array of line breaks for display (inv_lbreaks). + This handles expanding tabs for display and displaying meta characters. */ lb_linenum = 0; +#if defined (HANDLE_MULTIBYTE) + in = 0; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + memset (&ps, 0, sizeof (mbstate_t)); + wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps); + } + else + wc_bytes = 1; + while (in < rl_end) +#else for (in = 0; in < rl_end; in++) +#endif { c = (unsigned char)rl_line_buffer[in]; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (wc_bytes == (size_t)-1 || wc_bytes == (size_t)-2) + { + /* Byte sequence is invalid or shortened. Assume that the + first byte represents a character. */ + wc_bytes = 1; + /* Assume that a character occupies a single column. */ + wc_width = 1; + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (wc_bytes == (size_t)0) + break; /* Found '\0' */ + else + { + temp = wcwidth (wc); + wc_width = (temp < 0) ? 1 : temp; + } + } +#endif + if (out + 8 >= line_size) /* XXX - 8 for \t */ { line_size *= 2; - visible_line = xrealloc (visible_line, line_size); - invisible_line = xrealloc (invisible_line, line_size); + visible_line = (char *)xrealloc (visible_line, line_size); + invisible_line = (char *)xrealloc (invisible_line, line_size); line = invisible_line; } @@ -497,15 +619,19 @@ rl_redisplay () lb_linenum = newlines; } +#if defined (HANDLE_MULTIBYTE) + if (META_CHAR (c) && _rl_output_meta_chars == 0) /* XXX - clean up */ +#else if (META_CHAR (c)) +#endif { if (_rl_output_meta_chars == 0) { snprintf (line + out, line_size - out, "\\%o", c); - if (lpos + 4 >= screenwidth) + if (lpos + 4 >= _rl_screenwidth) { - temp = screenwidth - lpos; + temp = _rl_screenwidth - lpos; CHECK_INV_LBREAKS (); inv_lbreaks[++newlines] = out + temp; lpos = 4 - temp; @@ -524,7 +650,7 @@ rl_redisplay () #if defined (DISPLAY_TABS) else if (c == '\t') { - register int temp, newout; + register int newout; #if 0 newout = (out | (int)7) + 1; @@ -532,10 +658,10 @@ rl_redisplay () newout = out + 8 - lpos % 8; #endif temp = newout - out; - if (lpos + temp >= screenwidth) + if (lpos + temp >= _rl_screenwidth) { register int temp2; - temp2 = screenwidth - lpos; + temp2 = _rl_screenwidth - lpos; CHECK_INV_LBREAKS (); inv_lbreaks[++newlines] = out + temp2; lpos = temp - temp2; @@ -550,7 +676,7 @@ rl_redisplay () } } #endif - else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up) + else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) { line[out++] = '\0'; /* XXX - sentinel */ CHECK_INV_LBREAKS (); @@ -566,9 +692,52 @@ rl_redisplay () } else { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + register int i; + + _rl_wrapped_multicolumn = 0; + + if (_rl_screenwidth < lpos + wc_width) + for (i = lpos; i < _rl_screenwidth; i++) + { + /* The space will be removed in update_line() */ + line[out++] = ' '; + _rl_wrapped_multicolumn++; + CHECK_LPOS(); + } + if (in == rl_point) + { + c_pos = out; + lb_linenum = newlines; + } + for (i = in; i < in+wc_bytes; i++) + line[out++] = rl_line_buffer[i]; + for (i = 0; i < wc_width; i++) + CHECK_LPOS(); + } + else + { + line[out++] = c; + CHECK_LPOS(); + } +#else line[out++] = c; CHECK_LPOS(); +#endif } + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + in += wc_bytes; + wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps); + } + else + in++; +#endif + } line[out] = '\0'; if (c_pos < 0) @@ -582,7 +751,8 @@ rl_redisplay () inv_lbreaks[newlines+1] = out; cursor_linenum = lb_linenum; - /* C_POS == position in buffer where cursor should be placed. */ + /* C_POS == position in buffer where cursor should be placed. + CURSOR_LINENUM == line number where the cursor should be placed. */ /* PWP: now is when things get a bit hairy. The visible and invisible line buffers are really multiple lines, which would wrap every @@ -593,7 +763,7 @@ rl_redisplay () otherwise, let long lines display in a single terminal line, and horizontally scroll it. */ - if (_rl_horizontal_scroll_mode == 0 && term_up && *term_up) + if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up) { int nleft, pos, changed_screen_line; @@ -604,8 +774,13 @@ rl_redisplay () /* If we have more than a screenful of material to display, then only display a screenful. We should display the last screen, not the first. */ - if (out >= screenchars) - out = screenchars - 1; + if (out >= _rl_screenchars) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY); + else + out = _rl_screenchars - 1; + } /* The first line is at character position 0 in the buffer. The second and subsequent lines start at inv_lbreaks[N], offset by @@ -635,7 +810,7 @@ rl_redisplay () (wrap_offset > visible_wrap_offset) && (_rl_last_c_pos < visible_first_line_len)) { - nleft = screenwidth + wrap_offset - _rl_last_c_pos; + nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos; if (nleft) _rl_clear_to_eol (nleft); } @@ -656,7 +831,7 @@ rl_redisplay () _rl_move_vert (linenum); _rl_move_cursor_relative (0, tt); _rl_clear_to_eol - ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth); + ((linenum == _rl_vis_botlin) ? strlen (tt) : _rl_screenwidth); } } _rl_vis_botlin = inv_botlin; @@ -667,7 +842,7 @@ rl_redisplay () if (changed_screen_line) { _rl_move_vert (cursor_linenum); - /* If we moved up to the line with the prompt using term_up, + /* If we moved up to the line with the prompt using _rl_term_up, the physical cursor position on the screen stays the same, but the buffer position needs to be adjusted to account for invisible characters. */ @@ -680,18 +855,21 @@ rl_redisplay () the characters from the current cursor position. But we only need to reprint it if the cursor is before the last invisible character in the prompt string. */ - nleft = visible_length + wrap_offset; + nleft = prompt_visible_length + wrap_offset; if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && - _rl_last_c_pos <= last_invisible && local_prompt) + _rl_last_c_pos <= prompt_last_invisible && local_prompt) { #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - if (term_cr) - tputs (term_cr, 1, _rl_output_character_function); + if (_rl_term_cr) + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif _rl_output_some_chars (local_prompt, nleft); - _rl_last_c_pos = nleft; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width(local_prompt, 0, nleft); + else + _rl_last_c_pos = nleft; } /* Where on that line? And where does that line start @@ -707,10 +885,15 @@ rl_redisplay () if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos) { _rl_backspace (_rl_last_c_pos - nleft); - _rl_last_c_pos = nleft; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (&visible_line[pos], 0, nleft); + else + _rl_last_c_pos = nleft; } - if (nleft != _rl_last_c_pos) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_move_cursor_relative (nleft, &invisible_line[pos]); + else if (nleft != _rl_last_c_pos) _rl_move_cursor_relative (nleft, &invisible_line[pos]); } } @@ -727,11 +910,11 @@ rl_redisplay () /* The number of characters that will be displayed before the cursor. */ ndisp = c_pos - wrap_offset; - nleft = visible_length + wrap_offset; + nleft = prompt_visible_length + wrap_offset; /* Where the new cursor position will be on the screen. This can be longer than SCREENWIDTH; if it is, lmargin will be adjusted. */ phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset); - t = screenwidth / 3; + t = _rl_screenwidth / 3; /* If the number of characters had already exceeded the screenwidth, last_lmargin will be > 0. */ @@ -739,7 +922,7 @@ rl_redisplay () /* If the number of characters to be displayed is more than the screen width, compute the starting offset so that the cursor is about two-thirds of the way across the screen. */ - if (phys_c_pos > screenwidth - 2) + if (phys_c_pos > _rl_screenwidth - 2) { lmargin = c_pos - (2 * t); if (lmargin < 0) @@ -749,7 +932,7 @@ rl_redisplay () if (wrap_offset && lmargin > 0 && lmargin < nleft) lmargin = nleft; } - else if (ndisp < screenwidth - 2) /* XXX - was -1 */ + else if (ndisp < _rl_screenwidth - 2) /* XXX - was -1 */ lmargin = 0; else if (phys_c_pos < 1) { @@ -771,7 +954,7 @@ rl_redisplay () the whole line, indicate that with a special character at the right edge of the screen. If LMARGIN is 0, we need to take the wrap offset into account. */ - t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth; + t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth; if (t < out) line[t - 1] = '>'; @@ -781,8 +964,8 @@ rl_redisplay () update_line (&visible_line[last_lmargin], &invisible_line[lmargin], 0, - screenwidth + visible_wrap_offset, - screenwidth + (lmargin ? 0 : wrap_offset), + _rl_screenwidth + visible_wrap_offset, + _rl_screenwidth + (lmargin ? 0 : wrap_offset), 0); /* If the visible new line is shorter than the old, but the number @@ -793,12 +976,12 @@ rl_redisplay () (_rl_last_c_pos == out) && t < visible_first_line_len) { - nleft = screenwidth - t; + nleft = _rl_screenwidth - t; _rl_clear_to_eol (nleft); } visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset); - if (visible_first_line_len > screenwidth) - visible_first_line_len = screenwidth; + if (visible_first_line_len > _rl_screenwidth) + visible_first_line_len = _rl_screenwidth; _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); last_lmargin = lmargin; @@ -808,11 +991,11 @@ rl_redisplay () /* Swap visible and non-visible lines. */ { - char *temp = visible_line; + char *vtemp = visible_line; int *itemp = vis_lbreaks, ntemp = vis_lbsize; visible_line = invisible_line; - invisible_line = temp; + invisible_line = vtemp; vis_lbreaks = inv_lbreaks; inv_lbreaks = itemp; @@ -855,6 +1038,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) register char *ofd, *ols, *oe, *nfd, *nls, *ne; int temp, lendiff, wsatend, od, nd; int current_invis_chars; + int col_lendiff, col_temp; +#if defined (HANDLE_MULTIBYTE) + mbstate_t ps_new, ps_old; + int new_offset, old_offset, tmp; +#endif /* If we're at the right edge of a terminal that supports xn, we're ready to wrap around, so do so. This fixes problems with knowing @@ -862,20 +1050,98 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) emulators. In this calculation, TEMP is the physical screen position of the cursor. */ temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); - if (temp == screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode - && _rl_last_v_pos == current_line - 1) + if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode + && _rl_last_v_pos == current_line - 1) { - if (new[0]) - putc (new[0], rl_outstream); +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + wchar_t wc; + mbstate_t ps; + int tempwidth, bytes; + size_t ret; + + /* This fixes only double-column characters, but if the wrapped + character comsumes more than three columns, spaces will be + inserted in the string buffer. */ + if (_rl_wrapped_line[current_line] > 0) + _rl_clear_to_eol (_rl_wrapped_line[current_line]); + + memset (&ps, 0, sizeof (mbstate_t)); + ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps); + if (ret == (size_t)-1 || ret == (size_t)-2) + { + tempwidth = 1; + ret = 1; + } + else if (ret == 0) + tempwidth = 0; + else + tempwidth = wcwidth (wc); + + if (tempwidth > 0) + { + int count; + bytes = ret; + for (count = 0; count < bytes; count++) + putc (new[count], rl_outstream); + _rl_last_c_pos = tempwidth; + _rl_last_v_pos++; + memset (&ps, 0, sizeof (mbstate_t)); + ret = mbrtowc (&wc, old, MB_CUR_MAX, &ps); + if (ret != 0 && bytes != 0) + { + if (ret == (size_t)-1 || ret == (size_t)-2) + memmove (old+bytes, old+1, strlen (old+1)); + else + memmove (old+bytes, old+ret, strlen (old+ret)); + memcpy (old, new, bytes); + } + } + else + { + putc (' ', rl_outstream); + _rl_last_c_pos = 1; + _rl_last_v_pos++; + if (old[0] && new[0]) + old[0] = new[0]; + } + } else - putc (' ', rl_outstream); - _rl_last_c_pos = 1; /* XXX */ - _rl_last_v_pos++; - if (old[0] && new[0]) - old[0] = new[0]; +#endif + { + if (new[0]) + putc (new[0], rl_outstream); + else + putc (' ', rl_outstream); + _rl_last_c_pos = 1; /* XXX */ + _rl_last_v_pos++; + if (old[0] && new[0]) + old[0] = new[0]; + } } + /* Find first difference. */ +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + memset (&ps_new, 0, sizeof(mbstate_t)); + memset (&ps_old, 0, sizeof(mbstate_t)); + + new_offset = old_offset = 0; + for (ofd = old, nfd = new; + (ofd - old < omax) && *ofd && + _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); ) + { + old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY); + new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY); + ofd = old + old_offset; + nfd = new + new_offset; + } + } + else +#endif for (ofd = old, nfd = new; (ofd - old < omax) && *ofd && (*ofd == *nfd); ofd++, nfd++) @@ -892,6 +1158,33 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) return; wsatend = 1; /* flag for trailing whitespace */ + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY); + nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY); + while ((ols > ofd) && (nls > nfd)) + { + memset (&ps_old, 0, sizeof (mbstate_t)); + memset (&ps_new, 0, sizeof (mbstate_t)); + + _rl_adjust_point (old, ols - old, &ps_old); + _rl_adjust_point (new, nls - new, &ps_new); + + if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0) + break; + + if (*ols == ' ') + wsatend = 0; + + ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY); + nls = new + _rl_find_prev_mbchar (new, nls - new, MB_FIND_ANY); + } + } + else + { +#endif /* HANDLE_MULTIBYTE */ ols = oe - 1; /* find last same */ nls = ne - 1; while ((ols > ofd) && (nls > nfd) && (*ols == *nls)) @@ -901,18 +1194,38 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) ols--; nls--; } +#if defined (HANDLE_MULTIBYTE) + } +#endif if (wsatend) { ols = oe; nls = ne; } +#if defined (HANDLE_MULTIBYTE) + /* This may not work for stateful encoding, but who cares? To handle + stateful encoding properly, we have to scan each string from the + beginning and compare. */ + else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0) +#else else if (*ols != *nls) +#endif { if (*ols) /* don't step past the NUL */ - ols++; + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + ols = old + _rl_find_next_mbchar (old, ols - old, 1, MB_FIND_ANY); + else + ols++; + } if (*nls) - nls++; + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + nls = new + _rl_find_next_mbchar (new, nls - new, 1, MB_FIND_ANY); + else + nls++; + } } /* count of invisible characters in the current invisible line. */ @@ -939,33 +1252,59 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) lendiff = local_prompt ? strlen (local_prompt) : 0; od = ofd - old; /* index of first difference in visible line */ if (current_line == 0 && !_rl_horizontal_scroll_mode && - term_cr && lendiff > visible_length && _rl_last_c_pos > 0 && - od > lendiff && _rl_last_c_pos < last_invisible) + _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 && + od >= lendiff && _rl_last_c_pos <= prompt_last_invisible) { #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - tputs (term_cr, 1, _rl_output_character_function); + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif _rl_output_some_chars (local_prompt, lendiff); - _rl_last_c_pos = lendiff; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff); + else + _rl_last_c_pos = lendiff; } _rl_move_cursor_relative (od, old); - /* if (len (new) > len (old)) */ + /* if (len (new) > len (old)) + lendiff == difference in buffer + col_lendiff == difference on screen + When not using multibyte characters, these are equal */ lendiff = (nls - nfd) - (ols - ofd); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old); + else + col_lendiff = lendiff; /* If we are changing the number of invisible characters in a line, and the spot of first difference is before the end of the invisible chars, lendiff needs to be adjusted. */ if (current_line == 0 && !_rl_horizontal_scroll_mode && current_invis_chars != visible_wrap_offset) - lendiff += visible_wrap_offset - current_invis_chars; + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + lendiff += visible_wrap_offset - current_invis_chars; + col_lendiff += visible_wrap_offset - current_invis_chars; + } + else + { + lendiff += visible_wrap_offset - current_invis_chars; + col_lendiff = lendiff; + } + } /* Insert (diff (len (old), len (new)) ch. */ temp = ne - nfd; - if (lendiff > 0) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_temp = _rl_col_width (new, nfd - new, ne - new); + else + col_temp = temp; + + if (col_lendiff > 0) /* XXX - was lendiff */ { /* Non-zero if we're increasing the number of lines. */ int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin; @@ -973,17 +1312,17 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) use the terminal's capabilities. If we're growing the number of lines, make sure we actually cause the new line to wrap around on auto-wrapping terminals. */ - if (terminal_can_insert && ((2 * temp) >= lendiff || term_IC) && (!_rl_term_autowrap || !gl)) + if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl)) { - /* If lendiff > visible_length and _rl_last_c_pos == 0 and + /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and _rl_horizontal_scroll_mode == 1, inserting the characters with - term_IC or term_ic will screw up the screen because of the + _rl_term_IC or _rl_term_ic will screw up the screen because of the invisible characters. We need to just draw them. */ if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 || - lendiff <= visible_length || !current_invis_chars)) + lendiff <= prompt_visible_length || !current_invis_chars)) { - insert_some_chars (nfd, lendiff); - _rl_last_c_pos += lendiff; + insert_some_chars (nfd, lendiff, col_lendiff); + _rl_last_c_pos += col_lendiff; } else if (*ols == 0) { @@ -992,7 +1331,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) /* However, this screws up the rest of this block, which assumes you've done the insert because you can. */ _rl_output_some_chars (nfd, lendiff); - _rl_last_c_pos += lendiff; + _rl_last_c_pos += col_lendiff; } else { @@ -1000,7 +1339,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) the end. We have invisible characters in this line. This is a dumb update. */ _rl_output_some_chars (nfd, temp); - _rl_last_c_pos += temp; + _rl_last_c_pos += col_temp; return; } /* Copy (new) chars to screen from first diff to last match. */ @@ -1008,37 +1347,41 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if ((temp - lendiff) > 0) { _rl_output_some_chars (nfd + lendiff, temp - lendiff); - _rl_last_c_pos += temp - lendiff; +#if 0 + _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff); +#else + _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff); +#endif } } else { /* cannot insert chars, write to EOL */ _rl_output_some_chars (nfd, temp); - _rl_last_c_pos += temp; + _rl_last_c_pos += col_temp; } } else /* Delete characters from line. */ { /* If possible and inexpensive to use terminal deletion, then do so. */ - if (term_dc && (2 * temp) >= -lendiff) + if (_rl_term_dc && (2 * col_temp) >= -col_lendiff) { /* If all we're doing is erasing the invisible characters in the prompt string, don't bother. It screws up the assumptions about what's on the screen. */ if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 && -lendiff == visible_wrap_offset) - lendiff = 0; + col_lendiff = 0; - if (lendiff) - delete_chars (-lendiff); /* delete (diff) characters */ + if (col_lendiff) + delete_chars (-col_lendiff); /* delete (diff) characters */ /* Copy (new) chars to screen from first diff to last match */ temp = nls - nfd; if (temp > 0) { _rl_output_some_chars (nfd, temp); - _rl_last_c_pos += temp; + _rl_last_c_pos += _rl_col_width (nfd, 0, temp);; } } /* Otherwise, print over the existing material. */ @@ -1047,15 +1390,20 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (temp > 0) { _rl_output_some_chars (nfd, temp); - _rl_last_c_pos += temp; + _rl_last_c_pos += col_temp; } lendiff = (oe - old) - (ne - new); - if (lendiff) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new); + else + col_lendiff = lendiff; + + if (col_lendiff) { if (_rl_term_autowrap && current_line < inv_botlin) - space_to_eol (lendiff); + space_to_eol (col_lendiff); else - _rl_clear_to_eol (lendiff); + _rl_clear_to_eol (col_lendiff); } } } @@ -1101,12 +1449,15 @@ rl_on_new_line_with_prompt () prompt_last_line = rl_prompt; l = strlen (prompt_last_line); - _rl_last_c_pos = l; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); + else + _rl_last_c_pos = l; /* Dissect prompt_last_line into screen lines. Note that here we have to use the real screenwidth. Readline's notion of screenwidth might be one less, see terminal.c. */ - real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1); + real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1); _rl_last_v_pos = l / real_screenwidth; /* If the prompt length is a multiple of real_screenwidth, we don't know whether the cursor is at the end of the last line, or already at the @@ -1151,24 +1502,38 @@ rl_forced_update_display () void _rl_move_cursor_relative (new, data) int new; - char *data; + const char *data; { register int i; /* If we don't have to do anything, then return. */ +#if defined (HANDLE_MULTIBYTE) + /* If we have multibyte characters, NEW is indexed by the buffer point in + a multibyte string, but _rl_last_c_pos is the display position. In + this case, NEW's display position is not obvious and must be + calculated. */ + if (MB_CUR_MAX == 1 || rl_byte_oriented) + { + if (_rl_last_c_pos == new) + return; + } + else if (_rl_last_c_pos == _rl_col_width (data, 0, new)) + return; +#else if (_rl_last_c_pos == new) return; +#endif /* It may be faster to output a CR, and then move forwards instead of moving backwards. */ /* i == current physical cursor position. */ i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset); if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || - (_rl_term_autowrap && i == screenwidth)) + (_rl_term_autowrap && i == _rl_screenwidth)) { #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - tputs (term_cr, 1, _rl_output_character_function); + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif /* !__MSDOS__ */ _rl_last_c_pos = 0; } @@ -1185,20 +1550,66 @@ _rl_move_cursor_relative (new, data) That kind of control is for people who don't know what the data is underneath the cursor. */ #if defined (HACK_TERMCAP_MOTION) - if (term_forward_char) + if (_rl_term_forward_char) + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int width; + width = _rl_col_width (data, _rl_last_c_pos, new); + for (i = 0; i < width; i++) + tputs (_rl_term_forward_char, 1, _rl_output_character_function); + } + else + { + for (i = _rl_last_c_pos; i < new; i++) + tputs (_rl_term_forward_char, 1, _rl_output_character_function); + } + } + else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + tputs (_rl_term_cr, 1, _rl_output_character_function); + for (i = 0; i < new; i++) + putc (data[i], rl_outstream); + } + else for (i = _rl_last_c_pos; i < new; i++) - tputs (term_forward_char, 1, _rl_output_character_function); + putc (data[i], rl_outstream); + +#else /* !HACK_TERMCAP_MOTION */ + + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + tputs (_rl_term_cr, 1, _rl_output_character_function); + for (i = 0; i < new; i++) + putc (data[i], rl_outstream); + } else for (i = _rl_last_c_pos; i < new; i++) putc (data[i], rl_outstream); -#else - for (i = _rl_last_c_pos; i < new; i++) - putc (data[i], rl_outstream); -#endif /* HACK_TERMCAP_MOTION */ + +#endif /* !HACK_TERMCAP_MOTION */ + } +#if defined (HANDLE_MULTIBYTE) + /* NEW points to the buffer point, but _rl_last_c_pos is the display point. + The byte length of the string is probably bigger than the column width + of the string, which means that if NEW == _rl_last_c_pos, then NEW's + display point is less than _rl_last_c_pos. */ + else if (_rl_last_c_pos >= new) +#else else if (_rl_last_c_pos > new) - _rl_backspace (_rl_last_c_pos - new); - _rl_last_c_pos = new; +#endif + { + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_backspace (_rl_last_c_pos - _rl_col_width (data, 0, new)); + else + _rl_backspace (_rl_last_c_pos - new); + } + + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + _rl_last_c_pos = _rl_col_width (data, 0, new); + else + _rl_last_c_pos = new; } /* PWP: move the cursor up or down. */ @@ -1208,7 +1619,7 @@ _rl_move_vert (to) { register int delta, i; - if (_rl_last_v_pos == to || to > screenheight) + if (_rl_last_v_pos == to || to > _rl_screenheight) return; if ((delta = to - _rl_last_v_pos) > 0) @@ -1218,15 +1629,15 @@ _rl_move_vert (to) #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - tputs (term_cr, 1, _rl_output_character_function); + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif _rl_last_c_pos = 0; } else { /* delta < 0 */ - if (term_up && *term_up) + if (_rl_term_up && *_rl_term_up) for (i = 0; i < -delta; i++) - tputs (term_up, 1, _rl_output_character_function); + tputs (_rl_term_up, 1, _rl_output_character_function); } _rl_last_v_pos = to; /* Now TO is here */ @@ -1285,7 +1696,7 @@ rl_character_len (c, pos) if (CTRL_CHAR (c) || c == RUBOUT) return (2); - return ((isprint (uc)) ? 1 : 2); + return ((ISPRINT (uc)) ? 1 : 2); } /* How to print things in the "echo-area". The prompt is treated as a @@ -1312,7 +1723,12 @@ rl_message (va_alist) format = va_arg (args, char *); #endif - vsnprintf (msg_buf, sizeof(msg_buf), format, args); +#if defined (HAVE_VSNPRINTF) + vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args); +#else + vsprintf (msg_buf, format, args); + msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */ +#endif va_end (args); rl_display_prompt = msg_buf; @@ -1360,25 +1776,23 @@ rl_save_prompt () { saved_local_prompt = local_prompt; saved_local_prefix = local_prompt_prefix; - saved_last_invisible = last_invisible; - saved_visible_length = visible_length; + saved_last_invisible = prompt_last_invisible; + saved_visible_length = prompt_visible_length; local_prompt = local_prompt_prefix = (char *)0; - last_invisible = visible_length = 0; + prompt_last_invisible = prompt_visible_length = 0; } void rl_restore_prompt () { - if (local_prompt) - free (local_prompt); - if (local_prompt_prefix) - free (local_prompt_prefix); + FREE (local_prompt); + FREE (local_prompt_prefix); local_prompt = saved_local_prompt; local_prompt_prefix = saved_local_prefix; - last_invisible = saved_last_invisible; - visible_length = saved_visible_length; + prompt_last_invisible = saved_last_invisible; + prompt_visible_length = saved_visible_length; } char * @@ -1393,7 +1807,7 @@ _rl_make_prompt_for_search (pchar) if (saved_local_prompt == 0) { len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; - pmt = xmalloc (len + 2); + pmt = (char *)xmalloc (len + 2); if (len) strlcpy (pmt, rl_prompt, len + 2); pmt[len] = pchar; @@ -1402,14 +1816,14 @@ _rl_make_prompt_for_search (pchar) else { len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; - pmt = xmalloc (len + 2); + pmt = (char *)xmalloc (len + 2); if (len) strlcpy (pmt, saved_local_prompt, len + 2); pmt[len] = pchar; pmt[len+1] = '\0'; local_prompt = savestring (pmt); - last_invisible = saved_last_invisible; - visible_length = saved_visible_length + 1; + prompt_last_invisible = saved_last_invisible; + prompt_visible_length = saved_visible_length + 1; } return pmt; } @@ -1436,8 +1850,8 @@ void _rl_clear_to_eol (count) int count; { - if (term_clreol) - tputs (term_clreol, 1, _rl_output_character_function); + if (_rl_term_clreol) + tputs (_rl_term_clreol, 1, _rl_output_character_function); else if (count) space_to_eol (count); } @@ -1459,23 +1873,29 @@ space_to_eol (count) void _rl_clear_screen () { - if (term_clrpag) - tputs (term_clrpag, 1, _rl_output_character_function); + if (_rl_term_clrpag) + tputs (_rl_term_clrpag, 1, _rl_output_character_function); else - crlf (); + rl_crlf (); } -/* Insert COUNT characters from STRING to the output stream. */ +/* Insert COUNT characters from STRING to the output stream at column COL. */ static void -insert_some_chars (string, count) +insert_some_chars (string, count, col) char *string; - int count; + int count, col; { + /* DEBUGGING */ + if (MB_CUR_MAX == 1 || rl_byte_oriented) + if (count != col) + fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col); + /* If IC is defined, then we do not have to "enter" insert mode. */ - if (term_IC) + if (_rl_term_IC) { char *buffer; - buffer = tgoto (term_IC, 0, count); + + buffer = tgoto (_rl_term_IC, 0, col); tputs (buffer, 1, _rl_output_character_function); _rl_output_some_chars (string, count); } @@ -1484,15 +1904,15 @@ insert_some_chars (string, count) register int i; /* If we have to turn on insert-mode, then do so. */ - if (term_im && *term_im) - tputs (term_im, 1, _rl_output_character_function); + if (_rl_term_im && *_rl_term_im) + tputs (_rl_term_im, 1, _rl_output_character_function); /* If there is a special command for inserting characters, then use that first to open up the space. */ - if (term_ic && *term_ic) + if (_rl_term_ic && *_rl_term_ic) { - for (i = count; i--; ) - tputs (term_ic, 1, _rl_output_character_function); + for (i = col; i--; ) + tputs (_rl_term_ic, 1, _rl_output_character_function); } /* Print the text. */ @@ -1500,8 +1920,8 @@ insert_some_chars (string, count) /* If there is a string to turn off insert mode, we had best use it now. */ - if (term_ei && *term_ei) - tputs (term_ei, 1, _rl_output_character_function); + if (_rl_term_ei && *_rl_term_ei) + tputs (_rl_term_ei, 1, _rl_output_character_function); } } @@ -1510,20 +1930,20 @@ static void delete_chars (count) int count; { - if (count > screenwidth) /* XXX */ + if (count > _rl_screenwidth) /* XXX */ return; - if (term_DC && *term_DC) + if (_rl_term_DC && *_rl_term_DC) { char *buffer; - buffer = tgoto (term_DC, count, count); + buffer = tgoto (_rl_term_DC, count, count); tputs (buffer, count, _rl_output_character_function); } else { - if (term_dc && *term_dc) + if (_rl_term_dc && *_rl_term_dc) while (count--) - tputs (term_dc, 1, _rl_output_character_function); + tputs (_rl_term_dc, 1, _rl_output_character_function); } } @@ -1543,20 +1963,17 @@ _rl_update_final () } _rl_move_vert (_rl_vis_botlin); /* If we've wrapped lines, remove the final xterm line-wrap flag. */ - if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth)) + if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth)) { char *last_line; -#if 0 - last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]]; -#else + last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; -#endif - _rl_move_cursor_relative (screenwidth - 1, last_line); + _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); _rl_clear_to_eol (0); - putc (last_line[screenwidth - 1], rl_outstream); + putc (last_line[_rl_screenwidth - 1], rl_outstream); } _rl_vis_botlin = 0; - crlf (); + rl_crlf (); fflush (rl_outstream); rl_display_fixed++; } @@ -1565,12 +1982,12 @@ _rl_update_final () static void cr () { - if (term_cr) + if (_rl_term_cr) { #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - tputs (term_cr, 1, _rl_output_character_function); + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif _rl_last_c_pos = 0; } @@ -1584,27 +2001,31 @@ redraw_prompt (t) char *t; { char *oldp, *oldl, *oldlprefix; - int oldlen, oldlast, oldplen; + int oldlen, oldlast, oldplen, oldninvis; /* Geez, I should make this a struct. */ oldp = rl_display_prompt; oldl = local_prompt; oldlprefix = local_prompt_prefix; - oldlen = visible_length; - oldplen = prefix_length; - oldlast = last_invisible; + oldlen = prompt_visible_length; + oldplen = prompt_prefix_length; + oldlast = prompt_last_invisible; + oldninvis = prompt_invis_chars_first_line; rl_display_prompt = t; - local_prompt = expand_prompt (t, &visible_length, &last_invisible); + local_prompt = expand_prompt (t, &prompt_visible_length, + &prompt_last_invisible, + &prompt_invis_chars_first_line); local_prompt_prefix = (char *)NULL; rl_forced_update_display (); rl_display_prompt = oldp; local_prompt = oldl; local_prompt_prefix = oldlprefix; - visible_length = oldlen; - prefix_length = oldplen; - last_invisible = oldlast; + prompt_visible_length = oldlen; + prompt_prefix_length = oldplen; + prompt_last_invisible = oldlast; + prompt_invis_chars_first_line = oldninvis; } /* Redisplay the current line after a SIGWINCH is received. */ @@ -1615,31 +2036,31 @@ _rl_redisplay_after_sigwinch () /* Clear the current line and put the cursor at column 0. Make sure the right thing happens if we have wrapped to a new screen line. */ - if (term_cr) + if (_rl_term_cr) { #if defined (__MSDOS__) putc ('\r', rl_outstream); #else - tputs (term_cr, 1, _rl_output_character_function); + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif _rl_last_c_pos = 0; #if defined (__MSDOS__) - space_to_eol (screenwidth); + space_to_eol (_rl_screenwidth); putc ('\r', rl_outstream); #else - if (term_clreol) - tputs (term_clreol, 1, _rl_output_character_function); + if (_rl_term_clreol) + tputs (_rl_term_clreol, 1, _rl_output_character_function); else { - space_to_eol (screenwidth); - tputs (term_cr, 1, _rl_output_character_function); + space_to_eol (_rl_screenwidth); + tputs (_rl_term_cr, 1, _rl_output_character_function); } #endif if (_rl_last_v_pos > 0) _rl_move_vert (0); } else - crlf (); + rl_crlf (); /* Redraw only the last line of a multi-line prompt. */ t = strrchr (rl_display_prompt, '\n'); @@ -1680,14 +2101,97 @@ _rl_current_display_line () /* Find out whether or not there might be invisible characters in the editing buffer. */ if (rl_display_prompt == rl_prompt) - nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length; + nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length; else - nleft = _rl_last_c_pos - screenwidth; + nleft = _rl_last_c_pos - _rl_screenwidth; if (nleft > 0) - ret = 1 + nleft / screenwidth; + ret = 1 + nleft / _rl_screenwidth; else ret = 0; return ret; } + +#if defined (HANDLE_MULTIBYTE) +/* Calculate the number of screen columns occupied by STR from START to END. + In the case of multibyte characters with stateful encoding, we have to + scan from the beginning of the string to take the state into account. */ +static int +_rl_col_width (str, start, end) + const char *str; + int start, end; +{ + wchar_t wc; + mbstate_t ps = {0}; + int tmp, point, width, max; + + if (end <= start) + return 0; + + point = 0; + max = end; + + while (point < start) + { + tmp = mbrlen (str + point, max, &ps); + if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2) + { + /* In this case, the bytes are invalid or too short to compose a + multibyte character, so we assume that the first byte represents + a single character. */ + point++; + max--; + + /* Clear the state of the byte sequence, because in this case the + effect of mbstate is undefined. */ + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (tmp == 0) + break; /* Found '\0' */ + else + { + point += tmp; + max -= tmp; + } + } + + /* If START is not a byte that starts a character, then POINT will be + greater than START. In this case, assume that (POINT - START) gives + a byte count that is the number of columns of difference. */ + width = point - start; + + while (point < end) + { + tmp = mbrtowc (&wc, str + point, max, &ps); + if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2) + { + /* In this case, the bytes are invalid or too short to compose a + multibyte character, so we assume that the first byte represents + a single character. */ + point++; + max--; + + /* and assume that the byte occupies a single column. */ + width++; + + /* Clear the state of the byte sequence, because in this case the + effect of mbstate is undefined. */ + memset (&ps, 0, sizeof (mbstate_t)); + } + else if (tmp == 0) + break; /* Found '\0' */ + else + { + point += tmp; + max -= tmp; + tmp = wcwidth(wc); + width += (tmp >= 0) ? tmp : 1; + } + } + + width += point - end; + + return width; +} +#endif /* HANDLE_MULTIBYTE */ diff --git a/gnu/lib/libreadline/doc/hist.texinfo b/gnu/lib/libreadline/doc/hist.texinfo index ae95e5086fc..7230377ead2 100644 --- a/gnu/lib/libreadline/doc/hist.texinfo +++ b/gnu/lib/libreadline/doc/hist.texinfo @@ -18,7 +18,7 @@ This document describes the GNU History library, a programming tool that provides a consistent user interface for recalling lines of previously typed input. -Copyright (C) 1988-1999 Free Software Foundation, Inc. +Copyright (C) 1988-2002 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -73,7 +73,7 @@ except that this permission notice may be stated in a translation approved by the Free Software Foundation. @vskip 0pt plus 1filll -Copyright @copyright{} 1988-1999 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2002 Free Software Foundation, Inc. @end titlepage @ifinfo diff --git a/gnu/lib/libreadline/doc/hstech.texinfo b/gnu/lib/libreadline/doc/hstech.texinfo index a58516800da..c4feefc1527 100644 --- a/gnu/lib/libreadline/doc/hstech.texinfo +++ b/gnu/lib/libreadline/doc/hstech.texinfo @@ -1,7 +1,7 @@ @ignore This file documents the user interface to the GNU History library. -Copyright (C) 1988, 1991, 1994, 1996 Free Software Foundation, Inc. +Copyright (C) 1988-2002 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. Permission is granted to make and distribute verbatim copies of this manual @@ -27,9 +27,9 @@ into another language, under the above conditions for modified versions. @chapter Programming with GNU History This chapter describes how to interface programs that you write -with the GNU History Library. +with the @sc{gnu} History Library. It should be considered a technical guide. -For information on the interactive use of GNU History, @pxref{Using +For information on the interactive use of @sc{gnu} History, @pxref{Using History Interactively}. @menu @@ -43,10 +43,10 @@ History Interactively}. @node Introduction to History @section Introduction to History -Many programs read input from the user a line at a time. The GNU History -library is able to keep track of those lines, associate arbitrary data with -each line, and utilize information from previous lines in composing new -ones. +Many programs read input from the user a line at a time. The @sc{gnu} +History library is able to keep track of those lines, associate arbitrary +data with each line, and utilize information from previous lines in +composing new ones. The programmer using the History library has available functions for remembering lines on a history list, associating arbitrary data @@ -80,9 +80,11 @@ The history list is an array of history entries. A history entry is declared as follows: @example +typedef void *histdata_t; + typedef struct _hist_entry @{ char *line; - char *data; + histdata_t data; @} HIST_ENTRY; @end example @@ -95,12 +97,14 @@ HIST_ENTRY **the_history_list; The state of the History library is encapsulated into a single structure: @example -/* A structure used to pass the current state of the history stuff around. */ +/* + * A structure used to pass around the current state of the history. + */ typedef struct _hist_state @{ - HIST_ENTRY **entries; /* Pointer to the entries themselves. */ - int offset; /* The location pointer within this array. */ - int length; /* Number of elements within this array. */ - int size; /* Number of slots allocated to this array. */ + HIST_ENTRY **entries; /* Pointer to the entries themselves. */ + int offset; /* The location pointer within this array. */ + int length; /* Number of elements within this array. */ + int size; /* Number of slots allocated to this array. */ int flags; @} HISTORY_STATE; @end example @@ -112,7 +116,7 @@ stifled. @section History Functions This section describes the calling sequence for the various functions -present in GNU History. +exported by the @sc{gnu} History library. @menu * Initializing History and State Management:: Functions to call when you @@ -139,12 +143,12 @@ This section describes functions used to initialize and manage the state of the History library when you want to use the history functions in your program. -@deftypefun void using_history () +@deftypefun void using_history (void) Begin a session in which the history functions might be used. This initializes the interactive variables. @end deftypefun -@deftypefun {HISTORY_STATE *} history_get_history_state () +@deftypefun {HISTORY_STATE *} history_get_history_state (void) Return a structure describing the current state of the input history. @end deftypefun @@ -158,7 +162,7 @@ Set the state of the history list according to @var{state}. These functions manage individual entries on the history list, or set parameters managing the list itself. -@deftypefun void add_history (char *string) +@deftypefun void add_history (const char *string) Place @var{string} at the end of the history list. The associated data field (if any) is set to @code{NULL}. @end deftypefun @@ -169,13 +173,13 @@ removed element is returned so you can free the line, data, and containing structure. @end deftypefun -@deftypefun {HIST_ENTRY *} replace_history_entry (int which, char *line, char *data) +@deftypefun {HIST_ENTRY *} replace_history_entry (int which, const char *line, histdata_t data) Make the history entry at offset @var{which} have @var{line} and @var{data}. This returns the old entry so you can dispose of the data. In the case of an invalid @var{which}, a @code{NULL} pointer is returned. @end deftypefun -@deftypefun void clear_history () +@deftypefun void clear_history (void) Clear the history list by deleting all the entries. @end deftypefun @@ -183,13 +187,14 @@ Clear the history list by deleting all the entries. Stifle the history list, remembering only the last @var{max} entries. @end deftypefun -@deftypefun int unstifle_history () -Stop stifling the history. This returns the previous amount the -history was stifled. The value is positive if the history was +@deftypefun int unstifle_history (void) +Stop stifling the history. This returns the previously-set +maximum number of history entries (as set by @code{stifle_history()}). +The value is positive if the history was stifled, negative if it wasn't. @end deftypefun -@deftypefun int history_is_stifled () +@deftypefun int history_is_stifled (void) Returns non-zero if the history is stifled, zero if it is not. @end deftypefun @@ -199,29 +204,30 @@ Returns non-zero if the history is stifled, zero if it is not. These functions return information about the entire history list or individual list entries. -@deftypefun {HIST_ENTRY **} history_list () -Return a @code{NULL} terminated array of @code{HIST_ENTRY} which is the +@deftypefun {HIST_ENTRY **} history_list (void) +Return a @code{NULL} terminated array of @code{HIST_ENTRY *} which is the current input history. Element 0 of this list is the beginning of time. If there is no history, return @code{NULL}. @end deftypefun -@deftypefun int where_history () +@deftypefun int where_history (void) Returns the offset of the current history element. @end deftypefun -@deftypefun {HIST_ENTRY *} current_history () +@deftypefun {HIST_ENTRY *} current_history (void) Return the history entry at the current position, as determined by -@code{where_history ()}. If there is no entry there, return a @code{NULL} +@code{where_history()}. If there is no entry there, return a @code{NULL} pointer. @end deftypefun @deftypefun {HIST_ENTRY *} history_get (int offset) Return the history entry at position @var{offset}, starting from -@code{history_base}. If there is no entry there, or if @var{offset} +@code{history_base} (@pxref{History Variables}). +If there is no entry there, or if @var{offset} is greater than the history length, return a @code{NULL} pointer. @end deftypefun -@deftypefun int history_total_bytes () +@deftypefun int history_total_bytes (void) Return the number of bytes that the primary history entries are using. This function returns the sum of the lengths of all the lines in the history. @@ -234,17 +240,19 @@ These functions allow the current index into the history list to be set or changed. @deftypefun int history_set_pos (int pos) -Set the position in the history list to @var{pos}, an absolute index +Set the current history offset to @var{pos}, an absolute index into the list. +Returns 1 on success, 0 if @var{pos} is less than zero or greater +than the number of history entries. @end deftypefun -@deftypefun {HIST_ENTRY *} previous_history () +@deftypefun {HIST_ENTRY *} previous_history (void) Back up the current history offset to the previous history entry, and return a pointer to that entry. If there is no previous entry, return a @code{NULL} pointer. @end deftypefun -@deftypefun {HIST_ENTRY *} next_history () +@deftypefun {HIST_ENTRY *} next_history (void) Move the current history offset forward to the next history entry, and return the a pointer to that entry. If there is no next entry, return a @code{NULL} pointer. @@ -260,26 +268,28 @@ from the current history position. The search may be @dfn{anchored}, meaning that the string must match at the beginning of the history entry. @cindex anchored search -@deftypefun int history_search (char *string, int direction) -Search the history for @var{string}, starting at the current history -offset. If @var{direction} < 0, then the search is through previous entries, -else through subsequent. If @var{string} is found, then +@deftypefun int history_search (const char *string, int direction) +Search the history for @var{string}, starting at the current history offset. +If @var{direction} is less than 0, then the search is through +previous entries, otherwise through subsequent entries. +If @var{string} is found, then the current history index is set to that history entry, and the value returned is the offset in the line of the entry where @var{string} was found. Otherwise, nothing is changed, and a -1 is returned. @end deftypefun -@deftypefun int history_search_prefix (char *string, int direction) +@deftypefun int history_search_prefix (const char *string, int direction) Search the history for @var{string}, starting at the current history offset. The search is anchored: matching lines must begin with -@var{string}. If @var{direction} < 0, then the search is through previous -entries, else through subsequent. If @var{string} is found, then the +@var{string}. If @var{direction} is less than 0, then the search is +through previous entries, otherwise through subsequent entries. +If @var{string} is found, then the current history index is set to that entry, and the return value is 0. Otherwise, nothing is changed, and a -1 is returned. @end deftypefun -@deftypefun int history_search_pos (char *string, int direction, int pos) +@deftypefun int history_search_pos (const char *string, int direction, int pos) Search for @var{string} in the history list, starting at @var{pos}, an absolute index into the list. If @var{direction} is negative, the search proceeds backward from @var{pos}, otherwise forward. Returns the absolute @@ -292,41 +302,46 @@ index of the history element where @var{string} was found, or -1 otherwise. The History library can read the history from and write it to a file. This section documents the functions for managing a history file. -@deftypefun int read_history (char *filename) -Add the contents of @var{filename} to the history list, a line at a -time. If @var{filename} is @code{NULL}, then read from -@file{~/.history}. Returns 0 if successful, or errno if not. +@deftypefun int read_history (const char *filename) +Add the contents of @var{filename} to the history list, a line at a time. +If @var{filename} is @code{NULL}, then read from @file{~/.history}. +Returns 0 if successful, or @code{errno} if not. @end deftypefun -@deftypefun int read_history_range (char *filename, int from, int to) +@deftypefun int read_history_range (const char *filename, int from, int to) Read a range of lines from @var{filename}, adding them to the history list. -Start reading at line @var{from} and end at @var{to}. If -@var{from} is zero, start at the beginning. If @var{to} is less than +Start reading at line @var{from} and end at @var{to}. +If @var{from} is zero, start at the beginning. If @var{to} is less than @var{from}, then read until the end of the file. If @var{filename} is @code{NULL}, then read from @file{~/.history}. Returns 0 if successful, or @code{errno} if not. @end deftypefun -@deftypefun int write_history (char *filename) +@deftypefun int write_history (const char *filename) Write the current history to @var{filename}, overwriting @var{filename} -if necessary. If @var{filename} is -@code{NULL}, then write the history list to @file{~/.history}. Values -returned are as in @code{read_history ()}. +if necessary. +If @var{filename} is @code{NULL}, then write the history list to +@file{~/.history}. +Returns 0 on success, or @code{errno} on a read or write error. @end deftypefun -@deftypefun int append_history (int nelements, char *filename) +@deftypefun int append_history (int nelements, const char *filename) Append the last @var{nelements} of the history list to @var{filename}. +If @var{filename} is @code{NULL}, then append to @file{~/.history}. +Returns 0 on success, or @code{errno} on a read or write error. @end deftypefun -@deftypefun int history_truncate_file (char *filename, int nlines) +@deftypefun int history_truncate_file (const char *filename, int nlines) Truncate the history file @var{filename}, leaving only the last @var{nlines} lines. +If @var{filename} is @code{NULL}, then @file{~/.history} is truncated. +Returns 0 on success, or @code{errno} on failure. @end deftypefun @node History Expansion @subsection History Expansion -These functions implement @code{csh}-like history expansion. +These functions implement history expansion. @deftypefun int history_expand (char *string, char **output) Expand @var{string}, placing the result into @var{output}, a pointer @@ -334,7 +349,7 @@ to a string (@pxref{History Interaction}). Returns: @table @code @item 0 If no expansions took place (or, if the only change in -the text was the de-slashifying of the history expansion +the text was the removal of escape characters preceding the history expansion character); @item 1 if expansions did take place; @@ -349,12 +364,7 @@ If an error ocurred in expansion, then @var{output} contains a descriptive error message. @end deftypefun -@deftypefun {char *} history_arg_extract (int first, int last, char *string) -Extract a string segment consisting of the @var{first} through @var{last} -arguments present in @var{string}. Arguments are broken up as in Bash. -@end deftypefun - -@deftypefun {char *} get_history_event (char *string, int *cindex, int qchar) +@deftypefun {char *} get_history_event (const char *string, int *cindex, int qchar) Returns the text of the history event beginning at @var{string} + @var{*cindex}. @var{*cindex} is modified to point to after the event specifier. At function entry, @var{cindex} points to the index into @@ -363,18 +373,24 @@ is a character that is allowed to end the event specification in addition to the ``normal'' terminating characters. @end deftypefun -@deftypefun {char **} history_tokenize (char *string) +@deftypefun {char **} history_tokenize (const char *string) Return an array of tokens parsed out of @var{string}, much as the -shell might. The tokens are split on white space and on the -characters @code{()<>;&|$}, and shell quoting conventions are -obeyed. +shell might. The tokens are split on the characters in the +@var{history_word_delimiters} variable, +and shell quoting conventions are obeyed. +@end deftypefun + +@deftypefun {char *} history_arg_extract (int first, int last, const char *string) +Extract a string segment consisting of the @var{first} through @var{last} +arguments present in @var{string}. Arguments are split using +@code{history_tokenize}. @end deftypefun @node History Variables @section History Variables -This section describes the externally visible variables exported by -the GNU History Library. +This section describes the externally-visible variables exported by +the @sc{gnu} History Library. @deftypevar int history_base The logical offset of the first entry in the history list. @@ -384,13 +400,14 @@ The logical offset of the first entry in the history list. The number of entries currently stored in the history list. @end deftypevar -@deftypevar int max_input_history +@deftypevar int history_max_entries The maximum number of history entries. This must be changed using -@code{stifle_history ()}. +@code{stifle_history()}. @end deftypevar @deftypevar char history_expansion_char -The character that starts a history event. The default is @samp{!}. +The character that introduces a history event. The default is @samp{!}. +Setting this to 0 inhibits history expansion. @end deftypevar @deftypevar char history_subst_char @@ -405,15 +422,20 @@ ignored, suppressing history expansion for the remainder of the line. This is disabled by default. @end deftypevar +@deftypevar {char *} history_word_delimiters +The characters that separate tokens for @code{history_tokenize()}. +The default value is @code{" \t\n()<>;&|"}. +@end deftypevar + @deftypevar {char *} history_no_expand_chars The list of characters which inhibit history expansion if found immediately -following @var{history_expansion_char}. The default is whitespace and -@samp{=}. +following @var{history_expansion_char}. The default is space, tab, newline, +carriage return, and @samp{=}. @end deftypevar @deftypevar {char *} history_search_delimiter_chars The list of additional characters which can delimit a history search -string, in addition to whitespace, @samp{:} and @samp{?} in the case of +string, in addition to space, TAB, @samp{:} and @samp{?} in the case of a substring search. The default is empty. @end deftypevar @@ -422,24 +444,30 @@ If non-zero, single-quoted words are not scanned for the history expansion character. The default value is 0. @end deftypevar -@deftypevar {Function *} history_inhibit_expansion_function +@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function This should be set to the address of a function that takes two arguments: -a @code{char *} (@var{string}) and an integer index into that string (@var{i}). +a @code{char *} (@var{string}) +and an @code{int} index into that string (@var{i}). It should return a non-zero value if the history expansion starting at @var{string}[@var{i}] should not be performed; zero if the expansion should be done. It is intended for use by applications like Bash that use the history expansion character for additional purposes. -By default, this variable is set to NULL. +By default, this variable is set to @code{NULL}. @end deftypevar @node History Programming Example @section History Programming Example -The following program demonstrates simple use of the GNU History Library. +The following program demonstrates simple use of the @sc{gnu} History Library. @smallexample -main () +#include <stdio.h> +#include <readline/history.h> + +main (argc, argv) + int argc; + char **argv; @{ char line[1024], *t; int len, done = 0; diff --git a/gnu/lib/libreadline/doc/readline.3 b/gnu/lib/libreadline/doc/readline.3 index eb5be2a1179..afd6ba29362 100644 --- a/gnu/lib/libreadline/doc/readline.3 +++ b/gnu/lib/libreadline/doc/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet@ins.CWRU.Edu .\" -.\" Last Change: Tue Jun 1 13:28:03 EDT 1999 +.\" Last Change: Tue Jan 22 09:18:25 EST 2002 .\" -.TH READLINE 3 "1999 Jun 1" GNU +.TH READLINE 3 "2002 January 22" "GNU Readline 4.3" .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -29,14 +29,13 @@ readline \- get a line from a user with editing .fi .LP .nf -.ft B -char *readline (prompt) -char *prompt; -.ft +\fIchar *\fP +.br +\fBreadline\fP (\fIconst char *prompt\fP); .fi .SH COPYRIGHT -.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. -.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc. +.if n Readline is Copyright (C) 1989\-2002 by the Free Software Foundation, Inc. +.if t Readline is Copyright \(co 1989\-2002 by the Free Software Foundation, Inc. .SH DESCRIPTION .LP .B readline @@ -45,9 +44,10 @@ and return it, using .B prompt as a prompt. If .B prompt -is null, no prompt is issued. The line returned is allocated with -.IR malloc (3), -so the caller must free it when finished. The line returned +is \fBNULL\fP or the empty string, no prompt is issued. +The line returned is allocated with +.IR malloc (3); +the caller must free it when finished. The line returned has the final newline removed, so only the text of the line remains. .LP @@ -57,6 +57,11 @@ line. By default, the line editing commands are similar to those of emacs. A vi\-style line editing interface is also available. +.LP +This manual page describes only the most basic use of \fBreadline\fP. +Much more functionality is available; see +\fIThe GNU Readline Library\fP and \fIThe GNU History Library\fP +for additional information. .SH RETURN VALUE .LP .B readline @@ -130,6 +135,7 @@ or .RS C\-Meta\-u: universal\-argument .RE +.sp into the .I inputrc would make M\-C\-u execute the readline command @@ -137,15 +143,16 @@ would make M\-C\-u execute the readline command .PP The following symbolic character names are recognized while processing key bindings: -.IR RUBOUT , .IR DEL , .IR ESC , +.IR ESCAPE , .IR LFD , .IR NEWLINE , .IR RET , .IR RETURN , -.IR SPC , +.IR RUBOUT , .IR SPACE , +.IR SPC , and .IR TAB . .PP @@ -161,6 +168,7 @@ command or the text of a macro and a key sequence to which it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP prefixes, or as a key sequence. +.PP When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP, .I keyname is the name of a key spelled out in English. For example: @@ -170,7 +178,7 @@ Control\-u: universal\-argument .br Meta\-Rubout: backward\-kill\-word .br -Control\-o: ">&output" +Control\-o: "> output" .RE .LP In the above example, @@ -184,7 +192,8 @@ and .I C\-o is bound to run the macro expressed on the right hand side (that is, to insert the text -.I >&output +.if t \f(CW> output\fP +.if n ``> output'' into the line). .PP In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, @@ -194,7 +203,8 @@ differs from above in that strings denoting an entire key sequence may be specified by placing the sequence within double quotes. Some GNU Emacs style key escapes can be -used, as in the following example. +used, as in the following example, but the symbolic character names +are not recognized. .sp .RS "\eC\-u": universal\-argument @@ -214,8 +224,11 @@ is bound to the function and .I "ESC [ 1 1 ~" is bound to insert the text -.BR "Function Key 1" . -The full set of GNU Emacs style escape sequences is +.if t \f(CWFunction Key 1\fP. +.if n ``Function Key 1''. +.PP +The full set of GNU Emacs style escape sequences available when specifying +key sequences is .RS .PD 0 .TP @@ -232,10 +245,10 @@ an escape character backslash .TP .B \e" -literal " +literal ", a double quote .TP .B \e' -literal ' +literal ', a single quote .RE .PD .PP @@ -269,12 +282,12 @@ horizontal tab vertical tab .TP .B \e\fInnn\fP -the character whose ASCII code is the octal value \fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP (one to three digits) .TP -.B \ex\fInnn\fP -the character whose ASCII code is the hexadecimal value \fInnn\fP -(one to three digits) +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) .RE .PD .PP @@ -313,7 +326,8 @@ file with a statement of the form Except where noted, readline variables can take the values .B On or -.BR Off . +.B Off +(without regard to case). The variables and their default values are: .PP .PD 0 @@ -351,7 +365,7 @@ on the terminal. .B convert\-meta (On) If set to \fBOn\fP, readline will convert characters with the eighth bit set to an ASCII key sequence -by stripping the eighth bit and prepending an +by stripping the eighth bit and prefixing it with an escape character (in effect, using escape as the \fImeta prefix\fP). .TP .B disable\-completion (Off) @@ -361,7 +375,7 @@ mapped to \fBself-insert\fP. .TP .B editing\-mode (emacs) Controls whether readline begins with a set of key bindings similar -to \fIemacs\fP or \fIvi\fP. +to emacs or vi. .B editing\-mode can be set to either .B emacs @@ -377,6 +391,11 @@ arrow keys. If set to \fBon\fP, tilde expansion is performed when readline attempts word completion. .TP +.B history-preserve-point +If set to \fBon\fP, the history code attempts to place point at the +same location on each history line retrived with \fBprevious-history\fP +or \fBnext-history\fP. +.TP .B horizontal\-scroll\-mode (Off) When set to \fBOn\fP, makes readline use a single line for display, scrolling the input horizontally on a single screen line when it @@ -384,12 +403,12 @@ becomes longer than the screen width rather than wrapping to a new line. .TP .B input\-meta (Off) If set to \fBOn\fP, readline will enable eight-bit input (that is, -it will not strip the high bit from the characters it reads), +it will not clear the eighth bit in the characters it reads), regardless of what the terminal claims it can support. The name .B meta\-flag is a synonym for this variable. .TP -.B isearch\-terminators (``C\-[C\-J'') +.B isearch\-terminators (``C\-[ C\-J'') The string of characters that should terminate an incremental search without subsequently executing the character as a command. If this variable has not been given a value, the characters @@ -402,24 +421,39 @@ vi-command\fP, and .IR vi-insert . \fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is equivalent to \fIemacs-standard\fP. The default value is -.IR emacs ; -the value of +.IR emacs . +The value of .B editing\-mode also affects the default keymap. .TP .B mark\-directories (On) -If set to \fBOn\fP, complete<d directory names have a slash +If set to \fBOn\fP, completed directory names have a slash appended. .TP .B mark\-modified\-lines (Off) If set to \fBOn\fP, history lines that have been modified are displayed with a preceding asterisk (\fB*\fP). .TP +.B mark\-symlinked\-directories (Off) +If set to \fBOn\fP, completed names which are symbolic links to directories +have a slash appended (subject to the value of +\fBmark\-directories\fP). +.TP +.B match\-hidden\-files (On) +This variable, when set to \fBOn\fP, causes readline to match files whose +names begin with a `.' (hidden files) when performing filename +completion, unless the leading `.' is +supplied by the user in the filename to be completed. +.TP .B output\-meta (Off) If set to \fBOn\fP, readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. .TP +.B page\-completions (On) +If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager +to display a screenful of possible completions at a time. +.TP .B print\-completions\-horizontally (Off) If set to \fBOn\fP, readline will display completions with matches sorted horizontally in alphabetical order, rather than down the screen. @@ -433,7 +467,7 @@ matches to be listed immediately instead of ringing the bell. .TP .B visible\-stats (Off) If set to \fBOn\fP, a character denoting a file's type as reported -by \fBstat\fP(2) is appended to the filename when listing possible +by \fIstat\fP(2) is appended to the filename when listing possible completions. .PD .SS Conditional Constructs @@ -481,7 +515,7 @@ key sequence that quotes the current or previous word in Bash: .sp 1 .RS .nf -\fB$if\fP bash +\fB$if\fP Bash # Quote the current or previous word "\eC-xq": "\eeb\e"\eef\e"" \fB$endif\fP @@ -519,22 +553,27 @@ As each character of the search string is typed, readline displays the next entry from the history matching the string typed so far. An incremental search requires only as many characters as needed to find the desired history entry. -The characters present in the value of the \fIisearch-terminators\fP +To search backward in the history for a particular string, type +\fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history. +The characters present in the value of the \fBisearch-terminators\fP variable are used to terminate an incremental search. -If that variable has not been assigned a value the Escape and -Control-J characters will terminate an incremental search. -Control-G will abort an incremental search and restore the original +If that variable has not been assigned a value the \fIEscape\fP and +\fBC\-J\fP characters will terminate an incremental search. +\fBC\-G\fP will abort an incremental search and restore the original line. When the search is terminated, the history entry containing the search string becomes the current line. -To find other matching entries in the history list, type Control-S or -Control-R as appropriate. +.PP +To find other matching entries in the history list, type \fBC\-s\fP or +\fBC\-r\fP as appropriate. This will search backward or forward in the history for the next line matching the search string typed so far. Any other key sequence bound to a readline command will terminate the search and execute that command. -For instance, a \fInewline\fP will terminate the search and accept +For instance, a newline will terminate the search and accept the line, thereby executing the command from the history list. +A movement command will terminate the search, make the last line found +the current line, and begin editing. .PP Non-incremental searches read the entire search string before starting to search for matching history lines. The search string may be @@ -544,6 +583,11 @@ typed by the user or be part of the contents of the current line. The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accompanying key sequence are unbound by default. +.PP +In the following descriptions, \fIpoint\fP refers to the current cursor +position, and \fImark\fP refers to a cursor position saved by the +\fBset\-mark\fP command. +The text between the point and mark is referred to as the \fIregion\fP. .SS Commands for Moving .PP .PD 0 @@ -581,9 +625,11 @@ Refresh the current line. .PD 0 .TP .B accept\-line (Newline, Return) -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list. If the line is a modified -history line, then restore the history line to its original state. +Accept the line regardless of where the cursor is. +If this line is +non-empty, it may be added to the history list for future recall with +\fBadd_history()\fP. +If the line is a modified history line, the history line is restored to its original state. .TP .B previous\-history (C\-p) Fetch the previous command from the history list, moving back in @@ -629,8 +675,8 @@ This is a non-incremental search. .TP .B yank\-nth\-arg (M\-C\-y) Insert the first argument to the previous command (usually -the second word on the previous line) at point (the current -cursor position). With an argument +the second word on the previous line) at point. +With an argument .IR n , insert the \fIn\fPth word from the previous command (the words in the previous command begin with word 0). A negative argument @@ -649,9 +695,9 @@ list, inserting the last argument of each line in turn. .PD 0 .TP .B delete\-char (C\-d) -Delete the character under the cursor. If point is at the +Delete the character at point. If point is at the beginning of the line, there are no characters in the line, and -the last character typed was not bound to \fBBdelete\-char\fP, then return +the last character typed was not bound to \fBdelete\-char\fP, then return .SM .BR EOF . .TP @@ -662,7 +708,7 @@ save the deleted text on the kill ring. .B forward\-backward\-delete\-char Delete the character under the cursor, unless the cursor is at the end of the line, in which case the character behind the cursor is -deleted. By default, this is not bound to a key. +deleted. .TP .B quoted\-insert (C\-q, C\-v) Add the next character that you type to the line verbatim. This is @@ -675,13 +721,17 @@ Insert a tab character. Insert the character typed. .TP .B transpose\-chars (C\-t) -Drag the character before point forward over the character at point. -Point moves forward as well. If point is at the end of the line, then -transpose the two characters before point. Negative arguments don't work. +Drag the character before point forward over the character at point, +moving point forward as well. +If point is at the end of the line, then this transposes +the two characters before point. +Negative arguments have no effect. .TP .B transpose\-words (M\-t) -Drag the word behind the cursor past the word in front of the cursor -moving the cursor over that word as well. +Drag the word before point past the word after point, +moving point over that word as well. +If point is at the end of the line, this transposes +the last two words on the line. .TP .B upcase\-word (M\-u) Uppercase the current (or following) word. With a negative argument, @@ -694,13 +744,24 @@ lowercase the previous word, but do not move point. .B capitalize\-word (M\-c) Capitalize the current (or following) word. With a negative argument, capitalize the previous word, but do not move point. +.TP +.B overwrite\-mode +Toggle overwrite mode. With an explicit positive numeric argument, +switches to overwrite mode. With an explicit non-positive numeric +argument, switches to insert mode. This command affects only +\fBemacs\fP mode; \fBvi\fP mode does overwrite differently. +Each call to \fIreadline()\fP starts in insert mode. +In overwrite mode, characters bound to \fBself\-insert\fP replace +the text at point rather than pushing the text to the right. +Characters bound to \fBbackward\-delete\-char\fP replace the character +before point with a space. By default, this command is unbound. .PD .SS Killing and Yanking .PP .PD 0 .TP .B kill\-line (C\-k) -Kill the text from the current cursor position to the end of the line. +Kill the text from point to the end of the line. .TP .B backward\-kill\-line (C\-x Rubout) Kill backward to the beginning of the line. @@ -711,22 +772,20 @@ The killed text is saved on the kill-ring. .\" There is no real difference between this and backward-kill-line .TP .B kill\-whole\-line -Kill all characters on the current line, no matter where the -cursor is. +Kill all characters on the current line, no matter where point is. .TP .B kill\-word (M\-d) -Kill from the cursor to the end of the current word, or if between +Kill from point the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as those used by \fBforward\-word\fP. .TP .B backward\-kill\-word (M\-Rubout) -Kill the word behind the cursor. Word boundaries are the same as -those used by \fBbackward\-word\fP. +Kill the word behind point. +Word boundaries are the same as those used by \fBbackward\-word\fP. .TP .B unix\-word\-rubout (C\-w) -Kill the word behind the cursor, using white space as a word boundary. -The word boundaries are different from -.BR backward\-kill\-word . +Kill the word behind point, using white space as a word boundary. +The killed text is saved on the kill-ring. .TP .B delete\-horizontal\-space (M\-\e) Delete all spaces and tabs around point. @@ -747,7 +806,7 @@ Copy the word following point to the kill buffer. The word boundaries are the same as \fBforward\-word\fP. .TP .B yank (C\-y) -Yank the top of the kill ring into the buffer at the cursor. +Yank the top of the kill ring into the buffer at point. .TP .B yank\-pop (M\-y) Rotate the kill ring, and yank the new top. Only works following @@ -808,8 +867,9 @@ Similar to \fBcomplete\fP, but replaces the word to be completed with a single match from the list of possible completions. Repeated execution of \fBmenu\-complete\fP steps through the list of possible completions, inserting each match in turn. -At the end of the list of completions, the bell is rung and the -original text is restored. +At the end of the list of completions, the bell is rung +(subject to the setting of \Bbell\-style\fP) +and the original text is restored. An argument of \fIn\fP moves \fIn\fP positions forward in the list of matches; a negative argument may be used to move backward through the list. @@ -821,7 +881,6 @@ Deletes the character under the cursor if not at the beginning or end of the line (like \fBdelete-char\fP). If at the end of the line, behaves identically to \fBpossible-completions\fP. -This command is unbound by default. .PD .SS Keyboard Macros .PP @@ -874,8 +933,8 @@ command enough times to return the line to its initial state. .B tilde\-expand (M\-&) Perform tilde expansion on the current word. .TP -.B set\-mark (C\-@, M-<space>) -Set the mark to the current point. If a +.B set\-mark (C\-@, M\-<space>) +Set the mark to the point. If a numeric argument is supplied, the mark is set to that position. .TP .B exchange\-point\-and\-mark (C\-x C\-x) @@ -891,11 +950,20 @@ A character is read and point is moved to the previous occurrence of that character. A negative count searches for subsequent occurrences. .TP .B insert\-comment (M\-#) -The value of the readline +Without a numeric argument, the value of the readline +.B comment\-begin +variable is inserted at the beginning of the current line. +If a numeric argument is supplied, this command acts as a toggle: if +the characters at the beginning of the line do not match the value +of \fBcomment\-begin\fP, the value is inserted, otherwise +the characters in \fBcomment-begin\fP are deleted from the beginning of +the line. +In either case, the line is accepted as if a newline had been typed. +The default value of .B comment\-begin -variable is inserted at the beginning of the current line, and the line -is accepted as if a newline had been typed. This makes the current line -a shell comment. +makes the current line a shell comment. +If a numeric argument causes the comment character to be removed, the line +will be executed by the shell. .TP .B dump\-functions Print all of the functions and their key bindings to the @@ -918,7 +986,7 @@ of an \fIinputrc\fP file. .B emacs\-editing\-mode (C\-e) When in .B vi -editing mode, this causes a switch to +command mode, this causes a switch to .B emacs editing mode. .TP @@ -932,25 +1000,23 @@ editing mode. .SH DEFAULT KEY BINDINGS .LP The following is a list of the default emacs and vi bindings. -Characters with the 8th bit set are written as M\-<character>, and +Characters with the eighth bit set are written as M\-<character>, and are referred to as .I metafied characters. The printable ASCII characters not mentioned in the list of emacs standard bindings are bound to the -.I self\-insert +.B self\-insert function, which just inserts the given character into the input line. In vi insertion mode, all characters not specifically mentioned are bound to -.IR self\-insert . +.BR self\-insert . Characters assigned to signal generation by .IR stty (1) or the terminal driver, such as C-Z or C-C, retain that function. -Upper and lower case -.I metafied -characters are bound to the same function in the emacs mode -meta keymap. +Upper and lower case metafied characters are bound to the same function in +the emacs mode meta keymap. The remaining characters are unbound, which causes readline to ring the bell (subject to the setting of the .B bell\-style @@ -1036,7 +1102,7 @@ Emacs Meta bindings "M-Y" yank-pop "M-\e" delete-horizontal-space "M-~" tilde-expand -"M-C-?" backward-delete-word +"M-C-?" backward-kill-word "M-_" yank-last-arg .PP Emacs Control-X bindings @@ -1096,6 +1162,7 @@ VI Command Mode functions "C-V" quoted-insert "C-W" unix-word-rubout "C-Y" yank +"C-_" vi-undo "\^ " forward-char "#" insert-comment "$" end-of-line @@ -1150,7 +1217,7 @@ VI Command Mode functions "r" vi-change-char "s" vi-subst "t" vi-char-search -"u" undo +"u" vi-undo "w" vi-next-word "x" vi-delete "y" vi-yank-to diff --git a/gnu/lib/libreadline/doc/rltech.texinfo b/gnu/lib/libreadline/doc/rltech.texinfo index fc19b174033..08986d5837b 100644 --- a/gnu/lib/libreadline/doc/rltech.texinfo +++ b/gnu/lib/libreadline/doc/rltech.texinfo @@ -8,7 +8,7 @@ This document describes the GNU Readline Library, a utility for aiding in the consitency of user interface across discrete programs that need to provide a command line interface. -Copyright (C) 1988, 1994, 1996, 1998, 1999 Free Software Foundation, Inc. +Copyright (C) 1988-2002 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -33,9 +33,9 @@ by the Foundation. @node Programming with GNU Readline @chapter Programming with GNU Readline -This chapter describes the interface between the GNU Readline Library and +This chapter describes the interface between the @sc{gnu} Readline Library and other programs. If you are a programmer, and you wish to include the -features found in GNU Readline +features found in @sc{gnu} Readline such as completion, line editing, and interactive history manipulation in your own programs, this section is for you. @@ -59,18 +59,20 @@ Many programs provide a command line interface, such as @code{mail}, @code{ftp}, and @code{sh}. For such programs, the default behaviour of Readline is sufficient. This section describes how to use Readline in the simplest way possible, perhaps to replace calls in your code to -@code{gets()} or @code{fgets ()}. +@code{gets()} or @code{fgets()}. @findex readline @cindex readline, function -The function @code{readline ()} prints a prompt and then reads and returns -a single line of text from the user. The line @code{readline} -returns is allocated with @code{malloc ()}; you should @code{free ()} -the line when you are done with it. The declaration for @code{readline} -in ANSI C is + +The function @code{readline()} prints a prompt @var{prompt} +and then reads and returns a single line of text from the user. +If @var{prompt} is @code{NULL} or the empty string, no prompt is displayed. +The line @code{readline} returns is allocated with @code{malloc()}; +the caller should @code{free()} the line when it has finished with it. +The declaration for @code{readline} in ANSI C is @example -@code{char *readline (char *@var{prompt});} +@code{char *readline (const char *@var{prompt});} @end example @noindent @@ -88,7 +90,7 @@ line is empty at that point, then @code{(char *)NULL} is returned. Otherwise, the line is ended just as if a newline had been typed. If you want the user to be able to get at the line later, (with -@key{C-p} for example), you must call @code{add_history ()} to save the +@key{C-p} for example), you must call @code{add_history()} to save the line away in a @dfn{history} list of such lines. @example @@ -100,19 +102,20 @@ For full details on the GNU History Library, see the associated manual. It is preferable to avoid saving empty lines on the history list, since users rarely have a burning need to reuse a blank line. Here is -a function which usefully replaces the standard @code{gets ()} library +a function which usefully replaces the standard @code{gets()} library function, and has the advantage of no static buffer to overflow: @example /* A static variable for holding the line. */ static char *line_read = (char *)NULL; -/* Read a string, and return a pointer to it. Returns NULL on EOF. */ +/* Read a string, and return a pointer to it. + Returns NULL on EOF. */ char * rl_gets () @{ - /* If the buffer has already been allocated, return the memory - to the free pool. */ + /* If the buffer has already been allocated, + return the memory to the free pool. */ if (line_read) @{ free (line_read); @@ -122,7 +125,8 @@ rl_gets () /* Get a line from the user. */ line_read = readline (""); - /* If the line has any text in it, save it on the history. */ + /* If the line has any text in it, + save it on the history. */ if (line_read && *line_read) add_history (line_read); @@ -133,17 +137,17 @@ rl_gets () This function gives the user the default behaviour of @key{TAB} completion: completion on file names. If you do not want Readline to complete on filenames, you can change the binding of the @key{TAB} key -with @code{rl_bind_key ()}. +with @code{rl_bind_key()}. @example -@code{int rl_bind_key (int @var{key}, int (*@var{function})());} +@code{int rl_bind_key (int @var{key}, rl_command_func_t *@var{function});} @end example -@code{rl_bind_key ()} takes two arguments: @var{key} is the character that +@code{rl_bind_key()} takes two arguments: @var{key} is the character that you want to bind, and @var{function} is the address of the function to -call when @var{key} is pressed. Binding @key{TAB} to @code{rl_insert ()} +call when @var{key} is pressed. Binding @key{TAB} to @code{rl_insert()} makes @key{TAB} insert itself. -@code{rl_bind_key ()} returns non-zero if @var{key} is not a valid +@code{rl_bind_key()} returns non-zero if @var{key} is not a valid ASCII character code (between 0 and 255). Thus, to disable the default @key{TAB} behavior, the following suffices: @@ -152,7 +156,7 @@ Thus, to disable the default @key{TAB} behavior, the following suffices: @end example This code should be executed once at the start of your program; you -might write a function called @code{initialize_readline ()} which +might write a function called @code{initialize_readline()} which performs this and other desired initializations, such as installing custom completers (@pxref{Custom Completers}). @@ -172,45 +176,82 @@ in any file that uses Readline's features. Since some of the definitions in @code{readline.h} use the @code{stdio} library, the file @code{<stdio.h>} should be included before @code{readline.h}. +@code{readline.h} defines a C preprocessor variable that should +be treated as an integer, @code{RL_READLINE_VERSION}, which may +be used to conditionally compile application code depending on +the installed Readline version. The value is a hexadecimal +encoding of the major and minor version numbers of the library, +of the form 0x@var{MMmm}. @var{MM} is the two-digit major +version number; @var{mm} is the two-digit minor version number. +For Readline 4.2, for example, the value of +@code{RL_READLINE_VERSION} would be @code{0x0402}. + @menu -* The Function Type:: C declarations to make code readable. +* Readline Typedefs:: C declarations to make code readable. * Function Writing:: Variables and calling conventions. @end menu -@node The Function Type -@subsection The Function Type +@node Readline Typedefs +@subsection Readline Typedefs -For readabilty, we declare a new type of object, called -@dfn{Function}. A @code{Function} is a C function which -returns an @code{int}. The type declaration for @code{Function} is: +For readabilty, we declare a number of new object types, all pointers +to functions. -@noindent -@code{typedef int Function ();} +The reason for declaring these new types is to make it easier to write +code describing pointers to C functions with appropriately prototyped +arguments and return values. -The reason for declaring this new type is to make it easier to write -code describing pointers to C functions. Let us say we had a variable -called @var{func} which was a pointer to a function. Instead of the -classic C declaration +For instance, say we want to declare a variable @var{func} as a pointer +to a function which takes two @code{int} arguments and returns an +@code{int} (this is the type of all of the Readline bindable functions). +Instead of the classic C declaration -@code{int (*)()func;} +@code{int (*func)();} @noindent -we may write +or the ANSI-C style declaration -@code{Function *func;} +@code{int (*func)(int, int);} @noindent -Similarly, there are +we may write -@example -typedef void VFunction (); -typedef char *CPFunction (); @r{and} -typedef char **CPPFunction (); -@end example +@code{rl_command_func_t *func;} -@noindent -for functions returning no value, @code{pointer to char}, and -@code{pointer to pointer to char}, respectively. +The full list of function pointer types available is + +@table @code +@item typedef int rl_command_func_t (int, int); + +@item typedef char *rl_compentry_func_t (const char *, int); + +@item typedef char **rl_completion_func_t (const char *, int, int); + +@item typedef char *rl_quote_func_t (char *, int, char *); + +@item typedef char *rl_dequote_func_t (char *, int); + +@item typedef int rl_compignore_func_t (char **); + +@item typedef void rl_compdisp_func_t (char **, int, int); + +@item typedef int rl_hook_func_t (void); + +@item typedef int rl_getc_func_t (FILE *); + +@item typedef int rl_linebuf_func_t (char *, int); + +@item typedef int rl_intfunc_t (int); +@item #define rl_ivoidfunc_t rl_hook_func_t +@item typedef int rl_icpfunc_t (char *); +@item typedef int rl_icppfunc_t (char **); + +@item typedef void rl_voidfunc_t (void); +@item typedef void rl_vintfunc_t (int); +@item typedef void rl_vcpfunc_t (char *); +@item typedef void rl_vcppfunc_t (char **); + +@end table @node Function Writing @subsection Writing a New Function @@ -222,7 +263,7 @@ variables that describe the current state of the line read so far. The calling sequence for a command @code{foo} looks like @example -@code{foo (int count, int key)} +@code{int foo (int count, int key)} @end example @noindent @@ -239,6 +280,9 @@ to do something useful with both negative and positive arguments. At the very least, it should be aware that it can be passed a negative argument. +A command function should return 0 if its action completes successfully, +and a non-zero value if some error occurs. + @node Readline Variables @section Readline Variables @@ -263,7 +307,7 @@ The number of characters present in @code{rl_line_buffer}. When @end deftypevar @deftypevar int rl_mark -The mark (saved position) in the current line. If set, the mark +The @var{mark} (saved position) in the current line. If set, the mark and point define a @emph{region}. @end deftypevar @@ -272,11 +316,23 @@ Setting this to a non-zero value causes Readline to return the current line immediately. @end deftypevar +@deftypevar int rl_num_chars_to_read +Setting this to a positive value before calling @code{readline()} causes +Readline to return after accepting that many characters, rather +than reading up to a character bound to @code{accept-line}. +@end deftypevar + @deftypevar int rl_pending_input Setting this to a value makes it the next keystroke read. This is a way to stuff a single character into the input stream. @end deftypevar +@deftypevar int rl_dispatching +Set to a non-zero value if a function is being called from a key binding; +zero otherwise. Application functions can test this to discover whether +they were called directly or by Readline's dispatching mechanism. +@end deftypevar + @deftypevar int rl_erase_empty_line Setting this to a non-zero value causes Readline to completely erase the current line, including any prompt, any time a newline is typed as @@ -286,7 +342,9 @@ the beginning of the newly-blank line. @deftypevar {char *} rl_prompt The prompt Readline uses. This is set from the argument to -@code{readline ()}, and should not be assigned to directly. +@code{readline()}, and should not be assigned to directly. +The @code{rl_set_prompt()} function (@pxref{Redisplay}) may +be used to modify the prompt string after calling @code{readline()}. @end deftypevar @deftypevar int rl_already_prompted @@ -299,15 +357,30 @@ The calling application is responsible for managing the value; Readline never sets it. @end deftypevar -@deftypevar {char *} rl_library_version +@deftypevar {const char *} rl_library_version The version number of this revision of the library. @end deftypevar -@deftypevar {char *} rl_terminal_name -The terminal type, used for initialization. +@deftypevar int rl_readline_version +An integer encoding the current version of the library. The encoding is +of the form 0x@var{MMmm}, where @var{MM} is the two-digit major version +number, and @var{mm} is the two-digit minor version number. +For example, for Readline-4.2, @code{rl_readline_version} would have the +value 0x0402. +@end deftypevar + +@deftypevar {int} rl_gnu_readline_p +Always set to 1, denoting that this is @sc{gnu} readline rather than some +emulation. +@end deftypevar + +@deftypevar {const char *} rl_terminal_name +The terminal type, used for initialization. If not set by the application, +Readline sets this to the value of the @env{TERM} environment variable +the first time it is called. @end deftypevar -@deftypevar {char *} rl_readline_name +@deftypevar {const char *} rl_readline_name This variable is set to a unique name by each application using Readline. The value allows conditional parsing of the inputrc file (@pxref{Conditional Init Constructs}). @@ -315,42 +388,68 @@ The value allows conditional parsing of the inputrc file @deftypevar {FILE *} rl_instream The stdio stream from which Readline reads input. +If @code{NULL}, Readline defaults to @var{stdin}. @end deftypevar @deftypevar {FILE *} rl_outstream The stdio stream to which Readline performs output. +If @code{NULL}, Readline defaults to @var{stdout}. +@end deftypevar + +@deftypevar {rl_command_func_t *} rl_last_func +The address of the last command function Readline executed. May be used to +test whether or not a function is being executed twice in succession, for +example. @end deftypevar -@deftypevar {Function *} rl_startup_hook +@deftypevar {rl_hook_func_t *} rl_startup_hook If non-zero, this is the address of a function to call just before @code{readline} prints the first prompt. @end deftypevar -@deftypevar {Function *} rl_pre_input_hook +@deftypevar {rl_hook_func_t *} rl_pre_input_hook If non-zero, this is the address of a function to call after the first prompt has been printed and just before @code{readline} starts reading input characters. @end deftypevar -@deftypevar {Function *} rl_event_hook +@deftypevar {rl_hook_func_t *} rl_event_hook If non-zero, this is the address of a function to call periodically -when readline is waiting for terminal input. +when Readline is waiting for terminal input. +By default, this will be called at most ten times a second if there +is no keyboard input. @end deftypevar -@deftypevar {Function *} rl_getc_function -If non-zero, @code{readline} will call indirectly through this pointer +@deftypevar {rl_getc_func_t *} rl_getc_function +If non-zero, Readline will call indirectly through this pointer to get a character from the input stream. By default, it is set to -@code{rl_getc}, the default @code{readline} character input function -(@pxref{Utility Functions}). +@code{rl_getc}, the default Readline character input function +(@pxref{Character Input}). @end deftypevar -@deftypevar {VFunction *} rl_redisplay_function -If non-zero, @code{readline} will call indirectly through this pointer +@deftypevar {rl_voidfunc_t *} rl_redisplay_function +If non-zero, Readline will call indirectly through this pointer to update the display with the current contents of the editing buffer. -By default, it is set to @code{rl_redisplay}, the default @code{readline} +By default, it is set to @code{rl_redisplay}, the default Readline redisplay function (@pxref{Redisplay}). @end deftypevar +@deftypevar {rl_vintfunc_t *} rl_prep_term_function +If non-zero, Readline will call indirectly through this pointer +to initialize the terminal. The function takes a single argument, an +@code{int} flag that says whether or not to use eight-bit characters. +By default, this is set to @code{rl_prep_terminal} +(@pxref{Terminal Management}). +@end deftypevar + +@deftypevar {rl_voidfunc_t *} rl_deprep_term_function +If non-zero, Readline will call indirectly through this pointer +to reset the terminal. This function should undo the effects of +@code{rl_prep_term_function}. +By default, this is set to @code{rl_deprep_terminal} +(@pxref{Terminal Management}). +@end deftypevar + @deftypevar {Keymap} rl_executing_keymap This variable is set to the keymap (@pxref{Keymaps}) in which the currently executing readline function was found. @@ -361,6 +460,79 @@ This variable is set to the keymap (@pxref{Keymaps}) in which the last key binding occurred. @end deftypevar +@deftypevar {char *} rl_executing_macro +This variable is set to the text of any currently-executing macro. +@end deftypevar + +@deftypevar {int} rl_readline_state +A variable with bit values that encapsulate the current Readline state. +A bit is set with the @code{RL_SETSTATE} macro, and unset with the +@code{RL_UNSETSTATE} macro. Use the @code{RL_ISSTATE} macro to test +whether a particular state bit is set. Current state bits include: + +@table @code +@item RL_STATE_NONE +Readline has not yet been called, nor has it begun to intialize. +@item RL_STATE_INITIALIZING +Readline is initializing its internal data structures. +@item RL_STATE_INITIALIZED +Readline has completed its initialization. +@item RL_STATE_TERMPREPPED +Readline has modified the terminal modes to do its own input and redisplay. +@item RL_STATE_READCMD +Readline is reading a command from the keyboard. +@item RL_STATE_METANEXT +Readline is reading more input after reading the meta-prefix character. +@item RL_STATE_DISPATCHING +Readline is dispatching to a command. +@item RL_STATE_MOREINPUT +Readline is reading more input while executing an editing command. +@item RL_STATE_ISEARCH +Readline is performing an incremental history search. +@item RL_STATE_NSEARCH +Readline is performing a non-incremental history search. +@item RL_STATE_SEARCH +Readline is searching backward or forward through the history for a string. +@item RL_STATE_NUMERICARG +Readline is reading a numeric argument. +@item RL_STATE_MACROINPUT +Readline is currently getting its input from a previously-defined keyboard +macro. +@item RL_STATE_MACRODEF +Readline is currently reading characters defining a keyboard macro. +@item RL_STATE_OVERWRITE +Readline is in overwrite mode. +@item RL_STATE_COMPLETING +Readline is performing word completion. +@item RL_STATE_SIGHANDLER +Readline is currently executing the readline signal handler. +@item RL_STATE_UNDOING +Readline is performing an undo. +@item RL_STATE_DONE +Readline has read a key sequence bound to @code{accept-line} +and is about to return the line to the caller. +@end table + +@end deftypevar + +@deftypevar {int} rl_explicit_arg +Set to a non-zero value if an explicit numeric argument was specified by +the user. Only valid in a bindable command function. +@end deftypevar + +@deftypevar {int} rl_numeric_arg +Set to the value of any numeric argument explicitly specified by the user +before executing the current Readline function. Only valid in a bindable +command function. +@end deftypevar + +@deftypevar {int} rl_editing_mode +Set to a value denoting Readline's current editing mode. A value of +@var{1} means Readline is currently in emacs mode; @var{0} +means that vi mode is active. +@end deftypevar + + @node Readline Convenience Functions @section Readline Convenience Functions @@ -373,8 +545,12 @@ last key binding occurred. * Allowing Undoing:: How to make your functions undoable. * Redisplay:: Functions to control line display. * Modifying Text:: Functions to modify @code{rl_line_buffer}. +* Character Input:: Functions to read keyboard input. +* Terminal Management:: Functions to manage terminal settings. * Utility Functions:: Generally useful functions and hooks. +* Miscellaneous Functions:: Functions that don't fall into any category. * Alternate Interface:: Using Readline in a `callback' fashion. +* A Readline Example:: An example Readline function. @end menu @node Function Naming @@ -394,10 +570,10 @@ This binds the keystroke @key{Meta-Rubout} to the function programmer, should bind the functions you write to descriptive names as well. Readline provides a function for doing that: -@deftypefun int rl_add_defun (char *name, Function *function, int key) +@deftypefun int rl_add_defun (const char *name, rl_command_func_t *function, int key) Add @var{name} to the list of named functions. Make @var{function} be the function that gets called. If @var{key} is not -1, then bind it to -@var{function} using @code{rl_bind_key ()}. +@var{function} using @code{rl_bind_key()}. @end deftypefun Using this function alone is sufficient for most applications. It is @@ -414,16 +590,17 @@ association between the keys that the user types and the functions that get run. You can make your own keymaps, copy existing keymaps, and tell Readline which keymap to use. -@deftypefun Keymap rl_make_bare_keymap () +@deftypefun Keymap rl_make_bare_keymap (void) Returns a new, empty keymap. The space for the keymap is allocated with -@code{malloc ()}; you should @code{free ()} it when you are done. +@code{malloc()}; the caller should free it by calling +@code{rl_discard_keymap()} when done. @end deftypefun @deftypefun Keymap rl_copy_keymap (Keymap map) Return a new keymap which is a copy of @var{map}. @end deftypefun -@deftypefun Keymap rl_make_keymap () +@deftypefun Keymap rl_make_keymap (void) Return a new keymap with the printing characters bound to rl_insert, the lowercase Meta characters bound to run their equivalents, and the Meta digits bound to produce numeric arguments. @@ -436,7 +613,7 @@ Free the storage associated with @var{keymap}. Readline has several internal keymaps. These functions allow you to change which keymap is active. -@deftypefun Keymap rl_get_keymap () +@deftypefun Keymap rl_get_keymap (void) Returns the currently active keymap. @end deftypefun @@ -444,7 +621,7 @@ Returns the currently active keymap. Makes @var{keymap} the currently active keymap. @end deftypefun -@deftypefun Keymap rl_get_keymap_by_name (char *name) +@deftypefun Keymap rl_get_keymap_by_name (const char *name) Return the keymap matching @var{name}. @var{name} is one which would be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). @end deftypefun @@ -457,28 +634,28 @@ be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). @node Binding Keys @subsection Binding Keys -You associate keys with functions through the keymap. Readline has -several internal keymaps: @code{emacs_standard_keymap}, +Key sequences are associate with functions through the keymap. +Readline has several internal keymaps: @code{emacs_standard_keymap}, @code{emacs_meta_keymap}, @code{emacs_ctlx_keymap}, @code{vi_movement_keymap}, and @code{vi_insertion_keymap}. @code{emacs_standard_keymap} is the default, and the examples in this manual assume that. -Since @code{readline} installs a set of default key bindings the first +Since @code{readline()} installs a set of default key bindings the first time it is called, there is always the danger that a custom binding -installed before the first call to @code{readline} will be overridden. +installed before the first call to @code{readline()} will be overridden. An alternate mechanism is to install custom key bindings in an initialization function assigned to the @code{rl_startup_hook} variable (@pxref{Readline Variables}). These functions manage key bindings. -@deftypefun int rl_bind_key (int key, Function *function) +@deftypefun int rl_bind_key (int key, rl_command_func_t *function) Binds @var{key} to @var{function} in the currently active keymap. Returns non-zero in the case of an invalid @var{key}. @end deftypefun -@deftypefun int rl_bind_key_in_map (int key, Function *function, Keymap map) +@deftypefun int rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map) Bind @var{key} to @var{function} in @var{map}. Returns non-zero in the case of an invalid @var{key}. @end deftypefun @@ -493,15 +670,21 @@ Bind @var{key} to the null function in @var{map}. Returns non-zero in case of error. @end deftypefun -@deftypefun int rl_unbind_function_in_map (Function *function, Keymap map) +@deftypefun int rl_unbind_function_in_map (rl_command_func_t *function, Keymap map) Unbind all keys that execute @var{function} in @var{map}. @end deftypefun -@deftypefun int rl_unbind_command_in_map (char *command, Keymap map) +@deftypefun int rl_unbind_command_in_map (const char *command, Keymap map) Unbind all keys that are bound to @var{command} in @var{map}. @end deftypefun -@deftypefun int rl_generic_bind (int type, char *keyseq, char *data, Keymap map) +@deftypefun int rl_set_key (const char *keyseq, rl_command_func_t *function, Keymap map) +Bind the key sequence represented by the string @var{keyseq} to the function +@var{function}. This makes new keymaps as +necessary. The initial keymap in which to do bindings is @var{map}. +@end deftypefun + +@deftypefun int rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) Bind the key sequence represented by the string @var{keyseq} to the arbitrary pointer @var{data}. @var{type} says what kind of data is pointed to by @var{data}; this can be a function (@code{ISFUNC}), a macro @@ -515,7 +698,7 @@ perform any key bindings and variable assignments found (@pxref{Readline Init File}). @end deftypefun -@deftypefun int rl_read_init_file (char *filename) +@deftypefun int rl_read_init_file (const char *filename) Read keybindings and variable assignments from @var{filename} (@pxref{Readline Init File}). @end deftypefun @@ -524,25 +707,26 @@ Read keybindings and variable assignments from @var{filename} @subsection Associating Function Names and Bindings These functions allow you to find out what keys invoke named functions -and the functions invoked by a particular key sequence. +and the functions invoked by a particular key sequence. You may also +associate a new function name with an arbitrary function. -@deftypefun {Function *} rl_named_function (char *name) +@deftypefun {rl_command_func_t *} rl_named_function (const char *name) Return the function with name @var{name}. @end deftypefun -@deftypefun {Function *} rl_function_of_keyseq (char *keyseq, Keymap map, int *type) +@deftypefun {rl_command_func_t *} rl_function_of_keyseq (const char *keyseq, Keymap map, int *type) Return the function invoked by @var{keyseq} in keymap @var{map}. -If @var{map} is NULL, the current keymap is used. If @var{type} is -not NULL, the type of the object is returned in it (one of @code{ISFUNC}, -@code{ISKMAP}, or @code{ISMACR}). +If @var{map} is @code{NULL}, the current keymap is used. If @var{type} is +not @code{NULL}, the type of the object is returned in the @code{int} variable +it points to (one of @code{ISFUNC}, @code{ISKMAP}, or @code{ISMACR}). @end deftypefun -@deftypefun {char **} rl_invoking_keyseqs (Function *function) +@deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function) Return an array of strings representing the key sequences used to invoke @var{function} in the current keymap. @end deftypefun -@deftypefun {char **} rl_invoking_keyseqs_in_map (Function *function, Keymap map) +@deftypefun {char **} rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map) Return an array of strings representing the key sequences used to invoke @var{function} in the keymap @var{map}. @end deftypefun @@ -554,14 +738,19 @@ the list is formatted in such a way that it can be made part of an @code{inputrc} file and re-read. @end deftypefun -@deftypefun void rl_list_funmap_names () +@deftypefun void rl_list_funmap_names (void) Print the names of all bindable Readline functions to @code{rl_outstream}. @end deftypefun -@deftypefun {char **} rl_funmap_names () +@deftypefun {const char **} rl_funmap_names (void) Return a NULL terminated array of known function names. The array is sorted. The array itself is allocated, but not the strings inside. You -should free () the array when you done, but not the pointrs. +should @code{free()} the array when you are done, but not the pointers. +@end deftypefun + +@deftypefun int rl_add_funmap_entry (const char *name, rl_command_func_t *function) +Add @var{name} to the list of bindable Readline command names, and make +@var{function} the function to be called when @var{name} is invoked. @end deftypefun @node Allowing Undoing @@ -569,41 +758,40 @@ should free () the array when you done, but not the pointrs. Supporting the undo command is a painless thing, and makes your functions much more useful. It is certainly easy to try -something if you know you can undo it. I could use an undo function for -the stock market. +something if you know you can undo it. If your function simply inserts text once, or deletes text once, and -uses @code{rl_insert_text ()} or @code{rl_delete_text ()} to do it, then +uses @code{rl_insert_text()} or @code{rl_delete_text()} to do it, then undoing is already done for you automatically. If you do multiple insertions or multiple deletions, or any combination of these operations, you should group them together into one operation. -This is done with @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. +This is done with @code{rl_begin_undo_group()} and +@code{rl_end_undo_group()}. The types of events that can be undone are: -@example +@smallexample enum undo_code @{ UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END @}; -@end example +@end smallexample Notice that @code{UNDO_DELETE} means to insert some text, and @code{UNDO_INSERT} means to delete some text. That is, the undo code -tells undo what to undo, not how to undo it. @code{UNDO_BEGIN} and -@code{UNDO_END} are tags added by @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. +tells what to undo, not how to undo it. @code{UNDO_BEGIN} and +@code{UNDO_END} are tags added by @code{rl_begin_undo_group()} and +@code{rl_end_undo_group()}. -@deftypefun int rl_begin_undo_group () +@deftypefun int rl_begin_undo_group (void) Begins saving undo information in a group construct. The undo -information usually comes from calls to @code{rl_insert_text ()} and -@code{rl_delete_text ()}, but could be the result of calls to -@code{rl_add_undo ()}. +information usually comes from calls to @code{rl_insert_text()} and +@code{rl_delete_text()}, but could be the result of calls to +@code{rl_add_undo()}. @end deftypefun -@deftypefun int rl_end_undo_group () +@deftypefun int rl_end_undo_group (void) Closes the current undo group started with @code{rl_begin_undo_group -()}. There should be one call to @code{rl_end_undo_group ()} -for each call to @code{rl_begin_undo_group ()}. +()}. There should be one call to @code{rl_end_undo_group()} +for each call to @code{rl_begin_undo_group()}. @end deftypefun @deftypefun void rl_add_undo (enum undo_code what, int start, int end, char *text) @@ -611,17 +799,17 @@ Remember how to undo an event (according to @var{what}). The affected text runs from @var{start} to @var{end}, and encompasses @var{text}. @end deftypefun -@deftypefun void free_undo_list () +@deftypefun void rl_free_undo_list (void) Free the existing undo list. @end deftypefun -@deftypefun int rl_do_undo () +@deftypefun int rl_do_undo (void) Undo the first thing on the undo list. Returns @code{0} if there was nothing to undo, non-zero if something was undone. @end deftypefun Finally, if you neither insert nor delete text, but directly modify the -existing text (e.g., change its case), call @code{rl_modifying ()} +existing text (e.g., change its case), call @code{rl_modifying()} once, just before you modify the text. You must supply the indices of the text range that you are going to modify. @@ -634,22 +822,22 @@ that text. @node Redisplay @subsection Redisplay -@deftypefun void rl_redisplay () +@deftypefun void rl_redisplay (void) Change what's displayed on the screen to reflect the current contents of @code{rl_line_buffer}. @end deftypefun -@deftypefun int rl_forced_update_display () +@deftypefun int rl_forced_update_display (void) Force the line to be updated and redisplayed, whether or not Readline thinks the screen display is correct. @end deftypefun -@deftypefun int rl_on_new_line () +@deftypefun int rl_on_new_line (void) Tell the update functions that we have moved onto a new (empty) line, usually after outputting a newline. @end deftypefun -@deftypefun int rl_on_new_line_with_prompt () +@deftypefun int rl_on_new_line_with_prompt (void) Tell the update functions that we have moved onto a new line, with @var{rl_prompt} already displayed. This could be used by applications that want to output the prompt string @@ -658,40 +846,72 @@ redisplay. It should be used after setting @var{rl_already_prompted}. @end deftypefun -@deftypefun int rl_reset_line_state () +@deftypefun int rl_reset_line_state (void) Reset the display state to a clean state and redisplay the current line starting on a new line. @end deftypefun -@deftypefun int rl_message (va_alist) -The arguments are a string as would be supplied to @code{printf}. The -resulting string is displayed in the @dfn{echo area}. The echo area +@deftypefun int rl_crlf (void) +Move the cursor to the start of the next screen line. +@end deftypefun + +@deftypefun int rl_show_char (int c) +Display character @var{c} on @code{rl_outstream}. +If Readline has not been set to display meta characters directly, this +will convert meta characters to a meta-prefixed key sequence. +This is intended for use by applications which wish to do their own +redisplay. +@end deftypefun + +@deftypefun int rl_message (const char *, @dots{}) +The arguments are a format string as would be supplied to @code{printf}, +possibly containing conversion specifications such as @samp{%d}, and +any additional arguments necessary to satisfy the conversion specifications. +The resulting string is displayed in the @dfn{echo area}. The echo area is also used to display numeric arguments and search strings. @end deftypefun -@deftypefun int rl_clear_message () +@deftypefun int rl_clear_message (void) Clear the message in the echo area. @end deftypefun -@deftypefun void rl_save_prompt () +@deftypefun void rl_save_prompt (void) Save the local Readline prompt display state in preparation for -displaying a new message in the message area with @code{rl_message}. +displaying a new message in the message area with @code{rl_message()}. @end deftypefun -@deftypefun void rl_restore_prompt () +@deftypefun void rl_restore_prompt (void) Restore the local Readline prompt display state saved by the most recent call to @code{rl_save_prompt}. @end deftypefun +@deftypefun int rl_expand_prompt (char *prompt) +Expand any special character sequences in @var{prompt} and set up the +local Readline prompt redisplay variables. +This function is called by @code{readline()}. It may also be called to +expand the primary prompt if the @code{rl_on_new_line_with_prompt()} +function or @code{rl_already_prompted} variable is used. +It returns the number of visible characters on the last line of the +(possibly multi-line) prompt. +@end deftypefun + +@deftypefun int rl_set_prompt (const char *prompt) +Make Readline use @var{prompt} for subsequent redisplay. This calls +@code{rl_expand_prompt()} to expand the prompt and sets @code{rl_prompt} +to the result. +@end deftypefun + @node Modifying Text @subsection Modifying Text -@deftypefun int rl_insert_text (char *text) +@deftypefun int rl_insert_text (const char *text) Insert @var{text} into the line at the current cursor position. +Returns the number of characters inserted. @end deftypefun @deftypefun int rl_delete_text (int start, int end) Delete the text between @var{start} and @var{end} in the current line. +Returns the number of characters deleted. @end deftypefun @deftypefun {char *} rl_copy_text (int start, int end) @@ -708,53 +928,113 @@ the text is appended, otherwise prepended. If the last command was not a kill, a new kill ring slot is used. @end deftypefun -@node Utility Functions -@subsection Utility Functions +@deftypefun int rl_push_macro_input (char *macro) +Cause @var{macro} to be inserted into the line, as if it had been invoked +by a key bound to a macro. Not especially useful; use +@code{rl_insert_text()} instead. +@end deftypefun -@deftypefun int rl_read_key () -Return the next character available. This handles input inserted into -the input stream via @var{pending input} (@pxref{Readline Variables}) -and @code{rl_stuff_char ()}, macros, and characters read from the keyboard. +@node Character Input +@subsection Character Input + +@deftypefun int rl_read_key (void) +Return the next character available from Readline's current input stream. +This handles input inserted into +the input stream via @var{rl_pending_input} (@pxref{Readline Variables}) +and @code{rl_stuff_char()}, macros, and characters read from the keyboard. +While waiting for input, this function will call any function assigned to +the @code{rl_event_hook} variable. @end deftypefun -@deftypefun int rl_getc (FILE *) -Return the next character available from the keyboard. +@deftypefun int rl_getc (FILE *stream) +Return the next character available from @var{stream}, which is assumed to +be the keyboard. @end deftypefun @deftypefun int rl_stuff_char (int c) Insert @var{c} into the Readline input stream. It will be "read" before Readline attempts to read characters from the terminal with -@code{rl_read_key ()}. +@code{rl_read_key()}. Up to 512 characters may be pushed back. +@code{rl_stuff_char} returns 1 if the character was successfully inserted; +0 otherwise. @end deftypefun -@deftypefun int rl_extend_line_buffer (int len) -Ensure that @code{rl_line_buffer} has enough space to hold @var{len} -characters, possibly reallocating it if necessary. +@deftypefun int rl_execute_next (int c) +Make @var{c} be the next command to be executed when @code{rl_read_key()} +is called. This sets @var{rl_pending_input}. @end deftypefun -@deftypefun int rl_initialize () -Initialize or re-initialize Readline's internal state. +@deftypefun int rl_clear_pending_input (void) +Unset @var{rl_pending_input}, effectively negating the effect of any +previous call to @code{rl_execute_next()}. This works only if the +pending input has not already been read with @code{rl_read_key()}. +@end deftypefun + +@deftypefun int rl_set_keyboard_input_timeout (int u) +While waiting for keyboard input in @code{rl_read_key()}, Readline will +wait for @var{u} microseconds for input before calling any function +assigned to @code{rl_event_hook}. The default waiting period is +one-tenth of a second. Returns the old timeout value. +@end deftypefun + +@node Terminal Management +@subsection Terminal Management + +@deftypefun void rl_prep_terminal (int meta_flag) +Modify the terminal settings for Readline's use, so @code{readline()} +can read a single character at a time from the keyboard. +The @var{meta_flag} argument should be non-zero if Readline should +read eight-bit input. +@end deftypefun + +@deftypefun void rl_deprep_terminal (void) +Undo the effects of @code{rl_prep_terminal()}, leaving the terminal in +the state in which it was before the most recent call to +@code{rl_prep_terminal()}. +@end deftypefun + +@deftypefun void rl_tty_set_default_bindings (Keymap kmap) +Read the operating system's terminal editing characters (as would be displayed +by @code{stty}) to their Readline equivalents. The bindings are performed +in @var{kmap}. @end deftypefun -@deftypefun int rl_reset_terminal (char *terminal_name) +@deftypefun int rl_reset_terminal (const char *terminal_name) Reinitialize Readline's idea of the terminal settings using @var{terminal_name} as the terminal type (e.g., @code{vt100}). -If @var{terminal_name} is NULL, the value of the @code{TERM} +If @var{terminal_name} is @code{NULL}, the value of the @code{TERM} environment variable is used. @end deftypefun -@deftypefun int alphabetic (int c) -Return 1 if @var{c} is an alphabetic character. +@node Utility Functions +@subsection Utility Functions + +@deftypefun void rl_replace_line (const char *text, int clear_undo) +Replace the contents of @code{rl_line_buffer} with @var{text}. +The point and mark are preserved, if possible. +If @var{clear_undo} is non-zero, the undo list associated with the +current line is cleared. @end deftypefun -@deftypefun int numeric (int c) -Return 1 if @var{c} is a numeric character. +@deftypefun int rl_extend_line_buffer (int len) +Ensure that @code{rl_line_buffer} has enough space to hold @var{len} +characters, possibly reallocating it if necessary. @end deftypefun -@deftypefun int ding () +@deftypefun int rl_initialize (void) +Initialize or re-initialize Readline's internal state. +It's not strictly necessary to call this; @code{readline()} calls it before +reading any input. +@end deftypefun + +@deftypefun int rl_ding (void) Ring the terminal bell, obeying the setting of @code{bell-style}. @end deftypefun +@deftypefun int rl_alphabetic (int c) +Return 1 if @var{c} is an alphabetic character. +@end deftypefun + @deftypefun void rl_display_match_list (char **matches, int len, int max) A convenience function for displaying a list of strings in columnar format on Readline's output stream. @code{matches} is the list @@ -765,34 +1045,80 @@ the setting of @code{print-completions-horizontally} to select how the matches are displayed (@pxref{Readline Init File Syntax}). @end deftypefun -The following are implemented as macros, defined in @code{chartypes.h}. +The following are implemented as macros, defined in @code{chardefs.h}. +Applications should refrain from using them. -@deftypefun int uppercase_p (int c) +@deftypefun int _rl_uppercase_p (int c) Return 1 if @var{c} is an uppercase alphabetic character. @end deftypefun -@deftypefun int lowercase_p (int c) +@deftypefun int _rl_lowercase_p (int c) Return 1 if @var{c} is a lowercase alphabetic character. @end deftypefun -@deftypefun int digit_p (int c) +@deftypefun int _rl_digit_p (int c) Return 1 if @var{c} is a numeric character. @end deftypefun -@deftypefun int to_upper (int c) +@deftypefun int _rl_to_upper (int c) If @var{c} is a lowercase alphabetic character, return the corresponding uppercase character. @end deftypefun -@deftypefun int to_lower (int c) +@deftypefun int _rl_to_lower (int c) If @var{c} is an uppercase alphabetic character, return the corresponding lowercase character. @end deftypefun -@deftypefun int digit_value (int c) +@deftypefun int _rl_digit_value (int c) If @var{c} is a number, return the value it represents. @end deftypefun +@node Miscellaneous Functions +@subsection Miscellaneous Functions + +@deftypefun int rl_macro_bind (const char *keyseq, const char *macro, Keymap map) +Bind the key sequence @var{keyseq} to invoke the macro @var{macro}. +The binding is performed in @var{map}. When @var{keyseq} is invoked, the +@var{macro} will be inserted into the line. This function is deprecated; +use @code{rl_generic_bind()} instead. +@end deftypefun + +@deftypefun void rl_macro_dumper (int readable) +Print the key sequences bound to macros and their values, using +the current keymap, to @code{rl_outstream}. +If @var{readable} is non-zero, the list is formatted in such a way +that it can be made part of an @code{inputrc} file and re-read. +@end deftypefun + +@deftypefun int rl_variable_bind (const char *variable, const char *value) +Make the Readline variable @var{variable} have @var{value}. +This behaves as if the readline command +@samp{set @var{variable} @var{value}} had been executed in an @code{inputrc} +file (@pxref{Readline Init File Syntax}). +@end deftypefun + +@deftypefun void rl_variable_dumper (int readable) +Print the readline variable names and their current values +to @code{rl_outstream}. +If @var{readable} is non-zero, the list is formatted in such a way +that it can be made part of an @code{inputrc} file and re-read. +@end deftypefun + +@deftypefun int rl_set_paren_blink_timeout (int u) +Set the time interval (in microseconds) that Readline waits when showing +a balancing character when @code{blink-matching-paren} has been enabled. +@end deftypefun + +@deftypefun {char *} rl_get_termcap (const char *cap) +Retrieve the string value of the termcap capability @var{cap}. +Readline fetches the termcap entry for the current terminal name and +uses those capabilities to move around the screen line and perform other +terminal-specific operations, like erasing a line. Readline does not +use all of a terminal's capabilities, and this function will return +values for only those capabilities Readline uses. +@end deftypefun + @node Alternate Interface @subsection Alternate Interface @@ -803,28 +1129,40 @@ on various file descriptors. To accomodate this need, readline can also be invoked as a `callback' function from an event loop. There are functions available to make this easy. -@deftypefun void rl_callback_handler_install (char *prompt, Vfunction *lhandler) +@deftypefun void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler) Set up the terminal for readline I/O and display the initial expanded value of @var{prompt}. Save the value of @var{lhandler} to -use as a callback when a complete line of input has been entered. +use as a function to call when a complete line of input has been entered. +The function takes the text of the line as an argument. @end deftypefun -@deftypefun void rl_callback_read_char () +@deftypefun void rl_callback_read_char (void) Whenever an application determines that keyboard input is available, it should call @code{rl_callback_read_char()}, which will read the next -character from the current input source. If that character completes the -line, @code{rl_callback_read_char} will invoke the @var{lhandler} -function saved by @code{rl_callback_handler_install} to process the -line. @code{EOF} is indicated by calling @var{lhandler} with a +character from the current input source. +If that character completes the line, @code{rl_callback_read_char} will +invoke the @var{lhandler} function saved by @code{rl_callback_handler_install} +to process the line. +Before calling the @var{lhandler} function, the terminal settings are +reset to the values they had before calling +@code{rl_callback_handler_install}. +If the @var{lhandler} function returns, +the terminal settings are modified for Readline's use again. +@code{EOF} is indicated by calling @var{lhandler} with a @code{NULL} line. @end deftypefun -@deftypefun void rl_callback_handler_remove () +@deftypefun void rl_callback_handler_remove (void) Restore the terminal to its initial state and remove the line handler. This may be called from within a callback as well as independently. +If the @var{lhandler} installed by @code{rl_callback_handler_install} +does not exit the program, either this function or the function referred +to by the value of @code{rl_deprep_term_function} should be called before +the program exits to reset the terminal settings. @end deftypefun -@subsection An Example +@node A Readline Example +@subsection A Readline Example Here is a function which changes lowercase characters to their uppercase equivalents, and uppercase characters to lowercase. If @@ -873,16 +1211,16 @@ invert_case_line (count, key) end = temp; @} - /* Tell readline that we are modifying the line, so it will save - the undo information. */ + /* Tell readline that we are modifying the line, + so it will save the undo information. */ rl_modifying (start, end); for (i = start; i != end; i++) @{ - if (uppercase_p (rl_line_buffer[i])) - rl_line_buffer[i] = to_lower (rl_line_buffer[i]); - else if (lowercase_p (rl_line_buffer[i])) - rl_line_buffer[i] = to_upper (rl_line_buffer[i]); + if (_rl_uppercase_p (rl_line_buffer[i])) + rl_line_buffer[i] = _rl_to_lower (rl_line_buffer[i]); + else if (_rl_lowercase_p (rl_line_buffer[i])) + rl_line_buffer[i] = _rl_to_upper (rl_line_buffer[i]); @} /* Move point to on top of the last character changed. */ rl_point = (direction == 1) ? end - 1 : start; @@ -895,44 +1233,44 @@ invert_case_line (count, key) Signals are asynchronous events sent to a process by the Unix kernel, sometimes on behalf of another process. They are intended to indicate -exceptional events, like a user pressing the interrupt key on his -terminal, or a network connection being broken. There is a class of -signals that can be sent to the process currently reading input from -the keyboard. Since Readline changes the terminal attributes when it -is called, it needs to perform special processing when a signal is -received to restore the terminal to a sane state, or provide application -writers with functions to do so manually. +exceptional events, like a user pressing the interrupt key on his terminal, +or a network connection being broken. There is a class of signals that can +be sent to the process currently reading input from the keyboard. Since +Readline changes the terminal attributes when it is called, it needs to +perform special processing when such a signal is received in order to +restore the terminal to a sane state, or provide application writers with +functions to do so manually. Readline contains an internal signal handler that is installed for a number of signals (@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM}, @code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}). When one of these signals is received, the signal handler will reset the terminal attributes to those that were in effect before -@code{readline ()} was called, reset the signal handling to what it was -before @code{readline ()} was called, and resend the signal to the calling +@code{readline()} was called, reset the signal handling to what it was +before @code{readline()} was called, and resend the signal to the calling application. If and when the calling application's signal handler returns, Readline will reinitialize the terminal and continue to accept input. When a @code{SIGINT} is received, the Readline signal handler performs some additional work, which will cause any partially-entered line to be -aborted (see the description of @code{rl_free_line_state ()}). +aborted (see the description of @code{rl_free_line_state()} below). There is an additional Readline signal handler, for @code{SIGWINCH}, which the kernel sends to a process whenever the terminal's size changes (for example, if a user resizes an @code{xterm}). The Readline @code{SIGWINCH} -handler updates Readline's internal screen size state, and then calls any -@code{SIGWINCH} signal handler the calling application has installed. +handler updates Readline's internal screen size information, and then calls +any @code{SIGWINCH} signal handler the calling application has installed. Readline calls the application's @code{SIGWINCH} signal handler without resetting the terminal to its original state. If the application's signal handler does more than update its idea of the terminal size and return (for example, a @code{longjmp} back to a main processing loop), it @emph{must} -call @code{rl_cleanup_after_signal ()} (described below), to restore the +call @code{rl_cleanup_after_signal()} (described below), to restore the terminal state. Readline provides two variables that allow application writers to control whether or not it will catch certain signals and act on them when they are received. It is important that applications change the -values of these variables only when calling @code{readline ()}, not in +values of these variables only when calling @code{readline()}, not in a signal handler, so Readline's internal signal state is not corrupted. @deftypevar int rl_catch_signals @@ -958,7 +1296,7 @@ and internal state cleanup upon receipt of a signal. @deftypefun void rl_cleanup_after_signal (void) This function will reset the state of the terminal to what it was before -@code{readline ()} was called, and remove the Readline signal handlers for +@code{readline()} was called, and remove the Readline signal handlers for all signals, depending on the values of @code{rl_catch_signals} and @code{rl_catch_sigwinch}. @end deftypefun @@ -967,7 +1305,7 @@ all signals, depending on the values of @code{rl_catch_signals} and This will free any partial state associated with the current input line (undo information, any partial history entry, any partially-entered keyboard macro, and any partially-entered numeric argument). This -should be called before @code{rl_cleanup_after_signal ()}. The +should be called before @code{rl_cleanup_after_signal()}. The Readline signal handler for @code{SIGINT} calls this to abort the current input line. @end deftypefun @@ -979,11 +1317,26 @@ handlers, depending on the values of @code{rl_catch_signals} and @end deftypefun If an application does not wish Readline to catch @code{SIGWINCH}, it may -call @code{rl_resize_terminal ()} to force Readline to update its idea of -the terminal size when a @code{SIGWINCH} is received. +call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force +Readline to update its idea of the terminal size when a @code{SIGWINCH} +is received. @deftypefun void rl_resize_terminal (void) -Update Readline's internal screen size. +Update Readline's internal screen size by reading values from the kernel. +@end deftypefun + +@deftypefun void rl_set_screen_size (int rows, int cols) +Set Readline's idea of the terminal size to @var{rows} rows and +@var{cols} columns. +@end deftypefun + +If an application does not want to install a @code{SIGWINCH} handler, but +is still interested in the screen dimensions, Readline's idea of the screen +size may be queried. + +@deftypefun void rl_get_screen_size (int *rows, int *cols) +Return Readline's idea of the terminal's size in the +variables pointed to by the arguments. @end deftypefun The following functions install and remove Readline's signal handlers. @@ -997,7 +1350,7 @@ Install Readline's signal handler for @code{SIGINT}, @code{SIGQUIT}, @deftypefun int rl_clear_signals (void) Remove all of the Readline signal handlers installed by -@code{rl_set_signals ()}. +@code{rl_set_signals()}. @end deftypefun @node Custom Completers @@ -1032,30 +1385,31 @@ There are three major functions used to perform completion: @enumerate @item -The user-interface function @code{rl_complete ()}. This function is -called with the same arguments as other Readline -functions intended for interactive use: @var{count} and -@var{invoking_key}. It isolates the word to be completed and calls -@code{completion_matches ()} to generate a list of possible completions. +The user-interface function @code{rl_complete()}. This function is +called with the same arguments as other bindable Readline functions: +@var{count} and @var{invoking_key}. +It isolates the word to be completed and calls +@code{rl_completion_matches()} to generate a list of possible completions. It then either lists the possible completions, inserts the possible completions, or actually performs the completion, depending on which behavior is desired. @item -The internal function @code{completion_matches ()} uses your -@dfn{generator} function to generate the list of possible matches, and -then returns the array of these matches. You should place the address -of your generator function in @code{rl_completion_entry_function}. +The internal function @code{rl_completion_matches()} uses an +application-supplied @dfn{generator} function to generate the list of +possible matches, and then returns the array of these matches. +The caller should place the address of its generator function in +@code{rl_completion_entry_function}. @item The generator function is called repeatedly from -@code{completion_matches ()}, returning a string each time. The +@code{rl_completion_matches()}, returning a string each time. The arguments to the generator function are @var{text} and @var{state}. @var{text} is the partial word to be completed. @var{state} is zero the first time the function is called, allowing the generator to perform any necessary initialization, and a positive non-zero integer for -each subsequent call. When the generator function returns -@code{(char *)NULL} this signals @code{completion_matches ()} that there are +each subsequent call. The generator function returns +@code{(char *)NULL} to inform @code{rl_completion_matches()} that there are no more possibilities left. Usually the generator function computes the list of possible completions when @var{state} is zero, and returns them one at a time on subsequent calls. Each string the generator function @@ -1067,14 +1421,15 @@ frees the strings when it has finished with them. @deftypefun int rl_complete (int ignore, int invoking_key) Complete the word at or before point. You have supplied the function that does the initial simple matching selection algorithm (see -@code{completion_matches ()}). The default is to do filename completion. +@code{rl_completion_matches()}). The default is to do filename completion. @end deftypefun -@deftypevar {Function *} rl_completion_entry_function -This is a pointer to the generator function for @code{completion_matches -()}. If the value of @code{rl_completion_entry_function} is -@code{(Function *)NULL} then the default filename generator function, -@code{filename_completion_function ()}, is used. +@deftypevar {rl_compentry_func_t *} rl_completion_entry_function +This is a pointer to the generator function for +@code{rl_completion_matches()}. +If the value of @code{rl_completion_entry_function} is +@code{NULL} then the default filename generator +function, @code{rl_filename_completion_function()}, is used. @end deftypevar @node Completion Functions @@ -1095,47 +1450,55 @@ performing partial completion. @deftypefun int rl_complete (int ignore, int invoking_key) Complete the word at or before point. You have supplied the function that does the initial simple matching selection algorithm (see -@code{completion_matches ()} and @code{rl_completion_entry_function}). +@code{rl_completion_matches()} and @code{rl_completion_entry_function}). The default is to do filename -completion. This calls @code{rl_complete_internal ()} with an +completion. This calls @code{rl_complete_internal()} with an argument depending on @var{invoking_key}. @end deftypefun -@deftypefun int rl_possible_completions (int count, int invoking_key)) +@deftypefun int rl_possible_completions (int count, int invoking_key) List the possible completions. See description of @code{rl_complete -()}. This calls @code{rl_complete_internal ()} with an argument of +()}. This calls @code{rl_complete_internal()} with an argument of @samp{?}. @end deftypefun -@deftypefun int rl_insert_completions (int count, int invoking_key)) +@deftypefun int rl_insert_completions (int count, int invoking_key) Insert the list of possible completions into the line, deleting the -partially-completed word. See description of @code{rl_complete ()}. -This calls @code{rl_complete_internal ()} with an argument of @samp{*}. +partially-completed word. See description of @code{rl_complete()}. +This calls @code{rl_complete_internal()} with an argument of @samp{*}. +@end deftypefun + +@deftypefun int rl_completion_mode (rl_command_func_t *cfunc) +Returns the apppriate value to pass to @code{rl_complete_internal()} +depending on whether @var{cfunc} was called twice in succession and +the value of the @code{show-all-if-ambiguous} variable. +Application-specific completion functions may use this function to present +the same interface as @code{rl_complete()}. @end deftypefun -@deftypefun {char **} completion_matches (char *text, CPFunction *entry_func) -Returns an array of @code{(char *)} which is a list of completions for -@var{text}. If there are no completions, returns @code{(char **)NULL}. +@deftypefun {char **} rl_completion_matches (const char *text, rl_compentry_func_t *entry_func) +Returns an array of strings which is a list of completions for +@var{text}. If there are no completions, returns @code{NULL}. The first entry in the returned array is the substitution for @var{text}. The remaining entries are the possible completions. The array is terminated with a @code{NULL} pointer. @var{entry_func} is a function of two args, and returns a -@code{(char *)}. The first argument is @var{text}. The second is a +@code{char *}. The first argument is @var{text}. The second is a state argument; it is zero on the first call, and non-zero on subsequent calls. @var{entry_func} returns a @code{NULL} pointer to the caller when there are no more matches. @end deftypefun -@deftypefun {char *} filename_completion_function (char *text, int state) -A generator function for filename completion in the general case. Note -that completion in Bash is a little different because of all -the pathnames that must be followed when looking up completions for a -command. The Bash source is a useful reference for writing custom -completion functions. +@deftypefun {char *} rl_filename_completion_function (const char *text, int state) +A generator function for filename completion in the general case. +@var{text} is a partial filename. +The Bash source is a useful reference for writing custom +completion functions (the Bash completion functions call this and other +Readline functions). @end deftypefun -@deftypefun {char *} username_completion_function (char *text, int state) +@deftypefun {char *} rl_username_completion_function (const char *text, int state) A completion generator for usernames. @var{text} contains a partial username preceded by a random character (usually @samp{~}). As with all completion generators, @var{state} is zero on the first call and non-zero @@ -1145,26 +1508,29 @@ for subsequent calls. @node Completion Variables @subsection Completion Variables -@deftypevar {Function *} rl_completion_entry_function -A pointer to the generator function for @code{completion_matches ()}. -@code{NULL} means to use @code{filename_completion_function ()}, the default +@deftypevar {rl_compentry_func_t *} rl_completion_entry_function +A pointer to the generator function for @code{rl_completion_matches()}. +@code{NULL} means to use @code{rl_filename_completion_function()}, the default filename completer. @end deftypevar -@deftypevar {CPPFunction *} rl_attempted_completion_function +@deftypevar {rl_completion_func_t *} rl_attempted_completion_function A pointer to an alternative function to create matches. The function is called with @var{text}, @var{start}, and @var{end}. -@var{start} and @var{end} are indices in @code{rl_line_buffer} saying -what the boundaries of @var{text} are. If this function exists and -returns @code{NULL}, or if this variable is set to @code{NULL}, then -@code{rl_complete ()} will call the value of +@var{start} and @var{end} are indices in @code{rl_line_buffer} defining +the boundaries of @var{text}, which is a character string. +If this function exists and returns @code{NULL}, or if this variable is +set to @code{NULL}, then @code{rl_complete()} will call the value of @code{rl_completion_entry_function} to generate matches, otherwise the array of strings returned will be used. +If this function sets the @code{rl_attempted_completion_over} +variable to a non-zero value, Readline will not perform its default +completion even if this function returns no matches. @end deftypevar -@deftypevar {CPFunction *} rl_filename_quoting_function -A pointer to a function that will quote a filename in an application- -specific fashion. This is called if filename completion is being +@deftypevar {rl_quote_func_t *} rl_filename_quoting_function +A pointer to a function that will quote a filename in an +application-specific fashion. This is called if filename completion is being attempted and one of the characters in @code{rl_filename_quote_characters} appears in a completed filename. The function is called with @var{text}, @var{match_type}, and @var{quote_pointer}. The @var{text} @@ -1176,7 +1542,7 @@ to any opening quote character the user typed. Some functions choose to reset this character. @end deftypevar -@deftypevar {CPFunction *} rl_filename_dequoting_function +@deftypevar {rl_dequote_func_t *} rl_filename_dequoting_function A pointer to a function that will remove application-specific quoting characters from a filename before completion is attempted, so those characters do not interfere with matching the text against names in @@ -1186,52 +1552,83 @@ that delimits the filename (usually @samp{'} or @samp{"}). If @var{quote_char} is zero, the filename was not in an embedded string. @end deftypevar -@deftypevar {Function *} rl_char_is_quoted_p +@deftypevar {rl_linebuf_func_t *} rl_char_is_quoted_p A pointer to a function to call that determines whether or not a specific character in the line buffer is quoted, according to whatever quoting -mechanism the program calling readline uses. The function is called with +mechanism the program calling Readline uses. The function is called with two arguments: @var{text}, the text of the line, and @var{index}, the index of the character in the line. It is used to decide whether a character found in @code{rl_completer_word_break_characters} should be used to break words for the completer. @end deftypevar -@deftypevar int rl_completion_query_items -Up to this many items will be displayed in response to a -possible-completions call. After that, we ask the user if she is sure -she wants to see them all. The default value is 100. +@deftypevar {rl_compignore_func_t *} rl_ignore_some_completions_function +This function, if defined, is called by the completer when real filename +completion is done, after all the matching names have been generated. +It is passed a @code{NULL} terminated array of matches. +The first element (@code{matches[0]}) is the +maximal substring common to all matches. This function can +re-arrange the list of matches as required, but each element deleted +from the array must be freed. +@end deftypevar + +@deftypevar {rl_icppfunc_t *} rl_directory_completion_hook +This function, if defined, is allowed to modify the directory portion +of filenames Readline completes. It is called with the address of a +string (the current directory name) as an argument, and may modify that string. +If the string is replaced with a new string, the old value should be freed. +Any modified directory name should have a trailing slash. +The modified value will be displayed as part of the completion, replacing +the directory portion of the pathname the user typed. +It returns an integer that should be non-zero if the function modifies +its directory argument. +It could be used to expand symbolic links or shell variables in pathnames. +@end deftypevar + +@deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook +If non-zero, then this is the address of a function to call when +completing a word would normally display the list of possible matches. +This function is called in lieu of Readline displaying the list. +It takes three arguments: +(@code{char **}@var{matches}, @code{int} @var{num_matches}, @code{int} @var{max_length}) +where @var{matches} is the array of matching strings, +@var{num_matches} is the number of strings in that array, and +@var{max_length} is the length of the longest string in that array. +Readline provides a convenience function, @code{rl_display_match_list}, +that takes care of doing the display to Readline's output stream. That +function may be called from this hook. @end deftypevar -@deftypevar {char *} rl_basic_word_break_characters +@deftypevar {const char *} rl_basic_word_break_characters The basic list of characters that signal a break between words for the completer routine. The default value of this variable is the characters -which break words for completion in Bash, i.e., +which break words for completion in Bash: @code{" \t\n\"\\'`@@$><=;|&@{("}. @end deftypevar -@deftypevar {char *} rl_basic_quote_characters -List of quote characters which can cause a word break. +@deftypevar {const char *} rl_basic_quote_characters +A list of quote characters which can cause a word break. @end deftypevar -@deftypevar {char *} rl_completer_word_break_characters +@deftypevar {const char *} rl_completer_word_break_characters The list of characters that signal a break between words for -@code{rl_complete_internal ()}. The default list is the value of +@code{rl_complete_internal()}. The default list is the value of @code{rl_basic_word_break_characters}. @end deftypevar -@deftypevar {char *} rl_completer_quote_characters -List of characters which can be used to quote a substring of the line. +@deftypevar {const char *} rl_completer_quote_characters +A list of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring @code{rl_completer_word_break_characters} are treated as any other character, unless they also appear within this list. @end deftypevar -@deftypevar {char *} rl_filename_quote_characters +@deftypevar {const char *} rl_filename_quote_characters A list of characters that cause a filename to be quoted by the completer when they appear in a completed filename. The default is the null string. @end deftypevar -@deftypevar {char *} rl_special_prefixes +@deftypevar {const char *} rl_special_prefixes The list of characters that are word break characters, but should be left in @var{text} when it is passed to the completion function. Programs can use this to help determine what kind of completing to do. @@ -1239,6 +1636,12 @@ For instance, Bash sets this variable to "$@@" so that it can complete shell variables and hostnames. @end deftypevar +@deftypevar int rl_completion_query_items +Up to this many items will be displayed in response to a +possible-completions call. After that, we ask the user if she is sure +she wants to see them all. The default value is 100. +@end deftypevar + @deftypevar {int} rl_completion_append_character When a single completion alternative matches at the end of the command line, this character is appended to the inserted completion text. The @@ -1249,8 +1652,27 @@ provide the ``most sensible word separator character'' according to an application-specific command line syntax specification. @end deftypevar +@deftypevar int rl_completion_suppress_append +If non-zero, @var{rl_completion_append_character} is not appended to +matches at the end of the command line, as described above. It is +set to 0 before any application-specific completion function is called. +@end deftypevar + +@deftypevar int rl_completion_mark_symlink_dirs +If non-zero, a slash will be appended to completed filenames that are +symbolic links to directory names, subject to the value of the +user-settable @var{mark-directories} variable. +This variable exists so that application completion functions can +override the user's global preference (set via the +@var{mark-symlinked-directories} Readline variable) if appropriate. +This variable is set to the user's preference before any +application completion function is called, so unless that function +modifies the value, the user's preferences are honored. +@end deftypevar + @deftypevar int rl_ignore_completion_duplicates -If non-zero, then disallow duplicates in the matches. Default is 1. +If non-zero, then duplicates in the matches are removed. +The default is 1. @end deftypevar @deftypevar int rl_filename_completion_desired @@ -1258,8 +1680,9 @@ Non-zero means that the results of the matches are to be treated as filenames. This is @emph{always} zero on entry, and can only be changed within a completion entry generator function. If it is set to a non-zero value, directory names have a slash appended and Readline attempts to -quote completed filenames if they contain any embedded word break -characters. +quote completed filenames if they contain any characters in +@code{rl_filename_quote_characters} and @code{rl_filename_quoting_desired} +is set to a non-zero value. @end deftypevar @deftypevar int rl_filename_quoting_desired @@ -1272,40 +1695,23 @@ function. The quoting is effected via a call to the function pointed to by @code{rl_filename_quoting_function}. @end deftypevar -@deftypevar int rl_inhibit_completion -If this variable is non-zero, completion is inhibit<ed. The completion -character will be inserted as any other bound to @code{self-insert}. +@deftypevar int rl_attempted_completion_over +If an application-specific completion function assigned to +@code{rl_attempted_completion_function} sets this variable to a non-zero +value, Readline will not perform its default filename completion even +if the application's completion function returns no matches. +It should be set only by an application's completion function. @end deftypevar -@deftypevar {Function *} rl_ignore_some_completions_function -This function, if defined, is called by the completer when real filename -completion is done, after all the matching names have been generated. -It is passed a @code{NULL} terminated array of matches. -The first element (@code{matches[0]}) is the -maximal substring common to all matches. This function can -re-arrange the list of matches as required, but each element deleted -from the array must be freed. +@deftypevar int rl_completion_type +Set to a character describing the type of completion Readline is currently +attempting; see the description of @code{rl_complete_internal()} +(@pxref{Completion Functions}) for the list of characters. @end deftypevar -@deftypevar {Function *} rl_directory_completion_hook -This function, if defined, is allowed to modify the directory portion -of filenames Readline completes. It is called with the address of a -string (the current directory name) as an argument. It could be used -to expand symbolic links or shell variables in pathnames. -@end deftypevar - -@deftypevar {VFunction *} rl_completion_display_matches_hook -If non-zero, then this is the address of a function to call when -completing a word would normally display the list of possible matches. -This function is called in lieu of Readline displaying the list. -It takes three arguments: -(@code{char **}@var{matches}, @code{int} @var{num_matches}, @code{int} @var{max_length}) -where @var{matches} is the array of matching strings, -@var{num_matches} is the number of strings in that array, and -@var{max_length} is the length of the longest string in that array. -Readline provides a convenience function, @code{rl_display_match_list}, -that takes care of doing the display to Readline's output stream. That -function may be called from this hook. +@deftypevar int rl_inhibit_completion +If this variable is non-zero, completion is inhibited. The completion +character will be inserted as any other bound to @code{self-insert}. @end deftypevar @node A Short Completion Example @@ -1332,19 +1738,25 @@ history list. #include <readline/readline.h> #include <readline/history.h> -extern char *getwd (); extern char *xmalloc (); /* The names of functions that actually do the manipulation. */ -int com_list (), com_view (), com_rename (), com_stat (), com_pwd (); -int com_delete (), com_help (), com_cd (), com_quit (); +int com_list __P((char *)); +int com_view __P((char *)); +int com_rename __P((char *)); +int com_stat __P((char *)); +int com_pwd __P((char *)); +int com_delete __P((char *)); +int com_help __P((char *)); +int com_cd __P((char *)); +int com_quit __P((char *)); /* A structure which contains information on the commands this program can understand. */ typedef struct @{ char *name; /* User printable name of the function. */ - Function *func; /* Function to call to do the job. */ + rl_icpfunc_t *func; /* Function to call to do the job. */ char *doc; /* Documentation for this function. */ @} COMMAND; @@ -1360,7 +1772,7 @@ COMMAND commands[] = @{ @{ "rename", com_rename, "Rename FILE to NEWNAME" @}, @{ "stat", com_stat, "Print out statistics on FILE" @}, @{ "view", com_view, "View the contents of FILE" @}, - @{ (char *)NULL, (Function *)NULL, (char *)NULL @} + @{ (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL @} @}; /* Forward declarations. */ @@ -1370,7 +1782,7 @@ COMMAND *find_command (); /* The name of this program, as taken from argv[0]. */ char *progname; -/* When non-zero, this global means the user is done using this program. */ +/* When non-zero, this means the user is done using this program. */ int done; char * @@ -1500,29 +1912,29 @@ stripwhite (string) /* */ /* **************************************************************** */ -char *command_generator (); -char **fileman_completion (); +char *command_generator __P((const char *, int)); +char **fileman_completion __P((const char *, int, int)); -/* Tell the GNU Readline library how to complete. We want to try to complete - on command names if this is the first word in the line, or on filenames - if not. */ +/* Tell the GNU Readline library how to complete. We want to try to + complete on command names if this is the first word in the line, or + on filenames if not. */ initialize_readline () @{ /* Allow conditional parsing of the ~/.inputrc file. */ rl_readline_name = "FileMan"; /* Tell the completer that we want a crack first. */ - rl_attempted_completion_function = (CPPFunction *)fileman_completion; + rl_attempted_completion_function = fileman_completion; @} -/* Attempt to complete on the contents of TEXT. START and END bound the - region of rl_line_buffer that contains the word to complete. TEXT is - the word to complete. We can use the entire contents of rl_line_buffer - in case we want to do some simple parsing. Return the array of matches, - or NULL if there aren't any. */ +/* Attempt to complete on the contents of TEXT. START and END + bound the region of rl_line_buffer that contains the word to + complete. TEXT is the word to complete. We can use the entire + contents of rl_line_buffer in case we want to do some simple + parsing. Returnthe array of matches, or NULL if there aren't any. */ char ** fileman_completion (text, start, end) - char *text; + const char *text; int start, end; @{ char **matches; @@ -1533,32 +1945,33 @@ fileman_completion (text, start, end) to complete. Otherwise it is the name of a file in the current directory. */ if (start == 0) - matches = completion_matches (text, command_generator); + matches = rl_completion_matches (text, command_generator); return (matches); @} -/* Generator function for command completion. STATE lets us know whether - to start from scratch; without any state (i.e. STATE == 0), then we - start at the top of the list. */ +/* Generator function for command completion. STATE lets us + know whether to start from scratch; without any state + (i.e. STATE == 0), then we start at the top of the list. */ char * command_generator (text, state) - char *text; + const char *text; int state; @{ static int list_index, len; char *name; - /* If this is a new word to complete, initialize now. This includes - saving the length of TEXT for efficiency, and initializing the index - variable to 0. */ + /* If this is a new word to complete, initialize now. This + includes saving the length of TEXT for efficiency, and + initializing the index variable to 0. */ if (!state) @{ list_index = 0; len = strlen (text); @} - /* Return the next name which partially matches from the command list. */ + /* Return the next name which partially matches from the + command list. */ while (name = commands[list_index].name) @{ list_index++; @@ -1703,7 +2116,7 @@ com_pwd (ignore) @{ char dir[1024], *s; - s = getwd (dir); + s = getcwd (dir, sizeof(dir) - 1); if (s == 0) @{ printf ("Error getting pwd: %s\n", dir); @@ -1714,7 +2127,8 @@ com_pwd (ignore) return 0; @} -/* The user wishes to quit using this program. Just set DONE non-zero. */ +/* The user wishes to quit using this program. Just set DONE + non-zero. */ com_quit (arg) char *arg; @{ @@ -1727,12 +2141,13 @@ too_dangerous (caller) char *caller; @{ fprintf (stderr, - "%s: Too dangerous for me to distribute. Write it yourself.\n", + "%s: Too dangerous for me to distribute.\n" caller); + fprintf (stderr, "Write it yourself.\n"); @} -/* Return non-zero if ARG is a valid argument for CALLER, else print - an error message and return zero. */ +/* Return non-zero if ARG is a valid argument for CALLER, + else print an error message and return zero. */ int valid_argument (caller, arg) char *caller, *arg; diff --git a/gnu/lib/libreadline/doc/rluser.texinfo b/gnu/lib/libreadline/doc/rluser.texinfo index 316aa4d0aec..94f851e67f2 100644 --- a/gnu/lib/libreadline/doc/rluser.texinfo +++ b/gnu/lib/libreadline/doc/rluser.texinfo @@ -10,7 +10,7 @@ use these features. There is a document entitled "readline.texinfo" which contains both end-user and programmer documentation for the GNU Readline Library. -Copyright (C) 1988-1999 Free Software Foundation, Inc. +Copyright (C) 1988-2002 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. @@ -72,11 +72,11 @@ used by several different programs, including Bash. The following paragraphs describe the notation used to represent keystrokes. -The text @key{C-k} is read as `Control-K' and describes the character +The text @kbd{C-k} is read as `Control-K' and describes the character produced when the @key{k} key is pressed while the Control key is depressed. -The text @key{M-k} is read as `Meta-K' and describes the character +The text @kbd{M-k} is read as `Meta-K' and describes the character produced when the Meta key (if you have one) is depressed, and the @key{k} key is pressed. The Meta key is labeled @key{ALT} on many keyboards. @@ -89,11 +89,11 @@ Compose key for typing accented characters. If you do not have a Meta or @key{ALT} key, or another key working as a Meta key, the identical keystroke can be generated by typing @key{ESC} -@i{first}, and then typing @key{k}. +@emph{first}, and then typing @key{k}. Either process is known as @dfn{metafying} the @key{k} key. -The text @key{M-C-k} is read as `Meta-Control-k' and describes the -character produced by @dfn{metafying} @key{C-k}. +The text @kbd{M-C-k} is read as `Meta-Control-k' and describes the +character produced by @dfn{metafying} @kbd{C-k}. In addition, several keys have their own names. Specifically, @key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all @@ -115,8 +115,8 @@ as you type it in, allowing you to just fix your typo, and not forcing you to retype the majority of the line. Using these editing commands, you move the cursor to the place that needs correction, and delete or insert the text of the corrections. Then, when you are satisfied with -the line, you simply press @key{RETURN}. You do not have to be at the -end of the line to press @key{RETURN}; the entire line is accepted +the line, you simply press @key{RET}. You do not have to be at the +end of the line to press @key{RET}; the entire line is accepted regardless of the location of the cursor within the line. @menu @@ -140,9 +140,9 @@ erase character to back up and delete the mistyped character. Sometimes you may mistype a character, and not notice the error until you have typed several other characters. In -that case, you can type @key{C-b} to move the cursor to the left, and then +that case, you can type @kbd{C-b} to move the cursor to the left, and then correct your mistake. Afterwards, you can move the cursor to the right -with @key{C-f}. +with @kbd{C-f}. When you add text in the middle of a line, you will notice that characters to the right of the cursor are `pushed over' to make room for the text @@ -152,17 +152,17 @@ blank space created by the removal of the text. A list of the bare essentials for editing the text of an input line follows. @table @asis -@item @key{C-b} +@item @kbd{C-b} Move back one character. -@item @key{C-f} +@item @kbd{C-f} Move forward one character. @item @key{DEL} or @key{Backspace} Delete the character to the left of the cursor. -@item @key{C-d} +@item @kbd{C-d} Delete the character underneath the cursor. @item @w{Printing characters} Insert the character into the line at the cursor. -@item @key{C-_} or @key{C-x C-u} +@item @kbd{C-_} or @kbd{C-x C-u} Undo the last editing command. You can undo all the way back to an empty line. @end table @@ -170,7 +170,7 @@ empty line. @noindent (Depending on your configuration, the @key{Backspace} key be set to delete the character to the left of the cursor and the @key{DEL} key set -to delete the character underneath the cursor, like @key{C-d}, rather +to delete the character underneath the cursor, like @kbd{C-d}, rather than the character to the left of the cursor.) @node Readline Movement Commands @@ -179,11 +179,11 @@ than the character to the left of the cursor.) The above table describes the most basic keystrokes that you need in order to do editing of the input line. For your convenience, many -other commands have been added in addition to @key{C-b}, @key{C-f}, -@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly +other commands have been added in addition to @kbd{C-b}, @kbd{C-f}, +@kbd{C-d}, and @key{DEL}. Here are some commands for moving more rapidly about the line. -@table @key +@table @kbd @item C-a Move to the start of the line. @item C-e @@ -196,7 +196,7 @@ Move backward a word. Clear the screen, reprinting the current line at the top. @end table -Notice how @key{C-f} moves forward a character, while @key{M-f} moves +Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves forward a word. It is a loose convention that control keystrokes operate on characters while meta keystrokes operate on words. @@ -225,36 +225,36 @@ another line. Here is the list of commands for killing text. -@table @key +@table @kbd @item C-k Kill the text from the current cursor position to the end of the line. @item M-d Kill from the cursor to the end of the current word, or, if between words, to the end of the next word. -Word boundaries are the same as those used by @key{M-f}. +Word boundaries are the same as those used by @kbd{M-f}. -@item M-DEL -Kill from the cursor the start of the previous word, or, if between +@item M-@key{DEL} +Kill from the cursor the start of the current word, or, if between words, to the start of the previous word. -Word boundaries are the same as those used by @key{M-b}. +Word boundaries are the same as those used by @kbd{M-b}. @item C-w Kill from the cursor to the previous whitespace. This is different than -@key{M-DEL} because the word boundaries differ. +@kbd{M-@key{DEL}} because the word boundaries differ. @end table Here is how to @dfn{yank} the text back into the line. Yanking means to copy the most-recently-killed text from the kill buffer. -@table @key +@table @kbd @item C-y Yank the most recently killed text back into the buffer at the cursor. @item M-y Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @key{C-y} or @key{M-y}. +the prior command is @kbd{C-y} or @kbd{M-y}. @end table @node Readline Arguments @@ -272,7 +272,8 @@ digits before the command. If the first `digit' typed is a minus sign (@samp{-}), then the sign of the argument will be negative. Once you have typed one meta digit to get the argument started, you can type the remainder of the digits, and then the command. For example, to give -the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}. +the @kbd{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}, +which will delete the next ten characters on the input line. @node Searching @subsection Searching for Commands in the History @@ -282,7 +283,7 @@ Readline provides commands for searching through the command history (@pxref{Bash History Facilities}) @end ifset for lines containing a specified string. -There are two search modes: @var{incremental} and @var{non-incremental}. +There are two search modes: @dfn{incremental} and @dfn{non-incremental}. Incremental searches begin before the user has finished typing the search string. @@ -291,23 +292,29 @@ the next entry from the history matching the string typed so far. An incremental search requires only as many characters as needed to find the desired history entry. To search backward in the history for a particular string, type -@key{C-r}. Typing @key{C-s} searches forward through the history. +@kbd{C-r}. Typing @kbd{C-s} searches forward through the history. The characters present in the value of the @code{isearch-terminators} variable are used to terminate an incremental search. If that variable has not been assigned a value, the @key{ESC} and -@key{C-J} characters will terminate an incremental search. -@key{C-g} will abort an incremental search and restore the original line. +@kbd{C-J} characters will terminate an incremental search. +@kbd{C-g} will abort an incremental search and restore the original line. When the search is terminated, the history entry containing the search string becomes the current line. -To find other matching entries in the history list, type @key{C-r} or -@key{C-s} as appropriate. +To find other matching entries in the history list, type @kbd{C-r} or +@kbd{C-s} as appropriate. This will search backward or forward in the history for the next entry matching the search string typed so far. Any other key sequence bound to a Readline command will terminate the search and execute that command. For instance, a @key{RET} will terminate the search and accept the line, thereby executing the command from the history list. +A movement command will terminate the search, make the last line found +the current line, and begin editing. + +Readline remembers the last incremental search string. If two +@kbd{C-r}s are typed without any intervening characters defining a new +search string, any remembered search string is used. Non-incremental searches read the entire search string before starting to search for matching history lines. The search string may be @@ -324,10 +331,10 @@ Any user can customize programs that use Readline by putting commands in an @dfn{inputrc} file, conventionally in his home directory. The name of this @ifset BashFeatures -file is taken from the value of the shell variable @code{INPUTRC}. If +file is taken from the value of the shell variable @env{INPUTRC}. If @end ifset @ifclear BashFeatures -file is taken from the value of the environment variable @code{INPUTRC}. If +file is taken from the value of the environment variable @env{INPUTRC}. If @end ifclear that variable is unset, the default is @file{~/.inputrc}. @@ -359,7 +366,15 @@ denote variable settings and key bindings. @item Variable Settings You can modify the run-time behavior of Readline by altering the values of variables in Readline -using the @code{set} command within the init file. Here is how to +using the @code{set} command within the init file. +The syntax is simple: + +@example +set @var{variable} @var{value} +@end example + +@noindent +Here, for example, is how to change from the default Emacs-like key binding to use @code{vi} line editing commands: @@ -367,6 +382,9 @@ change from the default Emacs-like key binding to use set editing-mode vi @end example +Variable names and values, where appropriate, are recognized without regard +to case. + @ifset BashFeatures The @w{@code{bind -V}} command lists the current Readline variable names and values. @xref{Bash Builtins}. @@ -375,6 +393,7 @@ and values. @xref{Bash Builtins}. A great deal of run-time behavior is changeable with the following variables. +@cindex variables, readline @table @code @item bell-style @@ -402,13 +421,14 @@ The number of possible completions that determines when the user is asked whether he wants to see the list of possibilities. If the number of possible completions is greater than this value, Readline will ask the user whether or not he wishes to view -them; otherwise, they are simply listed. The default limit is -@code{100}. +them; otherwise, they are simply listed. +This variable must be set to an integer value greater than or equal to 0. +The default limit is @code{100}. @item convert-meta @vindex convert-meta If set to @samp{on}, Readline will convert characters with the -eighth bit set to an ASCII key sequence by stripping the eighth +eighth bit set to an @sc{ascii} key sequence by stripping the eighth bit and prefixing an @key{ESC} character, converting them to a meta-prefixed key sequence. The default value is @samp{on}. @@ -436,6 +456,11 @@ arrow keys. The default is @samp{off}. If set to @samp{on}, tilde expansion is performed when Readline attempts word completion. The default is @samp{off}. +@vindex history-preserve-point +If set to @samp{on}, the history code attempts to place point at the +same location on each history line retrived with @code{previous-history} +or @code{next-history}. + @item horizontal-scroll-mode @vindex horizontal-scroll-mode This variable can be set to either @samp{on} or @samp{off}. Setting it @@ -448,7 +473,7 @@ this variable is set to @samp{off}. @vindex input-meta @vindex meta-flag If set to @samp{on}, Readline will enable eight-bit input (it -will not strip the eighth bit from the characters it reads), +will not clear the eighth bit in the characters it reads), regardless of what the terminal claims it can support. The default value is @samp{off}. The name @code{meta-flag} is a synonym for this variable. @@ -458,7 +483,7 @@ synonym for this variable. The string of characters that should terminate an incremental search without subsequently executing the character as a command (@pxref{Searching}). If this variable has not been given a value, the characters @key{ESC} and -@key{C-J} will terminate an incremental search. +@kbd{C-J} will terminate an incremental search. @item keymap @vindex keymap @@ -469,6 +494,7 @@ Acceptable @code{keymap} names are @code{emacs-meta}, @code{emacs-ctlx}, @code{vi}, +@code{vi-move}, @code{vi-command}, and @code{vi-insert}. @code{vi} is equivalent to @code{vi-command}; @code{emacs} is @@ -486,12 +512,33 @@ This variable, when set to @samp{on}, causes Readline to display an asterisk (@samp{*}) at the start of history lines which have been modified. This variable is @samp{off} by default. +@item mark-symlinked-directories +@vindex mark-symlinked-directories +If set to @samp{on}, completed names which are symbolic links +to directories have a slash appended (subject to the value of +@code{mark-directories}). +The default is @samp{off}. + +@item match-hidden-files +@vindex match-hidden-files +This variable, when set to @samp{on}, causes Readline to match files whose +names begin with a @samp{.} (hidden files) when performing filename +completion, unless the leading @samp{.} is +supplied by the user in the filename to be completed. +This variable is @samp{on} by default. + @item output-meta @vindex output-meta If set to @samp{on}, Readline will display characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. The default is @samp{off}. +@item page-completions +@vindex page-completions +If set to @samp{on}, Readline uses an internal @code{more}-like pager +to display a screenful of possible completions at a time. +This variable is @samp{on} by default. + @item print-completions-horizontally If set to @samp{on}, Readline will display completions with matches sorted horizontally in alphabetical order, rather than down the screen. @@ -520,11 +567,15 @@ want to change. The following sections contain tables of the command name, the default keybinding, if any, and a short description of what the command does. -Once you know the name of the command, simply place the name of the key +Once you know the name of the command, simply place on a line +in the init file the name of the key you wish to bind the command to, a colon, and then the name of the -command on a line in the init file. The name of the key -can be expressed in different ways, depending on which is most -comfortable for you. +command. The name of the key +can be expressed in different ways, depending on what you find most +comfortable. + +In addition to command names, readline allows keys to be bound +to a string that is inserted when the key is pressed (a @var{macro}). @ifset BashFeatures The @w{@code{bind -p}} command displays Readline function names and @@ -541,11 +592,28 @@ Meta-Rubout: backward-kill-word Control-o: "> output" @end example -In the above example, @key{C-u} is bound to the function -@code{universal-argument}, and @key{C-o} is bound to run the macro +In the above example, @kbd{C-u} is bound to the function +@code{universal-argument}, +@kbd{M-DEL} is bound to the function @code{backward-kill-word}, and +@kbd{C-o} is bound to run the macro expressed on the right hand side (that is, to insert the text @samp{> output} into the line). +A number of symbolic character names are recognized while +processing this key binding syntax: +@var{DEL}, +@var{ESC}, +@var{ESCAPE}, +@var{LFD}, +@var{NEWLINE}, +@var{RET}, +@var{RETURN}, +@var{RUBOUT}, +@var{SPACE}, +@var{SPC}, +and +@var{TAB}. + @item @w{"@var{keyseq}": @var{function-name} or @var{macro}} @var{keyseq} differs from @var{keyname} above in that strings denoting an entire key sequence can be specified, by placing @@ -559,9 +627,9 @@ special character names are not recognized. "\e[11~": "Function Key 1" @end example -In the above example, @key{C-u} is bound to the function +In the above example, @kbd{C-u} is again bound to the function @code{universal-argument} (just as it was in the first example), -@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file}, +@samp{@kbd{C-x} @kbd{C-r}} is bound to the function @code{re-read-init-file}, and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert the text @samp{Function Key 1}. @@ -606,11 +674,11 @@ horizontal tab @item \v vertical tab @item \@var{nnn} -the character whose @code{ASCII} code is the octal value @var{nnn} -(one to three digits) -@item \x@var{nnn} -the character whose @code{ASCII} code is the hexadecimal value @var{nnn} +the eight-bit character whose value is the octal value @var{nnn} (one to three digits) +@item \x@var{HH} +the eight-bit character whose value is the hexadecimal value @var{HH} +(one or two hex digits) @end table When entering the text of a macro, single or double quotes must @@ -619,7 +687,7 @@ Unquoted text is assumed to be a function name. In the macro body, the backslash escapes described above are expanded. Backslash will quote any other character in the macro text, including @samp{"} and @samp{'}. -For example, the following binding will make @samp{C-x \} +For example, the following binding will make @samp{@kbd{C-x} \} insert a single @samp{\} into the line: @example "\C-x\\": "\\" @@ -663,7 +731,8 @@ for instance. @item application The @var{application} construct is used to include application-specific settings. Each program using the Readline -library sets the @var{application name}, and you can test for it. +library sets the @var{application name}, and you can test for +a particular value. This could be used to bind key sequences to functions useful for a specific program. For instance, the following command adds a key sequence that quotes the current or previous word in Bash: @@ -686,6 +755,7 @@ the test fails. @item $include This directive takes a single filename as an argument and reads commands and bindings from that file. +For example, the following directive reads from @file{/etc/inputrc}: @example $include /etc/inputrc @end example @@ -694,20 +764,20 @@ $include /etc/inputrc @node Sample Init File @subsection Sample Init File -Here is an example of an inputrc file. This illustrates key +Here is an example of an @var{inputrc} file. This illustrates key binding, variable assignment, and conditional syntax. @example @page # This file controls the behaviour of line input editing for -# programs that use the Gnu Readline library. Existing programs -# include FTP, Bash, and Gdb. +# programs that use the GNU Readline library. Existing +# programs include FTP, Bash, and GDB. # # You can re-read the inputrc file with C-x C-r. # Lines beginning with '#' are comments. # -# First, include any systemwide bindings and variable assignments from -# /etc/Inputrc +# First, include any systemwide bindings and variable +# assignments from /etc/Inputrc $include /etc/Inputrc # @@ -759,10 +829,12 @@ TAB: complete $if Bash # edit the path "\C-xp": "PATH=$@{PATH@}\e\C-e\C-a\ef\C-f" -# prepare to type a quoted word -- insert open and close double quotes +# prepare to type a quoted word -- +# insert open and close double quotes # and move to just after the open quote "\C-x\"": "\"\"\C-b" -# insert a backslash (testing backslash escapes in sequences and macros) +# insert a backslash (testing backslash escapes +# in sequences and macros) "\C-x\\": "\\" # Quote the current or previous word "\C-xq": "\eb\"\ef\"" @@ -778,16 +850,16 @@ set bell-style visible # don't strip characters to 7 bits when reading set input-meta on -# allow iso-latin1 characters to be inserted rather than converted to -# prefix-meta sequences +# allow iso-latin1 characters to be inserted rather +# than converted to prefix-meta sequences set convert-meta off -# display characters with the eighth bit set directly rather than -# as meta-prefixed characters +# display characters with the eighth bit set directly +# rather than as meta-prefixed characters set output-meta on -# if there are more than 150 possible completions for a word, ask the -# user if he wants to see all of them +# if there are more than 150 possible completions for +# a word, ask the user if he wants to see all of them set completion-query-items 150 # For FTP @@ -819,12 +891,12 @@ You can list your key bindings by executing @w{@code{bind -P}} or, for a more terse format, suitable for an @var{inputrc} file, @w{@code{bind -p}}. (@xref{Bash Builtins}.) @end ifset - Command names without an accompanying key sequence are unbound by default. -In the following descriptions, @var{point} refers to the current cursor -position, and @var{mark} refers to a cursor position saved by the + +In the following descriptions, @dfn{point} refers to the current cursor +position, and @dfn{mark} refers to a cursor position saved by the @code{set-mark} command. -The text between the point and mark is referred to as the @var{region}. +The text between the point and mark is referred to as the @dfn{region}. @node Commands For Moving @subsection Commands For Moving @@ -862,25 +934,29 @@ Refresh the current line. By default, this is unbound. @subsection Commands For Manipulating The History @ftable @code -@item accept-line (Newline, Return) +@item accept-line (Newline or Return) @ifset BashFeatures -Accept the line regardless of where the cursor is. If this line is +Accept the line regardless of where the cursor is. +If this line is non-empty, add it to the history list according to the setting of -the @code{HISTCONTROL} and @code{HISTIGNORE} variables. -If this line was a history line, then restore the history line to its -original state. +the @env{HISTCONTROL} and @env{HISTIGNORE} variables. +If this line is a modified history line, then restore the history line +to its original state. @end ifset @ifclear BashFeatures -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list. If this line was a history -line, then restore the history line to its original state. +Accept the line regardless of where the cursor is. +If this line is +non-empty, it may be added to the history list for future recall with +@code{add_history()}. +If this line is a modified history line, the history line is restored +to its original state. @end ifclear @item previous-history (C-p) -Move `up' through the history list. +Move `back' through the history list, fetching the previous command. @item next-history (C-n) -Move `down' through the history list. +Move `forward' through the history list, fetching the next command. @item beginning-of-history (M-<) Move to the first line in the history. @@ -920,12 +996,13 @@ is a non-incremental search. By default, this command is unbound. @item yank-nth-arg (M-C-y) Insert the first argument to the previous command (usually -the second word on the previous line). With an argument @var{n}, +the second word on the previous line) at point. +With an argument @var{n}, insert the @var{n}th word from the previous command (the words in the previous command begin with word 0). A negative argument inserts the @var{n}th word from the end of the previous command. -@item yank-last-arg (M-., M-_) +@item yank-last-arg (M-. or M-_) Insert last argument to the previous command (the last word of the previous history entry). With an argument, behave exactly like @code{yank-nth-arg}. @@ -939,10 +1016,10 @@ list, inserting the last argument of each line in turn. @ftable @code @item delete-char (C-d) -Delete the character under the cursor. If the cursor is at the +Delete the character at point. If point is at the beginning of the line, there are no characters in the line, and the last character typed was not bound to @code{delete-char}, then -return @code{EOF}. +return @sc{eof}. @item backward-delete-char (Rubout) Delete the character behind the cursor. A numeric argument means @@ -953,16 +1030,16 @@ Delete the character under the cursor, unless the cursor is at the end of the line, in which case the character behind the cursor is deleted. By default, this is not bound to a key. -@item quoted-insert (C-q, C-v) +@item quoted-insert (C-q or C-v) Add the next character typed to the line verbatim. This is -how to insert key sequences like @key{C-q}, for example. +how to insert key sequences like @kbd{C-q}, for example. @ifclear BashFeatures -@item tab-insert (M-TAB) +@item tab-insert (M-@key{TAB}) Insert a tab character. @end ifclear -@item self-insert (a, b, A, 1, !, ...) +@item self-insert (a, b, A, 1, !, @dots{}) Insert yourself. @item transpose-chars (C-t) @@ -976,6 +1053,8 @@ Negative arguments have no effect. @item transpose-words (M-t) Drag the word before point past the word after point, moving point past that word as well. +If the insertion point is at the end of the line, this transposes +the last two words on the line. @item upcase-word (M-u) Uppercase the current (or following) word. With a negative argument, @@ -989,6 +1068,20 @@ lowercase the previous word, but do not move the cursor. Capitalize the current (or following) word. With a negative argument, capitalize the previous word, but do not move the cursor. +@item overwrite-mode () +Toggle overwrite mode. With an explicit positive numeric argument, +switches to overwrite mode. With an explicit non-positive numeric +argument, switches to insert mode. This command affects only +@code{emacs} mode; @code{vi} mode does overwrite differently. +Each call to @code{readline()} starts in insert mode. + +In overwrite mode, characters bound to @code{self-insert} replace +the text at point rather than pushing the text to the right. +Characters bound to @code{backward-delete-char} replace the character +before point with a space. + +By default, this command is unbound. + @end ftable @node Commands For Killing @@ -1006,7 +1099,7 @@ Kill backward to the beginning of the line. Kill backward from the cursor to the beginning of the current line. @item kill-whole-line () -Kill all characters on the current line, no matter point is. +Kill all characters on the current line, no matter where point is. By default, this is unbound. @item kill-word (M-d) @@ -1014,7 +1107,7 @@ Kill from point to the end of the current word, or if between words, to the end of the next word. Word boundaries are the same as @code{forward-word}. -@item backward-kill-word (M-DEL) +@item backward-kill-word (M-@key{DEL}) Kill the word behind point. Word boundaries are the same as @code{backward-word}. @@ -1044,21 +1137,20 @@ The word boundaries are the same as @code{forward-word}. By default, this command is unbound. @item yank (C-y) -Yank the top of the kill ring into the buffer at the current -cursor position. +Yank the top of the kill ring into the buffer at point. @item yank-pop (M-y) Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is yank or yank-pop. +the prior command is @code{yank} or @code{yank-pop}. @end ftable @node Numeric Arguments @subsection Specifying Numeric Arguments @ftable @code -@item digit-argument (M-0, M-1, ... M--) +@item digit-argument (@kbd{M-0}, @kbd{M-1}, @dots{} @kbd{M--}) Add this digit to the argument already accumulating, or start a new -argument. @key{M--} starts a negative argument. +argument. @kbd{M--} starts a negative argument. @item universal-argument () This is another way to specify an argument. @@ -1079,13 +1171,9 @@ By default, this is not bound to a key. @subsection Letting Readline Type For You @ftable @code -@item complete (TAB) -Attempt to do completion on the text before the cursor. This is -application-specific. Generally, if you are typing a filename -argument, you can do filename completion; if you are typing a command, -you can do command completion; if you are typing in a symbol to GDB, you -can do symbol name completion; if you are typing in a variable to Bash, -you can do variable name completion, and so on. +@item complete (@key{TAB}) +Attempt to perform completion on the text before point. +The actual completion performed is application-specific. @ifset BashFeatures Bash attempts completion treating the text as a variable (if the text begins with @samp{$}), username (if the text begins with @@ -1093,9 +1181,12 @@ text begins with @samp{$}), username (if the text begins with command (including aliases and functions) in turn. If none of these produces a match, filename completion is attempted. @end ifset +@ifclear BashFeatures +The default is filename completion. +@end ifclear @item possible-completions (M-?) -List the possible completions of the text before the cursor. +List the possible completions of the text before point. @item insert-completions (M-*) Insert all completions of the text before point that would have @@ -1106,12 +1197,13 @@ Similar to @code{complete}, but replaces the word to be completed with a single match from the list of possible completions. Repeated execution of @code{menu-complete} steps through the list of possible completions, inserting each match in turn. -At the end of the list of completions, the bell is rung and the -original text is restored. +At the end of the list of completions, the bell is rung +(subject to the setting of @code{bell-style}) +and the original text is restored. An argument of @var{n} moves @var{n} positions forward in the list of matches; a negative argument may be used to move backward through the list. -This command is intended to be bound to @code{TAB}, but is unbound +This command is intended to be bound to @key{TAB}, but is unbound by default. @item delete-char-or-list () @@ -1164,7 +1256,7 @@ in that order. List the possible completions of the text before point, treating it as a command name. -@item dynamic-complete-history (M-TAB) +@item dynamic-complete-history (M-@key{TAB}) Attempt completion on the text before point, comparing the text against lines from the history list for possible completion matches. @@ -1211,12 +1303,12 @@ ring the terminal's bell (subject to the setting of If the metafied character @var{x} is lowercase, run the command that is bound to the corresponding uppercase character. -@item prefix-meta (ESC) -Make the next character typed be metafied. This is for keyboards -without a meta key. Typing @samp{ESC f} is equivalent to typing -@samp{M-f}. +@item prefix-meta (@key{ESC}) +Metafy the next character typed. This is for keyboards +without a meta key. Typing @samp{@key{ESC} f} is equivalent to typing +@kbd{M-f}. -@item undo (C-_, C-x C-u) +@item undo (C-_ or C-x C-u) Incremental undo, separately remembered for each line. @item revert-line (M-r) @@ -1232,7 +1324,7 @@ command enough times to get back to the beginning. Perform tilde expansion on the current word. @item set-mark (C-@@) -Set the mark to the current point. If a +Set the mark to the point. If a numeric argument is supplied, the mark is set to that position. @item exchange-point-and-mark (C-x C-x) @@ -1249,12 +1341,19 @@ of that character. A negative count searches for subsequent occurrences. @item insert-comment (M-#) -The value of the @code{comment-begin} -variable is inserted at the beginning of the current line, -and the line is accepted as if a newline had been typed. +Without a numeric argument, the value of the @code{comment-begin} +variable is inserted at the beginning of the current line. +If a numeric argument is supplied, this command acts as a toggle: if +the characters at the beginning of the line do not match the value +of @code{comment-begin}, the value is inserted, otherwise +the characters in @code{comment-begin} are deleted from the beginning of +the line. +In either case, the line is accepted as if a newline had been typed. @ifset BashFeatures The default value of @code{comment-begin} causes this command to make the current line a shell comment. +If a numeric argument causes the comment character to be removed, the line +will be executed by the shell. @end ifset @item dump-functions () @@ -1271,18 +1370,27 @@ of an @var{inputrc} file. This command is unbound by default. @item dump-macros () Print all of the Readline key sequences bound to macros and the -strings they ouput. If a numeric argument is supplied, +strings they output. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an @var{inputrc} file. This command is unbound by default. @ifset BashFeatures +@item glob-complete-word (M-g) +The word before point is treated as a pattern for pathname expansion, +with an asterisk implicitly appended. This pattern is used to +generate a list of matching file names for possible completions. + @item glob-expand-word (C-x *) The word before point is treated as a pattern for pathname expansion, and the list of matching file names is inserted, replacing the word. +If a numeric argument is supplied, a @samp{*} is appended before +pathname expansion. @item glob-list-expansions (C-x g) The list of expansions that would have been generated by @code{glob-expand-word} is displayed, and the line is redrawn. +If a numeric argument is supplied, a @samp{*} is appended before +pathname expansion. @item display-shell-version (C-x C-v) Display version information about the current instance of Bash. @@ -1305,7 +1413,7 @@ Perform alias expansion on the current line (@pxref{Aliases}). @item history-and-alias-expand-line () Perform history and alias expansion on the current line. -@item insert-last-argument (M-., M-_) +@item insert-last-argument (M-. or M-_) A synonym for @code{yank-last-arg}. @item operate-and-get-next (C-o) @@ -1313,13 +1421,26 @@ Accept the current line for execution and fetch the next line relative to the current line from the history for editing. Any argument is ignored. -@item emacs-editing-mode (C-e) -When in @code{vi} editing mode, this causes a switch back to -@code{emacs} editing mode, as if the command @samp{set -o emacs} had -been executed. +@item edit-and-execute-command (C-xC-e) +Invoke an editor on the current command line, and execute the result as shell +commands. +Bash attempts to invoke +@code{$FCEDIT}, @code{$EDITOR}, and @code{emacs} +as the editor, in that order. @end ifset +@ifclear BashFeatures +@item emacs-editing-mode (C-e) +When in @code{vi} command mode, this causes a switch to @code{emacs} +editing mode. + +@item vi-editing-mode (M-C-j) +When in @code{emacs} editing mode, this causes a switch to @code{vi} +editing mode. + +@end ifclear + @end ftable @node Readline vi Mode @@ -1337,7 +1458,8 @@ commands (@pxref{The Set Builtin}). @end ifset @ifclear BashFeatures In order to switch interactively between @code{emacs} and @code{vi} -editing modes, use the command M-C-j (toggle-editing-mode). +editing modes, use the command @kbd{M-C-j} (bound to emacs-editing-mode +when in @code{vi} mode and to vi-editing-mode in @code{emacs} mode). @end ifclear The Readline default is @code{emacs} mode. @@ -1374,20 +1496,20 @@ described above (@pxref{Commands For Completion}) is performed. First, the actions specified by the compspec are used. Only matches which are prefixed by the word being completed are returned. -When the @samp{-f} or @samp{-d} option is used for filename or -directory name completion, the shell variable @code{FIGNORE} is +When the @option{-f} or @option{-d} option is used for filename or +directory name completion, the shell variable @env{FIGNORE} is used to filter the matches. -@xref{Bash Variables}, for a description of @code{FIGNORE}. +@xref{Bash Variables}, for a description of @env{FIGNORE}. Any completions specified by a filename expansion pattern to the -@samp{-G} option are generated next. +@option{-G} option are generated next. The words generated by the pattern need not match the word being completed. -The @code{GLOBIGNORE} shell variable is not used to filter the matches, -but the @code{FIGNORE} shell variable is used. +The @env{GLOBIGNORE} shell variable is not used to filter the matches, +but the @env{FIGNORE} shell variable is used. -Next, the string specified as the argument to the @samp{-W} option +Next, the string specified as the argument to the @option{-W} option is considered. -The string is first split using the characters in the @code{IFS} +The string is first split using the characters in the @env{IFS} special variable as delimiters. Shell quoting is honored. Each word is then expanded using @@ -1400,12 +1522,12 @@ The results of the expansion are prefix-matched against the word being completed, and the matching words become the possible completions. After these matches have been generated, any shell function or command -specified with the @samp{-F} and @samp{-C} options is invoked. -When the command or function is invoked, the @code{COMP_LINE} and -@code{COMP_POINT} variables are assigned values as described above +specified with the @option{-F} and @option{-C} options is invoked. +When the command or function is invoked, the @env{COMP_LINE} and +@env{COMP_POINT} variables are assigned values as described above (@pxref{Bash Variables}). -If a shell function is being invoked, the @code{COMP_WORDS} and -@code{COMP_CWORD} variables are also set. +If a shell function is being invoked, the @env{COMP_WORDS} and +@env{COMP_CWORD} variables are also set. When the function or command is invoked, the first argument is the name of the command whose arguments are being completed, the second argument is the word being completed, and the third argument @@ -1414,21 +1536,21 @@ No filtering of the generated completions against the word being completed is performed; the function or command has complete freedom in generating the matches. -Any function specified with @samp{-F} is invoked first. +Any function specified with @option{-F} is invoked first. The function may use any of the shell facilities, including the @code{compgen} builtin described below (@pxref{Programmable Completion Builtins}), to generate the matches. -It must put the possible completions in the @code{COMPREPLY} array +It must put the possible completions in the @env{COMPREPLY} array variable. -Next, any command specified with the @samp{-C} option is invoked +Next, any command specified with the @option{-C} option is invoked in an environment equivalent to command substitution. It should print a list of completions, one per line, to the standard output. Backslash may be used to escape a newline, if necessary. After all of the possible completions are generated, any filter -specified with the @samp{-X} option is applied to the list. +specified with the @option{-X} option is applied to the list. The filter is a pattern as used for pathname expansion; a @samp{&} in the pattern is replaced with the text of the word being completed. A literal @samp{&} may be escaped with a backslash; the backslash @@ -1437,15 +1559,28 @@ Any completion that matches the pattern will be removed from the list. A leading @samp{!} negates the pattern; in this case any completion not matching the pattern will be removed. -Finally, any prefix and suffix specified with the @samp{-P} and @samp{-S} +Finally, any prefix and suffix specified with the @option{-P} and @option{-S} options are added to each member of the completion list, and the result is returned to the Readline completion code as the list of possible completions. -If a compspec is found, whatever it generates is returned to the completion -code as the full set of possible completions. -The default Bash completions are not attempted, and the Readline -default of filename completion is disabled. +If the previously-applied actions do not generate any matches, and the +@option{-o dirnames} option was supplied to @code{complete} when the +compspec was defined, directory name completion is attempted. + +By default, if a compspec is found, whatever it generates is returned to +the completion code as the full set of possible completions. +The default Bash completions are not attempted, and the Readline default +of filename completion is disabled. +If the @option{-o default} option was supplied to @code{complete} when the +compspec was defined, Readline's default completion will be performed +if the compspec generates no matches. + +When a compspec indicates that directory name completion is desired, +the programmable completion functions force Readline to append a slash +to completed names which are symbolic links to directories, subject to +the value of the @var{mark-directories} Readline variable, regardless +of the setting of the @var{mark-symlinked-directories} Readline variable. @node Programmable Completion Builtins @section Programmable Completion Builtins @@ -1464,9 +1599,9 @@ facilities. Generate possible completion matches for @var{word} according to the @var{option}s, which may be any option accepted by the @code{complete} -builtin with the exception of @samp{-p} and @samp{-r}, and write +builtin with the exception of @option{-p} and @option{-r}, and write the matches to the standard output. -When using the @samp{-F} or @samp{-C} options, the various shell variables +When using the @option{-F} or @option{-C} options, the various shell variables set by the programmable completion facilities, while available, will not have useful values. @@ -1482,17 +1617,17 @@ matches were generated. @item complete @btindex complete @example -@code{complete [-abcdefjkvu] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}] +@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}] [-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}] [-C @var{command}] @var{name} [@var{name} @dots{}]} @code{complete -pr [@var{name} @dots{}]} @end example Specify how arguments to each @var{name} should be completed. -If the @samp{-p} option is supplied, or if no options are supplied, existing +If the @option{-p} option is supplied, or if no options are supplied, existing completion specifications are printed in a way that allows them to be reused as input. -The @samp{-r} option removes a completion specification for +The @option{-r} option removes a completion specification for each @var{name}, or, if no @var{name}s are supplied, all completion specifications. @@ -1500,19 +1635,45 @@ The process of applying these completion specifications when word completion is attempted is described above (@pxref{Programmable Completion}). Other options, if specified, have the following meanings. -The arguments to the @samp{-G}, @samp{-W}, and @samp{-X} options -(and, if necessary, the @samp{-P} and @samp{-S} options) +The arguments to the @option{-G}, @option{-W}, and @option{-X} options +(and, if necessary, the @option{-P} and @option{-S} options) should be quoted to protect them from expansion before the @code{complete} builtin is invoked. + +@table @code +@item -o @var{comp-option} +The @var{comp-option} controls several aspects of the compspec's behavior +beyond the simple generation of completions. +@var{comp-option} may be one of: + @table @code + +@item default +Use Readline's default filename completion if the compspec generates +no matches. + +@item dirnames +Perform directory name completion if the compspec generates no matches. + +@item filenames +Tell Readline that the compspec generates filenames, so it can perform any +filename\-specific processing (like adding a slash to directory names or +suppressing trailing spaces). This option is intended to be used with +shell functions specified with @option{-F}. + +@item nospace +Tell Readline not to append a space (the default) to words completed at +the end of the line. +@end table + @item -A @var{action} The @var{action} may be one of the following to generate a list of possible completions: @table @code @item alias -Alias names. May also be specified as @samp{-a}. +Alias names. May also be specified as @option{-a}. @item arrayvar Array variable names. @@ -1521,13 +1682,13 @@ Array variable names. Readline key binding names (@pxref{Bindable Readline Commands}). @item builtin -Names of shell builtin commands. May also be specified as @samp{-b}. +Names of shell builtin commands. May also be specified as @option{-b}. @item command -Command names. May also be specified as @samp{-c}. +Command names. May also be specified as @option{-c}. @item directory -Directory names. May also be specified as @samp{-d}. +Directory names. May also be specified as @option{-d}. @item disabled Names of disabled shell builtins. @@ -1536,32 +1697,38 @@ Names of disabled shell builtins. Names of enabled shell builtins. @item export -Names of exported shell variables. May also be specified as @samp{-e}. +Names of exported shell variables. May also be specified as @option{-e}. @item file -File names. May also be specified as @samp{-f}. +File names. May also be specified as @option{-f}. @item function Names of shell functions. +@item group +Group names. May also be specified as @option{-g}. + @item helptopic Help topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}). @item hostname Hostnames, as taken from the file specified by the -@code{HOSTFILE} shell variable (@pxref{Bash Variables}). +@env{HOSTFILE} shell variable (@pxref{Bash Variables}). @item job -Job names, if job control is active. May also be specified as @samp{-j}. +Job names, if job control is active. May also be specified as @option{-j}. @item keyword -Shell reserved words. May also be specified as @samp{-k}. +Shell reserved words. May also be specified as @option{-k}. @item running Names of running jobs, if job control is active. +@item service +Service names. May also be specified as @option{-s}. + @item setopt -Valid arguments for the @samp{-o} option to the @code{set} builtin +Valid arguments for the @option{-o} option to the @code{set} builtin (@pxref{The Set Builtin}). @item shopt @@ -1575,10 +1742,10 @@ Signal names. Names of stopped jobs, if job control is active. @item user -User names. May also be specified as @samp{-u}. +User names. May also be specified as @option{-u}. @item variable -Names of all shell variables. May also be specified as @samp{-v}. +Names of all shell variables. May also be specified as @option{-v}. @end table @item -G @var{globpat} @@ -1587,7 +1754,7 @@ the possible completions. @item -W @var{wordlist} The @var{wordlist} is split using the characters in the -@code{IFS} special variable as delimiters, and each resultant word +@env{IFS} special variable as delimiters, and each resultant word is expanded. The possible completions are the members of the resultant list which match the word being completed. @@ -1600,7 +1767,7 @@ used as the possible completions. The shell function @var{function} is executed in the current shell environment. When it finishes, the possible completions are retrieved from the value -of the @code{COMPREPLY} array variable. +of the @env{COMPREPLY} array variable. @item -X @var{filterpat} @var{filterpat} is a pattern as used for filename expansion. @@ -1620,7 +1787,7 @@ after all other options have been applied. @end table The return value is true unless an invalid option is supplied, an option -other than @samp{-p} or @samp{-r} is supplied without a @var{name} +other than @option{-p} or @option{-r} is supplied without a @var{name} argument, an attempt is made to remove a completion specification for a @var{name} for which no specification exists, or an error occurs adding a completion specification. diff --git a/gnu/lib/libreadline/examples/excallback.c b/gnu/lib/libreadline/examples/excallback.c index c4588829954..3f77b0fa523 100644 --- a/gnu/lib/libreadline/examples/excallback.c +++ b/gnu/lib/libreadline/examples/excallback.c @@ -153,6 +153,8 @@ process_line(char *line) } else { fprintf(stderr, "|%s|\n", line); } + + free (line); } int diff --git a/gnu/lib/libreadline/histexpand.c b/gnu/lib/libreadline/histexpand.c index 30c8f913379..b0b9fb72f40 100644 --- a/gnu/lib/libreadline/histexpand.c +++ b/gnu/lib/libreadline/histexpand.c @@ -41,11 +41,7 @@ # include <unistd.h> #endif -#if defined (HAVE_STRING_H) -# include <string.h> -#else -# include <strings.h> -#endif /* !HAVE_STRING_H */ +#include "rlmbutil.h" #include "history.h" #include "histlib.h" @@ -56,6 +52,10 @@ #define HISTORY_WORD_DELIMITERS " \t\n;&()|<>" #define HISTORY_QUOTE_CHARACTERS "\"'`" +typedef int _hist_search_func_t PARAMS((const char *, int)); + +extern int rl_byte_oriented; /* declared in mbutil.c */ + static char error_pointer; static char *subst_lhs; @@ -63,10 +63,10 @@ static char *subst_rhs; static int subst_lhs_len; static int subst_rhs_len; -static char *get_history_word_specifier __P((char *, char *, int *)); -static char *history_find_word __P((char *, int)); +static char *get_history_word_specifier PARAMS((char *, char *, int *)); +static char *history_find_word PARAMS((char *, int)); -static char *quote_breaks __P((char *)); +static char *quote_breaks PARAMS((char *)); /* Variables exported by this file. */ /* The character that represents the start of a history expansion @@ -91,9 +91,12 @@ char *history_no_expand_chars = " \t\n\r="; The default is 0. */ int history_quotes_inhibit_expansion = 0; +/* Used to split words by history_tokenize_internal. */ +char *history_word_delimiters = HISTORY_WORD_DELIMITERS; + /* If set, this points to a function that is called to verify that a particular history expansion should be performed. */ -Function *history_inhibit_expansion_function; +rl_linebuf_func_t *history_inhibit_expansion_function; /* **************************************************************** */ /* */ @@ -122,7 +125,7 @@ static char *search_match; line = get_history_event ("!echo:p", &index, 0); */ char * get_history_event (string, caller_index, delimiting_quote) - char *string; + const char *string; int *caller_index; int delimiting_quote; { @@ -130,7 +133,7 @@ get_history_event (string, caller_index, delimiting_quote) register char c; HIST_ENTRY *entry; int which, sign, local_index, substring_okay; - Function *search_func; + _hist_search_func_t *search_func; char *temp; /* The event can be specified in a number of ways. @@ -199,15 +202,33 @@ get_history_event (string, caller_index, delimiting_quote) /* Only a closing `?' or a newline delimit a substring search string. */ for (local_index = i; c = string[i]; i++) - if ((!substring_okay && (whitespace (c) || c == ':' || - (history_search_delimiter_chars && member (c, history_search_delimiter_chars)) || - string[i] == delimiting_quote)) || - string[i] == '\n' || - (substring_okay && string[i] == '?')) - break; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int v; + mbstate_t ps; + + memset (&ps, 0, sizeof (mbstate_t)); + /* These produce warnings because we're passing a const string to a + function that takes a non-const string. */ + _rl_adjust_point (string, i, &ps); + if ((v = _rl_get_char_len (string + i, &ps)) > 1) + { + i += v - 1; + continue; + } + } + else +#endif /* HANDLE_MULTIBYTE */ + if ((!substring_okay && (whitespace (c) || c == ':' || + (history_search_delimiter_chars && member (c, history_search_delimiter_chars)) || + string[i] == delimiting_quote)) || + string[i] == '\n' || + (substring_okay && string[i] == '?')) + break; which = i - local_index; - temp = xmalloc (1 + which); + temp = (char *)xmalloc (1 + which); if (which) strncpy (temp, string + local_index, which); temp[which] = '\0'; @@ -309,7 +330,7 @@ quote_breaks (s) len += 2; } - r = ret = xmalloc (len); + r = ret = (char *)xmalloc (len); *r++ = '\''; for (p = s; p && *p; ) { @@ -340,7 +361,8 @@ hist_error(s, start, current, errtype) char *s; int start, current, errtype; { - char *temp, *emsg; + char *temp; + const char *emsg; int ll, elen, len; ll = current - start; @@ -374,7 +396,7 @@ hist_error(s, start, current, errtype) } len = ll + elen + 3; - temp = xmalloc (len); + temp = (char *)xmalloc (len); strncpy (temp, s + start, ll); strlcat (temp, ": ", len); strlcat (temp, emsg, len); @@ -399,17 +421,37 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr) int *iptr, delimiter, is_rhs, *lenptr; { register int si, i, j, k; - char *s = (char *) NULL; + char *s; +#if defined (HANDLE_MULTIBYTE) + mbstate_t ps; +#endif + s = (char *)NULL; i = *iptr; +#if defined (HANDLE_MULTIBYTE) + memset (&ps, 0, sizeof (mbstate_t)); + _rl_adjust_point (str, i, &ps); +#endif + for (si = i; str[si] && str[si] != delimiter; si++) - if (str[si] == '\\' && str[si + 1] == delimiter) - si++; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int v; + if ((v = _rl_get_char_len (str + si, &ps)) > 1) + si += v - 1; + else if (str[si] == '\\' && str[si + 1] == delimiter) + si++; + } + else +#endif /* HANDLE_MULTIBYTE */ + if (str[si] == '\\' && str[si + 1] == delimiter) + si++; if (si > i || is_rhs) { - s = xmalloc (si - i + 1); + s = (char *)xmalloc (si - i + 1); for (j = 0, k = i; k < si; j++, k++) { /* Remove a backslash quoting the search string delimiter. */ @@ -436,13 +478,13 @@ postproc_subst_rhs () char *new; int i, j, new_size; - new = xmalloc (new_size = subst_rhs_len + subst_lhs_len); + new = (char *)xmalloc (new_size = subst_rhs_len + subst_lhs_len); for (i = j = 0; i < subst_rhs_len; i++) { if (subst_rhs[i] == '&') { if (j + subst_lhs_len >= new_size) - new = xrealloc (new, (new_size = new_size * 2 + subst_lhs_len)); + new = (char *)xrealloc (new, (new_size = new_size * 2 + subst_lhs_len)); strlcpy (new + j, subst_lhs, new_size - j); j += subst_lhs_len; } @@ -452,7 +494,7 @@ postproc_subst_rhs () if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&') i++; if (j >= new_size) - new = xrealloc (new, new_size *= 2); + new = (char *)xrealloc (new, new_size *= 2); new[j++] = subst_rhs[i]; } } @@ -478,8 +520,13 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) int substitute_globally, want_quotes, print_only; char *event, *temp, *result, *tstr, *t, c, *word_spec; int result_len; +#if defined (HANDLE_MULTIBYTE) + mbstate_t ps; + + memset (&ps, 0, sizeof (mbstate_t)); +#endif - result = xmalloc (result_len = 128); + result = (char *)xmalloc (result_len = 128); i = start; @@ -508,8 +555,21 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) quote, then this expansion takes place inside of the quoted string. If we have to search for some text ("!foo"), allow the delimiter to end the search string. */ - if (i && (string[i - 1] == '\'' || string[i - 1] == '"')) - quoted_search_delimiter = string[i - 1]; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int c, l; + l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY); + c = string[l]; + /* XXX - original patch had i - 1 ??? If i == 0 it would fail. */ + if (i && (c == '\'' || c == '"')) + quoted_search_delimiter = c; + } + else +#endif /* HANDLE_MULTIBYTE */ + if (i && (string[i - 1] == '\'' || string[i - 1] == '"')) + quoted_search_delimiter = string[i - 1]; + event = get_history_event (string, &i, quoted_search_delimiter); } @@ -622,13 +682,26 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) case '&': case 's': { - char *new_event, *t; + char *new_event; int delimiter, failed, si, l_temp; if (c == 's') { if (i + 2 < (int)strlen (string)) - delimiter = string[i + 2]; + { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + _rl_adjust_point (string, i + 2, &ps); + if (_rl_get_char_len (string + i + 2, &ps) > 1) + delimiter = 0; + else + delimiter = string[i + 2]; + } + else +#endif /* HANDLE_MULTIBYTE */ + delimiter = string[i + 2]; + } else break; /* no search delimiter */ @@ -692,7 +765,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) if (STREQN (temp+si, subst_lhs, subst_lhs_len)) { int len = subst_rhs_len - subst_lhs_len + l_temp; - new_event = xmalloc (1 + len); + new_event = (char *)xmalloc (1 + len); strncpy (new_event, temp, si); strncpy (new_event + si, subst_rhs, subst_rhs_len); strncpy (new_event + si + subst_rhs_len, @@ -741,7 +814,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) char *x; if (want_quotes == 'q') - x = single_quote (temp); + x = sh_single_quote (temp); else if (want_quotes == 'x') x = quote_breaks (temp); else @@ -753,7 +826,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) n = strlen (temp); if (n >= result_len) - result = xrealloc (result, n + 2); + result = (char *)xrealloc (result, n + 2); strlcpy (result, temp, n + 2); free (temp); @@ -784,7 +857,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) { \ while (j >= result_len) \ result_len += 128; \ - result = xrealloc (result, result_len); \ + result = (char *)xrealloc (result, result_len); \ } \ strlcpy (result + j - sl, s, result_len - j + sl); \ } \ @@ -794,7 +867,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) do \ { \ if (j >= result_len - 1) \ - result = xrealloc (result, result_len += 64); \ + result = (char *)xrealloc (result, result_len += 64); \ result[j++] = c; \ result[j] = '\0'; \ } \ @@ -813,9 +886,17 @@ history_expand (hstring, output) int result_len; char *result; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; + mbstate_t ps; +#endif + /* Used when adding the string. */ char *temp; + if (output == 0) + return 0; + /* Setting the history expansion character to 0 inhibits all history expansion. */ if (history_expansion_char == 0) @@ -825,7 +906,7 @@ history_expand (hstring, output) } /* Prepare the buffer for printing error messages. */ - result = xmalloc (result_len = 256); + result = (char *)xmalloc (result_len = 256); result[0] = '\0'; only_printing = modified = 0; @@ -842,7 +923,7 @@ history_expand (hstring, output) that is the substitution that we do. */ if (hstring[0] == history_subst_char) { - string = xmalloc (l + 5); + string = (char *)xmalloc (l + 5); string[0] = string[1] = history_expansion_char; string[2] = ':'; @@ -852,6 +933,10 @@ history_expand (hstring, output) } else { +#if defined (HANDLE_MULTIBYTE) + memset (&ps, 0, sizeof (mbstate_t)); +#endif + string = hstring; /* If not quick substitution, still maybe have to do expansion. */ @@ -859,13 +944,26 @@ history_expand (hstring, output) is NOT an expansion. */ for (i = 0; string[i]; i++) { +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int v; + v = _rl_get_char_len (string + i, &ps); + if (v > 1) + { + i += v - 1; + continue; + } + } +#endif /* HANDLE_MULTIBYTE */ + cc = string[i + 1]; - /* The history_comment_char, if set, appearing that the beginning + /* The history_comment_char, if set, appearing at the beginning of a word signifies that the rest of the line should not have history expansion performed on it. Skip the rest of the line and break out of the loop. */ if (history_comment_char && string[i] == history_comment_char && - (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))) + (i == 0 || member (string[i - 1], history_word_delimiters))) { while (string[i]) i++; @@ -923,6 +1021,30 @@ history_expand (hstring, output) continue; } +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int k, c; + + c = tchar; + memset (mb, 0, sizeof (mb)); + for (k = 0; k < MB_LEN_MAX; k++) + { + mb[k] = (char)c; + memset (&ps, 0, sizeof (mbstate_t)); + if (_rl_get_char_len (mb, &ps) == -2) + c = string[++i]; + else + break; + } + if (strlen (mb) > 1) + { + ADD_STRING (mb); + break; + } + } +#endif /* HANDLE_MULTIBYTE */ + if (tchar == history_expansion_char) tchar = -3; else if (tchar == history_comment_char) @@ -951,7 +1073,7 @@ history_expand (hstring, output) hist_string_extract_single_quoted (string, &i); slen = i - quote + 2; - temp = xmalloc (slen); + temp = (char *)xmalloc (slen); strncpy (temp, string + quote, slen); temp[slen - 1] = '\0'; ADD_STRING (temp); @@ -963,9 +1085,9 @@ history_expand (hstring, output) } case -2: /* history_comment_char */ - if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)) + if (i == 0 || member (string[i - 1], history_word_delimiters)) { - temp = xmalloc (l - i + 1); + temp = (char *)xmalloc (l - i + 1); strlcpy (temp, string + i, l - i + 1); ADD_STRING (temp); free (temp); @@ -997,7 +1119,7 @@ history_expand (hstring, output) { if (result) { - temp = xmalloc (1 + strlen (result)); + temp = (char *)xmalloc (1 + strlen (result)); strlcpy (temp, result, 1 + strlen(result)); ADD_STRING (temp); free (temp); @@ -1131,7 +1253,14 @@ get_history_word_specifier (spec, from, caller_index) i++; last = '$'; } - else if (!spec[i] || spec[i] == ':') /* could be modifier separator */ +#if 0 + else if (!spec[i] || spec[i] == ':') + /* check against `:' because there could be a modifier separator */ +#else + else + /* csh seems to allow anything to terminate the word spec here, + leaving it as an abbreviation. */ +#endif last = -1; /* x- abbreviates x-$ omitting word `$' */ } @@ -1151,7 +1280,7 @@ get_history_word_specifier (spec, from, caller_index) char * history_arg_extract (first, last, string) int first, last; - char *string; + const char *string; { register int i, len; char *result; @@ -1187,7 +1316,7 @@ history_arg_extract (first, last, string) { for (size = 0, i = first; i < last; i++) size += strlen (list[i]) + 1; - result = xmalloc (size + 1); + result = (char *)xmalloc (size + 1); result[0] = '\0'; for (i = first, offset = 0; i < last; i++) @@ -1217,13 +1346,18 @@ history_arg_extract (first, last, string) *INDP. */ static char ** history_tokenize_internal (string, wind, indp) - char *string; + const char *string; int wind, *indp; { char **result; register int i, start, result_index, size; int len, delimiter; + /* If we're searching for a string that's not part of a word (e.g., " "), + make sure we set *INDP to a reasonable value. */ + if (indp && wind != -1) + *indp = -1; + /* Get a token, and stuff it into RESULT. The tokens are split exactly where the shell would split them. */ for (i = result_index = size = 0, result = (char **)NULL; string[i]; ) @@ -1298,7 +1432,7 @@ history_tokenize_internal (string, wind, indp) continue; } - if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS))) + if (!delimiter && (member (string[i], history_word_delimiters))) break; if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS)) @@ -1315,7 +1449,7 @@ history_tokenize_internal (string, wind, indp) len = i - start; if (result_index + 2 >= size) result = (char **)xrealloc (result, ((size += 10) * sizeof (char *))); - result[result_index] = xmalloc (1 + len); + result[result_index] = (char *)xmalloc (1 + len); strncpy (result[result_index], string + start, len); result[result_index][len] = '\0'; result[++result_index] = (char *)NULL; @@ -1328,7 +1462,7 @@ history_tokenize_internal (string, wind, indp) parsed out of STRING. */ char ** history_tokenize (string) - char *string; + const char *string; { return (history_tokenize_internal (string, -1, (int *)NULL)); } @@ -1345,7 +1479,7 @@ history_find_word (line, ind) int i, wind; words = history_tokenize_internal (line, ind, &wind); - if (wind == -1) + if (wind == -1 || words == 0) return ((char *)NULL); s = words[wind]; for (i = 0; i < wind; i++) diff --git a/gnu/lib/libreadline/histfile.c b/gnu/lib/libreadline/histfile.c index 180f20ea3e2..a2dbd4f3e51 100644 --- a/gnu/lib/libreadline/histfile.c +++ b/gnu/lib/libreadline/histfile.c @@ -48,12 +48,26 @@ # include <unistd.h> #endif -#if defined (HAVE_STRING_H) -# include <string.h> -#else -# include <strings.h> -#endif /* !HAVE_STRING_H */ +#if defined (__EMX__) || defined (__CYGWIN__) +# undef HAVE_MMAP +#endif + +#ifdef HAVE_MMAP +# include <sys/mman.h> + +# ifdef MAP_FILE +# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE) +# define MAP_WFLAGS (MAP_FILE|MAP_SHARED) +# else +# define MAP_RFLAGS MAP_PRIVATE +# define MAP_WFLAGS MAP_SHARED +# endif + +# ifndef MAP_FAILED +# define MAP_FAILED ((void *)-1) +# endif +#endif /* HAVE_MMAP */ /* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment on win 95/98/nt), we want to open files with O_BINARY mode so that there @@ -84,9 +98,10 @@ extern int errno; filename to read_history (), or write_history (). */ static char * history_filename (filename) - char *filename; + const char *filename; { - char *return_val, *home; + char *return_val; + const char *home; int home_len; char dot; @@ -95,7 +110,7 @@ history_filename (filename) if (return_val) return (return_val); - home = get_env_value ("HOME"); + home = sh_get_env_value ("HOME"); if (home == 0 || *home == '\0') { errno = ENOENT; @@ -118,7 +133,7 @@ history_filename (filename) successful, or errno if not. */ int read_history (filename) - char *filename; + const char *filename; { return (read_history_range (filename, 0, -1)); } @@ -130,11 +145,11 @@ read_history (filename) ~/.history. Returns 0 if successful, or errno if not. */ int read_history_range (filename, from, to) - char *filename; + const char *filename; int from, to; { - register int line_start, line_end; - char *input, *buffer; + register char *line_start, *line_end; + char *input, *buffer, *bufend; int file, current_line, chars_read; struct stat finfo; size_t file_size; @@ -155,23 +170,39 @@ read_history_range (filename, from, to) { #if defined (EFBIG) errno = EFBIG; +#elif defined (EOVERFLOW) + errno = EOVERFLOW; #endif goto error_and_exit; } - buffer = xmalloc (file_size + 1); +#ifdef HAVE_MMAP + /* We map read/write and private so we can change newlines to NULs without + affecting the underlying object. */ + buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0); + if ((void *)buffer == MAP_FAILED) + goto error_and_exit; + chars_read = file_size; +#else + buffer = (char *)malloc (file_size + 1); + if (buffer == 0) + goto error_and_exit; chars_read = read (file, buffer, file_size); +#endif if (chars_read < 0) { error_and_exit: + chars_read = errno; if (file >= 0) close (file); FREE (input); +#ifndef HAVE_MMAP FREE (buffer); +#endif - return (errno); + return (chars_read); } close (file); @@ -181,29 +212,25 @@ read_history_range (filename, from, to) to = chars_read; /* Start at beginning of file, work to end. */ - line_start = line_end = current_line = 0; + bufend = buffer + chars_read; + current_line = 0; /* Skip lines until we are at FROM. */ - while (line_start < chars_read && current_line < from) - { - for (line_end = line_start; line_end < chars_read; line_end++) - if (buffer[line_end] == '\n') - { - current_line++; - line_start = line_end + 1; - if (current_line == from) - break; - } - } + for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++) + if (*line_end == '\n') + { + current_line++; + line_start = line_end + 1; + } /* If there are lines left to gobble, then gobble them now. */ - for (line_end = line_start; line_end < chars_read; line_end++) - if (buffer[line_end] == '\n') + for (line_end = line_start; line_end < bufend; line_end++) + if (*line_end == '\n') { - buffer[line_end] = '\0'; + *line_end = '\0'; - if (buffer[line_start]) - add_history (buffer + line_start); + if (*line_start) + add_history (line_start); current_line++; @@ -214,21 +241,25 @@ read_history_range (filename, from, to) } FREE (input); +#ifndef HAVE_MMAP FREE (buffer); +#else + munmap (buffer, file_size); +#endif return (0); } /* Truncate the history file FNAME, leaving only LINES trailing lines. - If FNAME is NULL, then use ~/.history. */ + If FNAME is NULL, then use ~/.history. Returns 0 on success, errno + on failure. */ int history_truncate_file (fname, lines) - char *fname; + const char *fname; int lines; { - register int i; - int file, chars_read; - char *buffer, *filename; + char *buffer, *filename, *bp; + int file, chars_read, rv; struct stat finfo; size_t file_size; @@ -237,13 +268,27 @@ history_truncate_file (fname, lines) file = open (filename, O_RDONLY|O_BINARY, 0666); else file = -1; + rv = 0; + /* Don't try to truncate non-regular files. */ if (file == -1 || fstat (file, &finfo) == -1) - goto truncate_exit; + { + rv = errno; + if (file != -1) + close (file); + goto truncate_exit; + } - /* Don't try to truncate non-regular files. */ - if (S_ISREG(finfo.st_mode) == 0) - goto truncate_exit; + if (S_ISREG (finfo.st_mode) == 0) + { + close (file); +#ifdef EFTYPE + rv = EFTYPE; +#else + rv = EINVAL; +#endif + goto truncate_exit; + } file_size = (size_t)finfo.st_size; @@ -252,23 +297,36 @@ history_truncate_file (fname, lines) { close (file); #if defined (EFBIG) - errno = EFBIG; + rv = errno = EFBIG; +#elif defined (EOVERFLOW) + rv = errno = EOVERFLOW; +#else + rv = errno = EINVAL; #endif goto truncate_exit; } - buffer = xmalloc (file_size + 1); + buffer = (char *)malloc (file_size + 1); + if (buffer == 0) + { + close (file); + goto truncate_exit; + } + chars_read = read (file, buffer, file_size); close (file); if (chars_read <= 0) - goto truncate_exit; + { + rv = (chars_read < 0) ? errno : 0; + goto truncate_exit; + } /* Count backwards from the end of buffer until we have passed LINES lines. */ - for (i = chars_read - 1; lines && i; i--) + for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--) { - if (buffer[i] == '\n') + if (*bp == '\n') lines--; } @@ -277,22 +335,22 @@ history_truncate_file (fname, lines) anything. It's the first line if we don't find a newline between the current value of i and 0. Otherwise, write from the start of this line until the end of the buffer. */ - for ( ; i; i--) - if (buffer[i] == '\n') + for ( ; bp > buffer; bp--) + if (*bp == '\n') { - i++; + bp++; break; } /* Write only if there are more lines in the file than we want to truncate to. */ - if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1)) + if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1)) { - write (file, buffer + i, chars_read - i); + write (file, bp, chars_read - (bp - buffer)); #if defined (__BEOS__) /* BeOS ignores O_TRUNC. */ - ftruncate (file, chars_read - i); + ftruncate (file, chars_read - (bp - buffer)); #endif close (file); @@ -303,7 +361,7 @@ history_truncate_file (fname, lines) FREE (buffer); free (filename); - return 0; + return rv; } /* Workhorse function for writing history. Writes NELEMENT entries @@ -311,15 +369,21 @@ history_truncate_file (fname, lines) wish to replace FILENAME with the entries. */ static int history_do_write (filename, nelements, overwrite) - char *filename; + const char *filename; int nelements, overwrite; { register int i; char *output; - int file, mode; + int file, mode, rv; + size_t cursize; +#ifdef HAVE_MMAP + mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY; +#else mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY; +#endif output = history_filename (filename); + rv = 0; if (!output || (file = open (output, mode, 0600)) == -1) { @@ -327,6 +391,10 @@ history_do_write (filename, nelements, overwrite) return (errno); } +#ifdef HAVE_MMAP + cursize = overwrite ? 0 : lseek (file, 0, SEEK_END); +#endif + if (nelements > history_length) nelements = history_length; @@ -343,7 +411,28 @@ history_do_write (filename, nelements, overwrite) buffer_size += 1 + strlen (the_history[i]->line); /* Allocate the buffer, and fill it. */ - buffer = xmalloc (buffer_size); +#ifdef HAVE_MMAP + if (ftruncate (file, buffer_size+cursize) == -1) + goto mmap_error; + buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize); + if ((void *)buffer == MAP_FAILED) + { +mmap_error: + rv = errno; + FREE (output); + close (file); + return rv; + } +#else + buffer = (char *)malloc (buffer_size); + if (buffer == 0) + { + rv = errno; + FREE (output); + close (file); + return rv; + } +#endif buffer[0] = '\0'; for (i = history_length - nelements; i < history_length; i++) @@ -352,15 +441,21 @@ history_do_write (filename, nelements, overwrite) strlcat (buffer, "\n", buffer_size); } - write (file, buffer, buffer_size - 1); +#ifdef HAVE_MMAP + if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0) + rv = errno; +#else + if (write (file, buffer, buffer_size - 1) < 0) + rv = errno; free (buffer); +#endif } close (file); FREE (output); - return (0); + return (rv); } /* Append NELEMENT entries to FILENAME. The entries appended are from @@ -368,7 +463,7 @@ history_do_write (filename, nelements, overwrite) int append_history (nelements, filename) int nelements; - char *filename; + const char *filename; { return (history_do_write (filename, nelements, HISTORY_APPEND)); } @@ -378,7 +473,7 @@ append_history (nelements, filename) are as in read_history ().*/ int write_history (filename) - char *filename; + const char *filename; { return (history_do_write (filename, history_length, HISTORY_OVERWRITE)); } diff --git a/gnu/lib/libreadline/histlib.h b/gnu/lib/libreadline/histlib.h index c13e88a5c73..7a1e207a1e8 100644 --- a/gnu/lib/libreadline/histlib.h +++ b/gnu/lib/libreadline/histlib.h @@ -22,14 +22,11 @@ #if !defined (_HISTLIB_H_) #define _HISTLIB_H_ -/* Function pointers can be declared as (Function *)foo. */ -#if !defined (_FUNCTION_DEF) -# define _FUNCTION_DEF -typedef int Function (); -typedef void VFunction (); -typedef char *CPFunction (); -typedef char **CPPFunction (); -#endif /* _FUNCTION_DEF */ +#if defined (HAVE_STRING_H) +# include <string.h> +#else +# include <strings.h> +#endif /* !HAVE_STRING_H */ #if !defined (STREQ) #define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0)) @@ -40,7 +37,7 @@ typedef char **CPPFunction (); #if !defined (savestring) #include <stdio.h> static char * -xstrdup(char *s) +xstrdup(const char *s) { char * cp; cp = strdup(s); diff --git a/gnu/lib/libreadline/isearch.c b/gnu/lib/libreadline/isearch.c index 53bbface2f6..5b40d201ecb 100644 --- a/gnu/lib/libreadline/isearch.c +++ b/gnu/lib/libreadline/isearch.c @@ -4,7 +4,7 @@ /* */ /* **************************************************************** */ -/* Copyright (C) 1987,1989 Free Software Foundation, Inc. +/* Copyright (C) 1987-2002 Free Software Foundation, Inc. This file contains the Readline Library (the Library), a set of routines for providing Emacs style line input to programs that ask @@ -45,6 +45,8 @@ #endif #include "rldefs.h" +#include "rlmbutil.h" + #include "readline.h" #include "history.h" @@ -52,18 +54,24 @@ #include "xmalloc.h" /* Variables exported to other files in the readline library. */ -unsigned char *_rl_isearch_terminators = (unsigned char *)NULL; +char *_rl_isearch_terminators = (char *)NULL; /* Variables imported from other files in the readline library. */ -extern HIST_ENTRY *saved_line_for_history; +extern HIST_ENTRY *_rl_saved_line_for_history; /* Forward declarations */ -static int rl_search_history __P((int, int)); +static int rl_search_history PARAMS((int, int)); /* Last line found by the current incremental search, so we don't `find' identical lines many times in a row. */ static char *prev_line_found; +/* Last search string and its length. */ +static char *last_isearch_string; +static int last_isearch_string_len; + +static char *default_isearch_terminators = "\033\012"; + /* Search backwards through the history looking for a string which is typed interactively. Start with the current line. */ int @@ -98,7 +106,7 @@ rl_display_search (search_string, reverse_p, where) searchlen = (search_string && *search_string) ? strlen (search_string) : 0; mlen = searchlen + 33; - message = xmalloc (mlen); + message = (char *)xmalloc (mlen); msglen = 0; #if defined (NOTDEF) @@ -126,7 +134,7 @@ rl_display_search (search_string, reverse_p, where) strlcat (message, "': ", mlen); - rl_message ("%s", message, 0); + rl_message ("%s", message); free (message); (*rl_redisplay_function) (); } @@ -158,8 +166,12 @@ rl_search_history (direction, invoking_key) HIST_ENTRY **hlist; register int i; - int orig_point, orig_line, last_found_line; + int orig_point, orig_mark, orig_line, last_found_line; int c, found, failed, sline_len; + int n, wstart, wlen; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; +#endif /* The line currently being searched. */ char *sline; @@ -173,19 +185,21 @@ rl_search_history (direction, invoking_key) /* The list of characters which terminate the search, but are not subsequently executed. If the variable isearch-terminators has been set, we use that value, otherwise we use ESC and C-J. */ - unsigned char *isearch_terminators; + char *isearch_terminators; + RL_SETSTATE(RL_STATE_ISEARCH); orig_point = rl_point; + orig_mark = rl_mark; last_found_line = orig_line = where_history (); reverse = direction < 0; hlist = history_list (); allocated_line = (char *)NULL; isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators - : (unsigned char *)"\033\012"; + : default_isearch_terminators; /* Create an arrary of pointers to the lines that we want to search. */ - maybe_replace_line (); + rl_maybe_replace_line (); i = 0; if (hlist) for (i = 0; hlist[i]; i++); @@ -196,8 +210,8 @@ rl_search_history (direction, invoking_key) for (i = 0; i < hlen; i++) lines[i] = hlist[i]->line; - if (saved_line_for_history) - lines[i] = saved_line_for_history->line; + if (_rl_saved_line_for_history) + lines[i] = _rl_saved_line_for_history->line; else { /* Keep track of this so we can free it. */ @@ -215,7 +229,7 @@ rl_search_history (direction, invoking_key) rl_save_prompt (); /* Initialize search parameters. */ - search_string = xmalloc (search_string_size = 128); + search_string = (char *)xmalloc (search_string_size = 128); *search_string = '\0'; search_string_index = 0; prev_line_found = (char *)0; /* XXX */ @@ -232,12 +246,20 @@ rl_search_history (direction, invoking_key) found = failed = 0; for (;;) { - Function *f = (Function *)NULL; + rl_command_func_t *f = (rl_command_func_t *)NULL; /* Read a key and decide how to proceed. */ + RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); - if (_rl_keymap[c].type == ISFUNC) +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = _rl_read_mbstring (c, mb, MB_LEN_MAX); +#endif + + /* Translate the keys we do something with to opcodes. */ + if (c >= 0 && _rl_keymap[c].type == ISFUNC) { f = _rl_keymap[c].function; @@ -245,34 +267,56 @@ rl_search_history (direction, invoking_key) c = reverse ? -1 : -2; else if (f == rl_forward_search_history) c = !reverse ? -1 : -2; + else if (f == rl_rubout) + c = -3; + else if (c == CTRL ('G')) + c = -4; + else if (c == CTRL ('W')) /* XXX */ + c = -5; + else if (c == CTRL ('Y')) /* XXX */ + c = -6; } -#if 0 - /* Let NEWLINE (^J) terminate the search for people who don't like - using ESC. ^M can still be used to terminate the search and - immediately execute the command. */ - if (c == ESC || c == NEWLINE) -#else /* The characters in isearch_terminators (set from the user-settable variable isearch-terminators) are used to terminate the search but not subsequently execute the character as a command. The default value is "\033\012" (ESC and C-J). */ if (strchr (isearch_terminators, c)) -#endif { /* ESC still terminates the search, but if there is pending input or if input arrives within 0.1 seconds (on systems with select(2)) it is used as a prefix character with rl_execute_next. WATCH OUT FOR THIS! This is intended to allow the arrow keys to be used like ^F and ^B are used - to terminate the search and execute the movement command. */ - if (c == ESC && _rl_input_available ()) /* XXX */ + to terminate the search and execute the movement command. + XXX - since _rl_input_available depends on the application- + settable keyboard timeout value, this could alternatively + use _rl_input_queued(100000) */ + if (c == ESC && _rl_input_available ()) rl_execute_next (ESC); break; } - if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G')) +#define ENDSRCH_CHAR(c) \ + ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G'))) + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c)) + { + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ + rl_execute_next (c); + break; + } + } + else +#endif + if (c >= 0 && ENDSRCH_CHAR (c)) { + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ rl_execute_next (c); break; } @@ -281,13 +325,24 @@ rl_search_history (direction, invoking_key) { case -1: if (search_string_index == 0) - continue; + { + if (last_isearch_string) + { + search_string_size = 64 + last_isearch_string_len; + search_string = (char *)xrealloc (search_string, search_string_size); + strcpy (search_string, last_isearch_string); + search_string_index = last_isearch_string_len; + rl_display_search (search_string, reverse, -1); + break; + } + continue; + } else if (reverse) --line_index; else if (line_index != sline_len) ++line_index; else - ding (); + rl_ding (); break; /* switch directions */ @@ -296,40 +351,96 @@ rl_search_history (direction, invoking_key) reverse = direction < 0; break; - case CTRL ('G'): - strlcpy (rl_line_buffer, lines[orig_line], rl_line_buffer_len); + /* delete character from search string. */ + case -3: /* C-H, DEL */ + /* This is tricky. To do this right, we need to keep a + stack of search positions for the current search, with + sentinels marking the beginning and end. But this will + do until we have a real isearch-undo. */ + if (search_string_index == 0) + rl_ding (); + else + search_string[--search_string_index] = '\0'; + + break; + + case -4: /* C-G */ + rl_replace_line (lines[orig_line], 0); rl_point = orig_point; - rl_end = strlen (rl_line_buffer); + rl_mark = orig_mark; rl_restore_prompt(); rl_clear_message (); if (allocated_line) free (allocated_line); free (lines); + RL_UNSETSTATE(RL_STATE_ISEARCH); return 0; -#if 0 - /* delete character from search string. */ - case -3: - if (search_string_index == 0) - ding (); - else + case -5: /* C-W */ + /* skip over portion of line we already matched */ + wstart = rl_point + search_string_index; + if (wstart >= rl_end) + { + rl_ding (); + break; + } + + /* if not in a word, move to one. */ + if (rl_alphabetic(rl_line_buffer[wstart]) == 0) { - search_string[--search_string_index] = '\0'; - /* This is tricky. To do this right, we need to keep a - stack of search positions for the current search, with - sentinels marking the beginning and end. */ + rl_ding (); + break; } + n = wstart; + while (n < rl_end && rl_alphabetic(rl_line_buffer[n])) + n++; + wlen = n - wstart + 1; + if (search_string_index + wlen + 1 >= search_string_size) + { + search_string_size += wlen + 1; + search_string = (char *)xrealloc (search_string, search_string_size); + } + for (; wstart < n; wstart++) + search_string[search_string_index++] = rl_line_buffer[wstart]; + search_string[search_string_index] = '\0'; + break; + + case -6: /* C-Y */ + /* skip over portion of line we already matched */ + wstart = rl_point + search_string_index; + if (wstart >= rl_end) + { + rl_ding (); + break; + } + n = rl_end - wstart + 1; + if (search_string_index + n + 1 >= search_string_size) + { + search_string_size += n + 1; + search_string = (char *)xrealloc (search_string, search_string_size); + } + for (n = wstart; n < rl_end; n++) + search_string[search_string_index++] = rl_line_buffer[n]; + search_string[search_string_index] = '\0'; break; -#endif default: /* Add character to search string and continue search. */ if (search_string_index + 2 >= search_string_size) { search_string_size += 128; - search_string = xrealloc (search_string, search_string_size); + search_string = (char *)xrealloc (search_string, search_string_size); + } +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int j, l; + for (j = 0, l = strlen (mb); j < l; ) + search_string[search_string_index++] = mb[j++]; } - search_string[search_string_index++] = c; + else +#endif + search_string[search_string_index++] = c; search_string[search_string_index] = '\0'; break; } @@ -384,7 +495,7 @@ rl_search_history (direction, invoking_key) if (failed) { /* We cannot find the search string. Ding the bell. */ - ding (); + rl_ding (); i = last_found_line; continue; /* XXX - was break */ } @@ -394,17 +505,9 @@ rl_search_history (direction, invoking_key) the location. */ if (found) { - int line_len; - prev_line_found = lines[i]; - line_len = strlen (lines[i]); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strlcpy (rl_line_buffer, lines[i], rl_line_buffer_len); + rl_replace_line (lines[i], 0); rl_point = line_index; - rl_end = line_len; last_found_line = i; rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i); } @@ -420,23 +523,38 @@ rl_search_history (direction, invoking_key) rl_restore_prompt (); - /* Free the search string. */ - free (search_string); + /* Save the search string for possible later use. */ + FREE (last_isearch_string); + last_isearch_string = search_string; + last_isearch_string_len = search_string_index; if (last_found_line < orig_line) rl_get_previous_history (orig_line - last_found_line, 0); else rl_get_next_history (last_found_line - orig_line, 0); - /* If the string was not found, put point at the end of the line. */ + /* If the string was not found, put point at the end of the last matching + line. If last_found_line == orig_line, we didn't find any matching + history lines at all, so put point back in its original position. */ if (line_index < 0) - line_index = strlen (rl_line_buffer); + { + if (last_found_line == orig_line) + line_index = orig_point; + else + line_index = strlen (rl_line_buffer); + rl_mark = orig_mark; + } + rl_point = line_index; + /* Don't worry about where to put the mark here; rl_get_previous_history + and rl_get_next_history take care of it. */ + rl_clear_message (); - if (allocated_line) - free (allocated_line); + FREE (allocated_line); free (lines); + RL_UNSETSTATE(RL_STATE_ISEARCH); + return 0; } diff --git a/gnu/lib/libreadline/kill.c b/gnu/lib/libreadline/kill.c index b30dd707627..6205229cdfc 100644 --- a/gnu/lib/libreadline/kill.c +++ b/gnu/lib/libreadline/kill.c @@ -70,6 +70,11 @@ static int rl_kill_index; /* How many slots we have in the kill ring. */ static int rl_kill_ring_length; +static int _rl_copy_to_kill_ring PARAMS((char *, int)); +static int region_kill_internal PARAMS((int)); +static int _rl_copy_word_as_kill PARAMS((int, int)); +static int rl_yank_nth_arg_internal PARAMS((int, int, int)); + /* How to say that you only want to save a certain amount of kill material. */ int @@ -131,7 +136,7 @@ _rl_copy_to_kill_ring (text, append) int len; old = rl_kill_ring[slot]; len = 1 + strlen (old) + strlen (text); - new = xmalloc (len); + new = (char *)xmalloc (len); if (append) { @@ -198,18 +203,21 @@ int rl_kill_word (count, key) int count, key; { - int orig_point = rl_point; + int orig_point; if (count < 0) return (rl_backward_kill_word (-count, key)); else { + orig_point = rl_point; rl_forward_word (count, key); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -219,16 +227,20 @@ int rl_backward_kill_word (count, ignore) int count, ignore; { - int orig_point = rl_point; + int orig_point; if (count < 0) return (rl_kill_word (-count, ignore)); else { + orig_point = rl_point; rl_backward_word (count, ignore); if (rl_point != orig_point) rl_kill_text (orig_point, rl_point); + + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -239,16 +251,19 @@ int rl_kill_line (direction, ignore) int direction, ignore; { - int orig_point = rl_point; + int orig_point; if (direction < 0) return (rl_backward_kill_line (1, ignore)); else { + orig_point = rl_point; rl_end_of_line (1, ignore); if (orig_point != rl_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -259,18 +274,22 @@ int rl_backward_kill_line (direction, ignore) int direction, ignore; { - int orig_point = rl_point; + int orig_point; if (direction < 0) return (rl_kill_line (1, ignore)); else { if (!rl_point) - ding (); + rl_ding (); else { + orig_point = rl_point; rl_beg_of_line (1, ignore); - rl_kill_text (orig_point, rl_point); + if (rl_point != orig_point) + rl_kill_text (orig_point, rl_point); + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } } return 0; @@ -284,6 +303,7 @@ rl_kill_full_line (count, ignore) rl_begin_undo_group (); rl_point = 0; rl_kill_text (rl_point, rl_end); + rl_mark = 0; rl_end_undo_group (); return 0; } @@ -301,7 +321,7 @@ rl_unix_word_rubout (count, key) int orig_point; if (rl_point == 0) - ding (); + rl_ding (); else { orig_point = rl_point; @@ -318,6 +338,8 @@ rl_unix_word_rubout (count, key) } rl_kill_text (orig_point, rl_point); + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -333,11 +355,13 @@ rl_unix_line_discard (count, key) int count, key; { if (rl_point == 0) - ding (); + rl_ding (); else { rl_kill_text (rl_point, 0); rl_point = 0; + if (rl_editing_mode == emacs_mode) + rl_mark = rl_point; } return 0; } @@ -350,17 +374,14 @@ region_kill_internal (delete) { char *text; - if (rl_mark == rl_point) + if (rl_mark != rl_point) { - _rl_last_command_was_kill++; - return 0; + text = rl_copy_text (rl_point, rl_mark); + if (delete) + rl_delete_text (rl_point, rl_mark); + _rl_copy_to_kill_ring (text, rl_point < rl_mark); } - text = rl_copy_text (rl_point, rl_mark); - if (delete) - rl_delete_text (rl_point, rl_mark); - _rl_copy_to_kill_ring (text, rl_point < rl_mark); - _rl_last_command_was_kill++; return 0; } @@ -514,19 +535,21 @@ rl_yank_nth_arg_internal (count, ignore, history_skip) if (entry == 0) { - ding (); + rl_ding (); return -1; } arg = history_arg_extract (count, count, entry->line); if (!arg || !*arg) { - ding (); + rl_ding (); return -1; } rl_begin_undo_group (); + _rl_set_mark_at_pos (rl_point); + #if defined (VI_MODE) /* Vi mode always inserts a space before yanking the argument, and it inserts it right *after* rl_point. */ @@ -594,7 +617,7 @@ rl_yank_last_arg (count, key) } /* A special paste command for users of Cygnus's cygwin32. */ -#if defined (__CYGWIN32__) +#if defined (__CYGWIN__) #include <windows.h> int @@ -614,12 +637,13 @@ rl_paste_from_clipboard (count, key) if (ptr) { len = ptr - data; - ptr = xmalloc (len + 1); + ptr = (char *)xmalloc (len + 1); ptr[len] = '\0'; strncpy (ptr, data, len); } else ptr = data; + _rl_set_mark_at_pos (rl_point); rl_insert_text (ptr); if (ptr != data) free (ptr); @@ -627,4 +651,4 @@ rl_paste_from_clipboard (count, key) } return (0); } -#endif /* __CYGWIN32__ */ +#endif /* __CYGWIN__ */ diff --git a/gnu/lib/libreadline/nls.c b/gnu/lib/libreadline/nls.c index 81de0f2ec82..d784a6862cf 100644 --- a/gnu/lib/libreadline/nls.c +++ b/gnu/lib/libreadline/nls.c @@ -71,8 +71,8 @@ static char *legal_lang_values[] = 0 }; -static char *normalize_codeset __P((char *)); -static char *find_codeset __P((char *, size_t *)); +static char *normalize_codeset PARAMS((char *)); +static char *find_codeset PARAMS((char *, size_t *)); #endif /* !HAVE_SETLOCALE */ /* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value @@ -105,9 +105,9 @@ _rl_init_eightbit () /* We don't have setlocale. Finesse it. Check the environment for the appropriate variables and set eight-bit mode if they have the right values. */ - lspec = get_env_value ("LC_ALL"); - if (lspec == 0 || *lspec == '\0') lspec = get_env_value ("LC_CTYPE"); - if (lspec == 0 || *lspec == '\0') lspec = get_env_value ("LANG"); + lspec = sh_get_env_value ("LC_ALL"); + if (lspec == 0 || *lspec == '\0') lspec = sh_get_env_value ("LC_CTYPE"); + if (lspec == 0 || *lspec == '\0') lspec = sh_get_env_value ("LANG"); if (lspec == 0 || *lspec == '\0' || (t = normalize_codeset (lspec)) == 0) return (0); for (i = 0; t && legal_lang_values[i]; i++) @@ -141,10 +141,10 @@ normalize_codeset (codeset) all_digits = 1; for (len = 0, i = 0; i < namelen; i++) { - if (isalnum (codeset[i])) + if (ISALNUM ((unsigned char)codeset[i])) { len++; - all_digits &= isdigit (codeset[i]); + all_digits &= _rl_digit_p (codeset[i]); } } @@ -162,9 +162,9 @@ normalize_codeset (codeset) } for (i = 0; i < namelen; i++) - if (isalpha (codeset[i])) - *wp++ = (isupper (codeset[i])) ? tolower (codeset[i]) : codeset[i]; - else if (isdigit (codeset[i])) + if (ISALPHA ((unsigned char)codeset[i])) + *wp++ = _rl_to_lower (codeset[i]); + else if (_rl_digit_p (codeset[i])) *wp++ = codeset[i]; *wp = '\0'; diff --git a/gnu/lib/libreadline/readline.c b/gnu/lib/libreadline/readline.c index 5ccc001748a..65e612bcf1e 100644 --- a/gnu/lib/libreadline/readline.c +++ b/gnu/lib/libreadline/readline.c @@ -1,7 +1,7 @@ /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2002 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -52,6 +52,7 @@ /* System-specific feature definitions and include files. */ #include "rldefs.h" +#include "rlmbutil.h" #if defined (__EMX__) # define INCL_DOSPROCESS @@ -67,22 +68,23 @@ #include "xmalloc.h" #ifndef RL_LIBRARY_VERSION -# define RL_LIBRARY_VERSION "4.1" +# define RL_LIBRARY_VERSION "4.3" #endif -/* Evaluates its arguments multiple times. */ -#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0) +#ifndef RL_READLINE_VERSION +# define RL_READLINE_VERSION 0x0403 +#endif + +extern void _rl_free_history_entry PARAMS((HIST_ENTRY *)); /* Forward declarations used in this file. */ -void _rl_free_history_entry __P((HIST_ENTRY *)); +static char *readline_internal PARAMS((void)); +static void readline_initialize_everything PARAMS((void)); -static char *readline_internal __P((void)); -static void readline_initialize_everything __P((void)); -static void start_using_history __P((void)); -static void bind_arrow_keys __P((void)); -static int rl_change_case __P((int, int)); +static void bind_arrow_keys_internal PARAMS((Keymap)); +static void bind_arrow_keys PARAMS((void)); -static void readline_default_bindings __P((void)); +static void readline_default_bindings PARAMS((void)); /* **************************************************************** */ /* */ @@ -90,8 +92,11 @@ static void readline_default_bindings __P((void)); /* */ /* **************************************************************** */ -char *rl_library_version = RL_LIBRARY_VERSION; +const char *rl_library_version = RL_LIBRARY_VERSION; + +int rl_readline_version = RL_READLINE_VERSION; +/* True if this is `real' readline as opposed to some stub substitute. */ int rl_gnu_readline_p = 1; /* A pointer to the keymap that is currently in use. @@ -101,6 +106,9 @@ Keymap _rl_keymap = emacs_standard_keymap; /* The current style of editing. */ int rl_editing_mode = emacs_mode; +/* The current insert mode: input (the default) or overwrite */ +int rl_insert_mode = RL_IM_DEFAULT; + /* Non-zero if we called this function from _rl_dispatch(). It's present so functions can find out whether they were called from a key binding or directly from an application. */ @@ -121,8 +129,13 @@ int rl_arg_sign = 1; /* Non-zero means we have been called at least once before. */ static int rl_initialized; +#if 0 /* If non-zero, this program is running in an EMACS buffer. */ static int running_in_emacs; +#endif + +/* Flags word encapsulating the current readline state. */ +int rl_readline_state = RL_STATE_NONE; /* The current offset in the current input line. */ int rl_point; @@ -137,7 +150,7 @@ int rl_end; int rl_done; /* The last function executed by readline. */ -Function *rl_last_func = (Function *)NULL; +rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL; /* Top level environment for readline_internal (). */ procenv_t readline_top_level; @@ -149,11 +162,14 @@ FILE *_rl_in_stream, *_rl_out_stream; FILE *rl_instream = (FILE *)NULL; FILE *rl_outstream = (FILE *)NULL; -/* Non-zero means echo characters as they are read. */ -int readline_echoing_p = 1; +/* Non-zero means echo characters as they are read. Defaults to no echo; + set to 1 if there is a controlling terminal, we can get its attributes, + and the attributes include `echo'. Look at rltty.c:prepare_terminal_settings + for the code that sets it. */ +int readline_echoing_p = 0; /* Current prompt. */ -char *rl_prompt; +char *rl_prompt = (char *)NULL; int rl_visible_prompt_length = 0; /* Set to non-zero by calling application if it has already printed rl_prompt @@ -165,12 +181,12 @@ int rl_key_sequence_length = 0; /* If non-zero, then this is the address of a function to call just before readline_internal_setup () prints the first prompt. */ -Function *rl_startup_hook = (Function *)NULL; +rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL; /* If non-zero, this is the address of a function to call just before readline_internal_setup () returns and readline_internal starts reading input characters. */ -Function *rl_pre_input_hook = (Function *)NULL; +rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL; /* What we use internally. You should always refer to RL_LINE_BUFFER. */ static char *the_line; @@ -183,7 +199,7 @@ int _rl_eof_char = CTRL ('D'); int rl_pending_input = 0; /* Pointer to a useful terminal name. */ -char *rl_terminal_name = (char *)NULL; +const char *rl_terminal_name = (const char *)NULL; /* Non-zero means to always use horizontal scrolling in line display. */ int _rl_horizontal_scroll_mode = 0; @@ -213,7 +229,7 @@ int rl_num_chars_to_read; char *rl_line_buffer = (char *)NULL; int rl_line_buffer_len = 0; -/* Forward declarations used by the display and termcap code. */ +/* Forward declarations used by the display, termcap, and history code. */ /* **************************************************************** */ /* */ @@ -243,24 +259,35 @@ int _rl_output_meta_chars = 0; /* Non-zero means treat 0200 bit in terminal input as Meta bit. */ int _rl_meta_flag = 0; /* Forward declaration */ +/* Set up the prompt and expand it. Called from readline() and + rl_callback_handler_install (). */ +int +rl_set_prompt (prompt) + const char *prompt; +{ + FREE (rl_prompt); + rl_prompt = prompt ? savestring (prompt) : (char *)NULL; + + rl_visible_prompt_length = rl_expand_prompt (rl_prompt); + return 0; +} + /* Read a line of input. Prompt with PROMPT. An empty PROMPT means none. A return value of NULL means that EOF was encountered. */ char * readline (prompt) - char *prompt; + const char *prompt; { char *value; - rl_prompt = prompt; - /* If we are at EOF return a NULL string. */ if (rl_pending_input == EOF) { - rl_pending_input = 0; + rl_clear_pending_input (); return ((char *)NULL); } - rl_visible_prompt_length = rl_expand_prompt (rl_prompt); + rl_set_prompt (prompt); rl_initialize (); (*rl_prep_term_function) (_rl_meta_flag); @@ -296,7 +323,10 @@ readline_internal_setup () if (rl_startup_hook) (*rl_startup_hook) (); - if (readline_echoing_p == 0) + /* If we're not echoing, we still want to at least print a prompt, because + rl_redisplay will not do it for us. If the calling application has a + custom redisplay function, though, let that function handle it. */ + if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay) { if (rl_prompt && rl_already_prompted == 0) { @@ -313,11 +343,12 @@ readline_internal_setup () else rl_on_new_line (); (*rl_redisplay_function) (); + } + #if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_vi_insertion_mode (1, 0); + if (rl_editing_mode == vi_mode) + rl_vi_insertion_mode (1, 0); #endif /* VI_MODE */ - } if (rl_pre_input_hook) (*rl_pre_input_hook) (); @@ -348,7 +379,10 @@ readline_internal_teardown (eof) /* At any rate, it is highly likely that this line has an undo list. Get rid of it now. */ if (rl_undo_list) - free_undo_list (); + rl_free_undo_list (); + + /* Restore normal cursor, if available. */ + _rl_set_insert_mode (RL_IM_INSERT, 0); return (eof ? (char *)NULL : savestring (the_line)); } @@ -384,7 +418,9 @@ readline_internal_charloop () rl_key_sequence_length = 0; } + RL_SETSTATE(RL_STATE_READCMD); c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_READCMD); /* EOF typed to a non-blank line is a <NL>. */ if (c == EOF && rl_end) @@ -395,6 +431,7 @@ readline_internal_charloop () if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end) { #if defined (READLINE_CALLBACKS) + RL_SETSTATE(RL_STATE_DONE); return (rl_done = 1); #else eof_found = 1; @@ -470,7 +507,7 @@ readline_internal () void _rl_init_line_state () { - rl_point = rl_end = 0; + rl_point = rl_end = rl_mark = 0; the_line = rl_line_buffer; the_line[0] = 0; } @@ -489,15 +526,24 @@ _rl_dispatch (key, map) register int key; Keymap map; { + return _rl_dispatch_subseq (key, map, 0); +} + +int +_rl_dispatch_subseq (key, map, got_subseq) + register int key; + Keymap map; + int got_subseq; +{ int r, newkey; char *macro; - Function *func; + rl_command_func_t *func; if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) { if (map[ESC].type == ISKMAP) { - if (_rl_defining_kbd_macro) + if (RL_ISSTATE (RL_STATE_MACRODEF)) _rl_add_macro_char (ESC); map = FUNCTION_TO_KEYMAP (map, ESC); key = UNMETA (key); @@ -505,11 +551,11 @@ _rl_dispatch (key, map) return (_rl_dispatch (key, map)); } else - ding (); + rl_ding (); return 0; } - if (_rl_defining_kbd_macro) + if (RL_ISSTATE (RL_STATE_MACRODEF)) _rl_add_macro_char (key); r = 0; @@ -517,7 +563,7 @@ _rl_dispatch (key, map) { case ISFUNC: func = map[key].function; - if (func != (Function *)NULL) + if (func) { /* Special case rl_do_lowercase_version (). */ if (func == rl_do_lowercase_version) @@ -530,15 +576,34 @@ _rl_dispatch (key, map) #endif rl_dispatching = 1; + RL_SETSTATE(RL_STATE_DISPATCHING); r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key); + RL_UNSETSTATE(RL_STATE_DISPATCHING); rl_dispatching = 0; /* If we have input pending, then the last command was a prefix command. Don't change the state of rl_last_func. Otherwise, remember the last command executed in this variable. */ - if (!rl_pending_input && map[key].function != rl_digit_argument) + if (rl_pending_input == 0 && map[key].function != rl_digit_argument) rl_last_func = map[key].function; } + else if (map[ANYOTHERKEY].function) + { + /* OK, there's no function bound in this map, but there is a + shadow function that was overridden when the current keymap + was created. Return -2 to note that. */ + _rl_unget_char (key); + return -2; + } + else if (got_subseq) + { + /* Return -1 to note that we're in a subsequence, but we don't + have a matching key, nor was one overridden. This means + we need to back up the recursion chain and find the last + subsequence that is bound to a function. */ + _rl_unget_char (key); + return -1; + } else { _rl_abort_internal (); @@ -547,11 +612,59 @@ _rl_dispatch (key, map) break; case ISKMAP: - if (map[key].function != (Function *)NULL) + if (map[key].function != 0) { +#if defined (VI_MODE) + /* The only way this test will be true is if a subsequence has been + bound starting with ESC, generally the arrow keys. What we do is + check whether there's input in the queue, which there generally + will be if an arrow key has been pressed, and, if there's not, + just dispatch to (what we assume is) rl_vi_movement_mode right + away. This is essentially an input test with a zero timeout. */ + if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap + && _rl_input_queued (0) == 0) + return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key))); +#endif + rl_key_sequence_length++; + + if (key == ESC) + RL_SETSTATE(RL_STATE_METANEXT); + RL_SETSTATE(RL_STATE_MOREINPUT); newkey = rl_read_key (); - r = _rl_dispatch (newkey, FUNCTION_TO_KEYMAP (map, key)); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (key == ESC) + RL_UNSETSTATE(RL_STATE_METANEXT); + + if (newkey < 0) + { + _rl_abort_internal (); + return -1; + } + + r = _rl_dispatch_subseq (newkey, FUNCTION_TO_KEYMAP (map, key), got_subseq || map[ANYOTHERKEY].function); + + if (r == -2) + /* We didn't match anything, and the keymap we're indexed into + shadowed a function previously bound to that prefix. Call + the function. The recursive call to _rl_dispatch_subseq has + already taken care of pushing any necessary input back onto + the input queue with _rl_unget_char. */ + r = _rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)); + else if (r && map[ANYOTHERKEY].function) + { + /* We didn't match (r is probably -1), so return something to + tell the caller that it should try ANYOTHERKEY for an + overridden function. */ + _rl_unget_char (key); + return -2; + } + else if (r && got_subseq) + { + /* OK, back up the chain. */ + _rl_unget_char (key); + return -1; + } } else { @@ -561,7 +674,7 @@ _rl_dispatch (key, map) break; case ISMACR: - if (map[key].function != (Function *)NULL) + if (map[key].function != 0) { macro = savestring ((char *)map[key].function); _rl_with_macro_input (macro); @@ -571,6 +684,7 @@ _rl_dispatch (key, map) } #if defined (VI_MODE) if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap && + key != ANYOTHERKEY && _rl_vi_textmod_command (key)) _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign); #endif @@ -591,8 +705,11 @@ rl_initialize () terminal and data structures. */ if (!rl_initialized) { + RL_SETSTATE(RL_STATE_INITIALIZING); readline_initialize_everything (); + RL_UNSETSTATE(RL_STATE_INITIALIZING); rl_initialized++; + RL_SETSTATE(RL_STATE_INITIALIZED); } /* Initalize the current line information. */ @@ -600,15 +717,16 @@ rl_initialize () /* We aren't done yet. We haven't even gotten started yet! */ rl_done = 0; + RL_UNSETSTATE(RL_STATE_DONE); /* Tell the history routines what is going on. */ - start_using_history (); + _rl_start_using_history (); /* Make the display buffer match the state of the line. */ rl_reset_line_state (); /* No such function typed yet. */ - rl_last_func = (Function *)NULL; + rl_last_func = (rl_command_func_t *)NULL; /* Parsing of key-bindings begins in an enabled state. */ _rl_parsing_conditionalized_out = 0; @@ -618,6 +736,9 @@ rl_initialize () _rl_vi_initialize_line (); #endif + /* Each line starts in insert mode (the default). */ + _rl_set_insert_mode (RL_IM_DEFAULT, 1); + return 0; } @@ -658,8 +779,10 @@ readline_initialize_everything () #endif #endif - /* Find out if we are running in Emacs. */ - running_in_emacs = get_env_value ("EMACS") != (char *)0; +#if 0 + /* Find out if we are running in Emacs -- UNUSED. */ + running_in_emacs = sh_get_env_value ("EMACS") != (char *)0; +#endif /* Set up input and output if they are not already set up. */ if (!rl_instream) @@ -676,10 +799,12 @@ readline_initialize_everything () /* Allocate data structures. */ if (rl_line_buffer == 0) - rl_line_buffer = xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE); + rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE); /* Initialize the terminal interface. */ - _rl_init_terminal_io ((char *)NULL); + if (rl_terminal_name == 0) + rl_terminal_name = sh_get_env_value ("TERM"); + _rl_init_terminal_io (rl_terminal_name); /* Bind tty characters to readline functions. */ readline_default_bindings (); @@ -696,8 +821,8 @@ readline_initialize_everything () /* XXX */ if (_rl_horizontal_scroll_mode && _rl_term_autowrap) { - screenwidth--; - screenchars -= screenheight; + _rl_screenwidth--; + _rl_screenchars -= _rl_screenheight; } /* Override the effect of any `set keymap' assignments in the @@ -723,1367 +848,127 @@ readline_initialize_everything () static void readline_default_bindings () { - rltty_set_default_bindings (_rl_keymap); -} - -static void -bind_arrow_keys_internal () -{ - Function *f; - -#if defined (__MSDOS__) - f = rl_function_of_keyseq ("\033[0A", _rl_keymap, (int *)NULL); - if (!f || f == rl_do_lowercase_version) - { - _rl_bind_if_unbound ("\033[0A", rl_get_previous_history); - _rl_bind_if_unbound ("\033[0B", rl_backward); - _rl_bind_if_unbound ("\033[0C", rl_forward); - _rl_bind_if_unbound ("\033[0D", rl_get_next_history); - } -#endif - - f = rl_function_of_keyseq ("\033[A", _rl_keymap, (int *)NULL); - if (!f || f == rl_do_lowercase_version) - { - _rl_bind_if_unbound ("\033[A", rl_get_previous_history); - _rl_bind_if_unbound ("\033[B", rl_get_next_history); - _rl_bind_if_unbound ("\033[C", rl_forward); - _rl_bind_if_unbound ("\033[D", rl_backward); - } - - f = rl_function_of_keyseq ("\033OA", _rl_keymap, (int *)NULL); - if (!f || f == rl_do_lowercase_version) - { - _rl_bind_if_unbound ("\033OA", rl_get_previous_history); - _rl_bind_if_unbound ("\033OB", rl_get_next_history); - _rl_bind_if_unbound ("\033OC", rl_forward); - _rl_bind_if_unbound ("\033OD", rl_backward); - } + rl_tty_set_default_bindings (_rl_keymap); } -/* Try and bind the common arrow key prefix after giving termcap and - the inputrc file a chance to bind them and create `real' keymaps - for the arrow key prefix. */ +/* Bind some common arrow key sequences in MAP. */ static void -bind_arrow_keys () +bind_arrow_keys_internal (map) + Keymap map; { Keymap xkeymap; xkeymap = _rl_keymap; + _rl_keymap = map; - _rl_keymap = emacs_standard_keymap; - bind_arrow_keys_internal (); - -#if defined (VI_MODE) - _rl_keymap = vi_movement_keymap; - bind_arrow_keys_internal (); -#endif - - _rl_keymap = xkeymap; -} - - -/* **************************************************************** */ -/* */ -/* Numeric Arguments */ -/* */ -/* **************************************************************** */ - -/* Handle C-u style numeric args, as well as M--, and M-digits. */ -static int -rl_digit_loop () -{ - int key, c, sawminus, sawdigits; - - rl_save_prompt (); - - sawminus = sawdigits = 0; - while (1) - { - if (rl_numeric_arg > 1000000) - { - sawdigits = rl_explicit_arg = rl_numeric_arg = 0; - ding (); - rl_restore_prompt (); - rl_clear_message (); - return 1; - } - rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); - key = c = rl_read_key (); - - /* If we see a key bound to `universal-argument' after seeing digits, - it ends the argument but is otherwise ignored. */ - if (_rl_keymap[c].type == ISFUNC && - _rl_keymap[c].function == rl_universal_argument) - { - if (sawdigits == 0) - { - rl_numeric_arg *= 4; - continue; - } - else - { - key = rl_read_key (); - rl_restore_prompt (); - rl_clear_message (); - return (_rl_dispatch (key, _rl_keymap)); - } - } - - c = UNMETA (c); - - if (_rl_digit_p (c)) - { - rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0'; - sawdigits = rl_explicit_arg = 1; - } - else if (c == '-' && rl_explicit_arg == 0) - { - rl_numeric_arg = sawminus = 1; - rl_arg_sign = -1; - } - else - { - /* Make M-- command equivalent to M--1 command. */ - if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0) - rl_explicit_arg = 1; - rl_restore_prompt (); - rl_clear_message (); - return (_rl_dispatch (key, _rl_keymap)); - } - } - - return 0; -} - -/* Add the current digit to the argument in progress. */ -int -rl_digit_argument (ignore, key) - int ignore, key; -{ - rl_pending_input = key; - return (rl_digit_loop ()); -} - -/* What to do when you abort reading an argument. */ -int -rl_discard_argument () -{ - ding (); - rl_clear_message (); - _rl_init_argument (); - return 0; -} - -/* Create a default argument. */ -int -_rl_init_argument () -{ - rl_numeric_arg = rl_arg_sign = 1; - rl_explicit_arg = 0; - return 0; -} - -/* C-u, universal argument. Multiply the current argument by 4. - Read a key. If the key has nothing to do with arguments, then - dispatch on it. If the key is the abort character then abort. */ -int -rl_universal_argument (count, key) - int count, key; -{ - rl_numeric_arg *= 4; - return (rl_digit_loop ()); -} - -/* **************************************************************** */ -/* */ -/* Insert and Delete */ -/* */ -/* **************************************************************** */ - -/* Insert a string of text into the line at point. This is the only - way that you should do insertion. rl_insert () calls this - function. */ -int -rl_insert_text (string) - char *string; -{ - register int i, l = strlen (string); - - if (rl_end + l >= rl_line_buffer_len) - rl_extend_line_buffer (rl_end + l); - - for (i = rl_end; i >= rl_point; i--) - the_line[i + l] = the_line[i]; - strncpy (the_line + rl_point, string, l); - - /* Remember how to undo this if we aren't undoing something. */ - if (!_rl_doing_an_undo) - { - /* If possible and desirable, concatenate the undos. */ - if ((l == 1) && - rl_undo_list && - (rl_undo_list->what == UNDO_INSERT) && - (rl_undo_list->end == rl_point) && - (rl_undo_list->end - rl_undo_list->start < 20)) - rl_undo_list->end++; - else - rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL); - } - rl_point += l; - rl_end += l; - the_line[rl_end] = '\0'; - return l; -} - -/* Delete the string between FROM and TO. FROM is - inclusive, TO is not. */ -int -rl_delete_text (from, to) - int from, to; -{ - register char *text; - register int diff, i; - - /* Fix it if the caller is confused. */ - if (from > to) - SWAP (from, to); - - /* fix boundaries */ - if (to > rl_end) - { - to = rl_end; - if (from > to) - from = to; - } - - text = rl_copy_text (from, to); - - /* Some versions of strncpy() can't handle overlapping arguments. */ - diff = to - from; - for (i = from; i < rl_end - diff; i++) - the_line[i] = the_line[i + diff]; - - /* Remember how to undo this delete. */ - if (_rl_doing_an_undo == 0) - rl_add_undo (UNDO_DELETE, from, to, text); - else - free (text); - - rl_end -= diff; - the_line[rl_end] = '\0'; - return (diff); -} - -/* Fix up point so that it is within the line boundaries after killing - text. If FIX_MARK_TOO is non-zero, the mark is forced within line - boundaries also. */ - -#define _RL_FIX_POINT(x) \ - do { \ - if (x > rl_end) \ - x = rl_end; \ - else if (x < 0) \ - x = 0; \ - } while (0) - -void -_rl_fix_point (fix_mark_too) - int fix_mark_too; -{ - _RL_FIX_POINT (rl_point); - if (fix_mark_too) - _RL_FIX_POINT (rl_mark); -} -#undef _RL_FIX_POINT - -void -_rl_replace_text (text, start, end) - char *text; - int start, end; -{ - rl_begin_undo_group (); - rl_delete_text (start, end + 1); - rl_point = start; - rl_insert_text (text); - rl_end_undo_group (); -} - -/* **************************************************************** */ -/* */ -/* Readline character functions */ -/* */ -/* **************************************************************** */ - -/* This is not a gap editor, just a stupid line input routine. No hair - is involved in writing any of the functions, and none should be. */ - -/* Note that: - - rl_end is the place in the string that we would place '\0'; - i.e., it is always safe to place '\0' there. - - rl_point is the place in the string where the cursor is. Sometimes - this is the same as rl_end. - - Any command that is called interactively receives two arguments. - The first is a count: the numeric arg pased to this command. - The second is the key which invoked this command. -*/ - -/* **************************************************************** */ -/* */ -/* Movement Commands */ -/* */ -/* **************************************************************** */ - -/* Note that if you `optimize' the display for these functions, you cannot - use said functions in other functions which do not do optimizing display. - I.e., you will have to update the data base for rl_redisplay, and you - might as well let rl_redisplay do that job. */ - -/* Move forward COUNT characters. */ -int -rl_forward (count, key) - int count, key; -{ - if (count < 0) - rl_backward (-count, key); - else if (count > 0) - { - int end = rl_point + count; -#if defined (VI_MODE) - int lend = rl_end - (rl_editing_mode == vi_mode); -#else - int lend = rl_end; +#if defined (__MSDOS__) + _rl_bind_if_unbound ("\033[0A", rl_get_previous_history); + _rl_bind_if_unbound ("\033[0B", rl_backward_char); + _rl_bind_if_unbound ("\033[0C", rl_forward_char); + _rl_bind_if_unbound ("\033[0D", rl_get_next_history); #endif - if (end > lend) - { - rl_point = lend; - ding (); - } - else - rl_point = end; - } - - if (rl_end < 0) - rl_end = 0; - - return 0; -} - -/* Move backward COUNT characters. */ -int -rl_backward (count, key) - int count, key; -{ - if (count < 0) - rl_forward (-count, key); - else if (count > 0) - { - if (rl_point < count) - { - rl_point = 0; - ding (); - } - else - rl_point -= count; - } - return 0; -} - -/* Move to the beginning of the line. */ -int -rl_beg_of_line (count, key) - int count, key; -{ - rl_point = 0; - return 0; -} - -/* Move to the end of the line. */ -int -rl_end_of_line (count, key) - int count, key; -{ - rl_point = rl_end; - return 0; -} - -/* Move forward a word. We do what Emacs does. */ -int -rl_forward_word (count, key) - int count, key; -{ - int c; - - if (count < 0) - { - rl_backward_word (-count, key); - return 0; - } - - while (count) - { - if (rl_point == rl_end) - return 0; - - /* If we are not in a word, move forward until we are in one. - Then, move forward until we hit a non-alphabetic character. */ - c = the_line[rl_point]; - if (alphabetic (c) == 0) - { - while (++rl_point < rl_end) - { - c = the_line[rl_point]; - if (alphabetic (c)) - break; - } - } - if (rl_point == rl_end) - return 0; - while (++rl_point < rl_end) - { - c = the_line[rl_point]; - if (alphabetic (c) == 0) - break; - } - --count; - } - return 0; -} - -/* Move backward a word. We do what Emacs does. */ -int -rl_backward_word (count, key) - int count, key; -{ - int c; - - if (count < 0) - { - rl_forward_word (-count, key); - return 0; - } - - while (count) - { - if (!rl_point) - return 0; - - /* Like rl_forward_word (), except that we look at the characters - just before point. */ - - c = the_line[rl_point - 1]; - if (alphabetic (c) == 0) - { - while (--rl_point) - { - c = the_line[rl_point - 1]; - if (alphabetic (c)) - break; - } - } - - while (rl_point) - { - c = the_line[rl_point - 1]; - if (alphabetic (c) == 0) - break; - else - --rl_point; - } - --count; - } - return 0; -} - -/* Clear the current line. Numeric argument to C-l does this. */ -int -rl_refresh_line (ignore1, ignore2) - int ignore1, ignore2; -{ - int curr_line; - - curr_line = _rl_current_display_line (); - - _rl_move_vert (curr_line); - _rl_move_cursor_relative (0, the_line); /* XXX is this right */ - - _rl_clear_to_eol (0); /* arg of 0 means to not use spaces */ - - rl_forced_update_display (); - rl_display_fixed = 1; - - return 0; -} - -/* C-l typed to a line without quoting clears the screen, and then reprints - the prompt and the current input line. Given a numeric arg, redraw only - the current line. */ -int -rl_clear_screen (count, key) - int count, key; -{ - if (rl_explicit_arg) - { - rl_refresh_line (count, key); - return 0; - } - - _rl_clear_screen (); /* calls termcap function to clear screen */ - rl_forced_update_display (); - rl_display_fixed = 1; - - return 0; -} - -int -rl_arrow_keys (count, c) - int count, c; -{ - int ch; - - ch = rl_read_key (); - - switch (_rl_to_upper (ch)) - { - case 'A': - rl_get_previous_history (count, ch); - break; - - case 'B': - rl_get_next_history (count, ch); - break; - - case 'C': - rl_forward (count, ch); - break; - - case 'D': - rl_backward (count, ch); - break; - - default: - ding (); - } - return 0; -} - - -/* **************************************************************** */ -/* */ -/* Text commands */ -/* */ -/* **************************************************************** */ - -/* Insert the character C at the current location, moving point forward. */ -int -rl_insert (count, c) - int count, c; -{ - register int i; - char *string; - - if (count <= 0) - return 0; - - /* If we can optimize, then do it. But don't let people crash - readline because of extra large arguments. */ - if (count > 1 && count <= 1024) - { - string = xmalloc (1 + count); - - for (i = 0; i < count; i++) - string[i] = c; - - string[i] = '\0'; - rl_insert_text (string); - free (string); - - return 0; - } - - if (count > 1024) - { - int decreaser; - char str[1024+1]; - - for (i = 0; i < 1024; i++) - str[i] = c; - - while (count) - { - decreaser = (count > 1024 ? 1024 : count); - str[decreaser] = '\0'; - rl_insert_text (str); - count -= decreaser; - } - - return 0; - } - - /* We are inserting a single character. - If there is pending input, then make a string of all of the - pending characters that are bound to rl_insert, and insert - them all. */ - if (_rl_any_typein ()) - _rl_insert_typein (c); - else - { - /* Inserting a single character. */ - char str[2]; - - str[1] = '\0'; - str[0] = c; - rl_insert_text (str); - } - return 0; -} - -/* Insert the next typed character verbatim. */ -int -rl_quoted_insert (count, key) - int count, key; -{ - int c; + _rl_bind_if_unbound ("\033[A", rl_get_previous_history); + _rl_bind_if_unbound ("\033[B", rl_get_next_history); + _rl_bind_if_unbound ("\033[C", rl_forward_char); + _rl_bind_if_unbound ("\033[D", rl_backward_char); + _rl_bind_if_unbound ("\033[H", rl_beg_of_line); + _rl_bind_if_unbound ("\033[F", rl_end_of_line); -#if defined (HANDLE_SIGNALS) - _rl_disable_tty_signals (); -#endif - c = rl_read_key (); -#if defined (HANDLE_SIGNALS) - _rl_restore_tty_signals (); -#endif + _rl_bind_if_unbound ("\033OA", rl_get_previous_history); + _rl_bind_if_unbound ("\033OB", rl_get_next_history); + _rl_bind_if_unbound ("\033OC", rl_forward_char); + _rl_bind_if_unbound ("\033OD", rl_backward_char); + _rl_bind_if_unbound ("\033OH", rl_beg_of_line); + _rl_bind_if_unbound ("\033OF", rl_end_of_line); - return (rl_insert (count, c)); -} - -/* Insert a tab character. */ -int -rl_tab_insert (count, key) - int count, key; -{ - return (rl_insert (count, '\t')); + _rl_keymap = xkeymap; } -/* What to do when a NEWLINE is pressed. We accept the whole line. - KEY is the key that invoked this command. I guess it could have - meaning in the future. */ -int -rl_newline (count, key) - int count, key; +/* Try and bind the common arrow key prefixes after giving termcap and + the inputrc file a chance to bind them and create `real' keymaps + for the arrow key prefix. */ +static void +bind_arrow_keys () { - rl_done = 1; + bind_arrow_keys_internal (emacs_standard_keymap); #if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - { - _rl_vi_done_inserting (); - _rl_vi_reset_last (); - } -#endif /* VI_MODE */ - - /* If we've been asked to erase empty lines, suppress the final update, - since _rl_update_final calls crlf(). */ - if (rl_erase_empty_line && rl_point == 0 && rl_end == 0) - return 0; - - if (readline_echoing_p) - _rl_update_final (); - return 0; -} - -/* What to do for some uppercase characters, like meta characters, - and some characters appearing in emacs_ctlx_keymap. This function - is just a stub, you bind keys to it and the code in _rl_dispatch () - is special cased. */ -int -rl_do_lowercase_version (ignore1, ignore2) - int ignore1, ignore2; -{ - return 0; -} - -/* Rubout the character behind point. */ -int -rl_rubout (count, key) - int count, key; -{ - if (count < 0) - { - rl_delete (-count, key); - return 0; - } - - if (!rl_point) - { - ding (); - return -1; - } - - if (count > 1 || rl_explicit_arg) - { - int orig_point = rl_point; - rl_backward (count, key); - rl_kill_text (orig_point, rl_point); - } - else - { - int c = the_line[--rl_point]; - rl_delete_text (rl_point, rl_point + 1); - - if (rl_point == rl_end && isprint (c) && _rl_last_c_pos) - { - int l; - l = rl_character_len (c, rl_point); - _rl_erase_at_end_of_line (l); - } - } - return 0; -} - -/* Delete the character under the cursor. Given a numeric argument, - kill that many characters instead. */ -int -rl_delete (count, key) - int count, key; -{ - if (count < 0) - return (rl_rubout (-count, key)); - - if (rl_point == rl_end) - { - ding (); - return -1; - } - - if (count > 1 || rl_explicit_arg) - { - int orig_point = rl_point; - rl_forward (count, key); - rl_kill_text (orig_point, rl_point); - rl_point = orig_point; - return 0; - } - else - return (rl_delete_text (rl_point, rl_point + 1)); -} - -/* Delete the character under the cursor, unless the insertion - point is at the end of the line, in which case the character - behind the cursor is deleted. COUNT is obeyed and may be used - to delete forward or backward that many characters. */ -int -rl_rubout_or_delete (count, key) - int count, key; -{ - if (rl_end != 0 && rl_point == rl_end) - return (rl_rubout (count, key)); - else - return (rl_delete (count, key)); -} - -/* Delete all spaces and tabs around point. */ -int -rl_delete_horizontal_space (count, ignore) - int count, ignore; -{ - int start = rl_point; - - while (rl_point && whitespace (the_line[rl_point - 1])) - rl_point--; - - start = rl_point; - - while (rl_point < rl_end && whitespace (the_line[rl_point])) - rl_point++; - - if (start != rl_point) - { - rl_delete_text (start, rl_point); - rl_point = start; - } - return 0; -} - -/* Like the tcsh editing function delete-char-or-list. The eof character - is caught before this is invoked, so this really does the same thing as - delete-char-or-list-or-eof, as long as it's bound to the eof character. */ -int -rl_delete_or_show_completions (count, key) - int count, key; -{ - if (rl_end != 0 && rl_point == rl_end) - return (rl_possible_completions (count, key)); - else - return (rl_delete (count, key)); -} - -#ifndef RL_COMMENT_BEGIN_DEFAULT -#define RL_COMMENT_BEGIN_DEFAULT "#" + bind_arrow_keys_internal (vi_movement_keymap); + bind_arrow_keys_internal (vi_insertion_keymap); #endif - -/* Turn the current line into a comment in shell history. - A K*rn shell style function. */ -int -rl_insert_comment (count, key) - int count, key; -{ - rl_beg_of_line (1, key); - rl_insert_text (_rl_comment_begin ? _rl_comment_begin - : RL_COMMENT_BEGIN_DEFAULT); - (*rl_redisplay_function) (); - rl_newline (1, '\n'); - return (0); -} - -/* **************************************************************** */ -/* */ -/* Changing Case */ -/* */ -/* **************************************************************** */ - -/* The three kinds of things that we know how to do. */ -#define UpCase 1 -#define DownCase 2 -#define CapCase 3 - -/* Uppercase the word at point. */ -int -rl_upcase_word (count, key) - int count, key; -{ - return (rl_change_case (count, UpCase)); -} - -/* Lowercase the word at point. */ -int -rl_downcase_word (count, key) - int count, key; -{ - return (rl_change_case (count, DownCase)); -} - -/* Upcase the first letter, downcase the rest. */ -int -rl_capitalize_word (count, key) - int count, key; -{ - return (rl_change_case (count, CapCase)); -} - -/* The meaty function. - Change the case of COUNT words, performing OP on them. - OP is one of UpCase, DownCase, or CapCase. - If a negative argument is given, leave point where it started, - otherwise, leave it where it moves to. */ -static int -rl_change_case (count, op) - int count, op; -{ - register int start, end; - int inword, c; - - start = rl_point; - rl_forward_word (count, 0); - end = rl_point; - - if (count < 0) - SWAP (start, end); - - /* We are going to modify some text, so let's prepare to undo it. */ - rl_modifying (start, end); - - for (inword = 0; start < end; start++) - { - c = the_line[start]; - switch (op) - { - case UpCase: - the_line[start] = _rl_to_upper (c); - break; - - case DownCase: - the_line[start] = _rl_to_lower (c); - break; - - case CapCase: - the_line[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c); - inword = alphabetic (the_line[start]); - break; - - default: - ding (); - return -1; - } - } - rl_point = end; - return 0; -} - -/* **************************************************************** */ -/* */ -/* Transposition */ -/* */ -/* **************************************************************** */ - -/* Transpose the words at point. */ -int -rl_transpose_words (count, key) - int count, key; -{ - char *word1, *word2; - int w1_beg, w1_end, w2_beg, w2_end; - int orig_point = rl_point; - - if (!count) - return 0; - - /* Find the two words. */ - rl_forward_word (count, key); - w2_end = rl_point; - rl_backward_word (1, key); - w2_beg = rl_point; - rl_backward_word (count, key); - w1_beg = rl_point; - rl_forward_word (1, key); - w1_end = rl_point; - - /* Do some check to make sure that there really are two words. */ - if ((w1_beg == w2_beg) || (w2_beg < w1_end)) - { - ding (); - rl_point = orig_point; - return -1; - } - - /* Get the text of the words. */ - word1 = rl_copy_text (w1_beg, w1_end); - word2 = rl_copy_text (w2_beg, w2_end); - - /* We are about to do many insertions and deletions. Remember them - as one operation. */ - rl_begin_undo_group (); - - /* Do the stuff at word2 first, so that we don't have to worry - about word1 moving. */ - rl_point = w2_beg; - rl_delete_text (w2_beg, w2_end); - rl_insert_text (word1); - - rl_point = w1_beg; - rl_delete_text (w1_beg, w1_end); - rl_insert_text (word2); - - /* This is exactly correct since the text before this point has not - changed in length. */ - rl_point = w2_end; - - /* I think that does it. */ - rl_end_undo_group (); - free (word1); - free (word2); - - return 0; -} - -/* Transpose the characters at point. If point is at the end of the line, - then transpose the characters before point. */ -int -rl_transpose_chars (count, key) - int count, key; -{ - char dummy[2]; - - if (!count) - return 0; - - if (!rl_point || rl_end < 2) - { - ding (); - return -1; - } - - rl_begin_undo_group (); - - if (rl_point == rl_end) - { - --rl_point; - count = 1; - } - rl_point--; - - dummy[0] = the_line[rl_point]; - dummy[1] = '\0'; - - rl_delete_text (rl_point, rl_point + 1); - - rl_point += count; - _rl_fix_point (0); - rl_insert_text (dummy); - - rl_end_undo_group (); - return 0; } /* **************************************************************** */ /* */ -/* Character Searching */ +/* Saving and Restoring Readline's state */ /* */ /* **************************************************************** */ int -_rl_char_search_internal (count, dir, schar) - int count, dir, schar; +rl_save_state (sp) + struct readline_state *sp; { - int pos, inc; + if (sp == 0) + return -1; - pos = rl_point; - inc = (dir < 0) ? -1 : 1; - while (count) - { - if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end)) - { - ding (); - return -1; - } + sp->point = rl_point; + sp->end = rl_end; + sp->mark = rl_mark; + sp->buffer = rl_line_buffer; + sp->buflen = rl_line_buffer_len; + sp->ul = rl_undo_list; + sp->prompt = rl_prompt; + + sp->rlstate = rl_readline_state; + sp->done = rl_done; + sp->kmap = _rl_keymap; + + sp->lastfunc = rl_last_func; + sp->insmode = rl_insert_mode; + sp->edmode = rl_editing_mode; + sp->kseqlen = rl_key_sequence_length; + sp->inf = rl_instream; + sp->outf = rl_outstream; + sp->pendingin = rl_pending_input; + sp->macro = rl_executing_macro; + + sp->catchsigs = rl_catch_signals; + sp->catchsigwinch = rl_catch_sigwinch; - pos += inc; - do - { - if (rl_line_buffer[pos] == schar) - { - count--; - if (dir < 0) - rl_point = (dir == BTO) ? pos + 1 : pos; - else - rl_point = (dir == FTO) ? pos - 1 : pos; - break; - } - } - while ((dir < 0) ? pos-- : ++pos < rl_end); - } return (0); } -/* Search COUNT times for a character read from the current input stream. - FDIR is the direction to search if COUNT is non-negative; otherwise - the search goes in BDIR. */ -static int -_rl_char_search (count, fdir, bdir) - int count, fdir, bdir; -{ - int c; - - c = rl_read_key (); - if (count < 0) - return (_rl_char_search_internal (-count, bdir, c)); - else - return (_rl_char_search_internal (count, fdir, c)); -} - int -rl_char_search (count, key) - int count, key; +rl_restore_state (sp) + struct readline_state *sp; { - return (_rl_char_search (count, FFIND, BFIND)); -} - -int -rl_backward_char_search (count, key) - int count, key; -{ - return (_rl_char_search (count, BFIND, FFIND)); -} - -/* **************************************************************** */ -/* */ -/* History Utilities */ -/* */ -/* **************************************************************** */ - -/* We already have a history library, and that is what we use to control - the history features of readline. This is our local interface to - the history mechanism. */ - -/* While we are editing the history, this is the saved - version of the original line. */ -HIST_ENTRY *saved_line_for_history = (HIST_ENTRY *)NULL; - -/* Set the history pointer back to the last entry in the history. */ -static void -start_using_history () -{ - using_history (); - if (saved_line_for_history) - _rl_free_history_entry (saved_line_for_history); - - saved_line_for_history = (HIST_ENTRY *)NULL; -} - -/* Free the contents (and containing structure) of a HIST_ENTRY. */ -void -_rl_free_history_entry (entry) - HIST_ENTRY *entry; -{ - if (entry == 0) - return; - if (entry->line) - free (entry->line); - free (entry); -} - -/* Perhaps put back the current line if it has changed. */ -int -maybe_replace_line () -{ - HIST_ENTRY *temp; - - temp = current_history (); - /* If the current line has changed, save the changes. */ - if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list)) - { - temp = replace_history_entry (where_history (), the_line, (histdata_t)rl_undo_list); - free (temp->line); - free (temp); - } - return 0; -} - -/* Put back the saved_line_for_history if there is one. */ -int -maybe_unsave_line () -{ - int line_len; - - if (saved_line_for_history) - { - line_len = strlen (saved_line_for_history->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strlcpy (the_line, saved_line_for_history->line, rl_line_buffer_len); - rl_undo_list = (UNDO_LIST *)saved_line_for_history->data; - _rl_free_history_entry (saved_line_for_history); - saved_line_for_history = (HIST_ENTRY *)NULL; - rl_end = rl_point = strlen (the_line); - } - else - ding (); - return 0; -} - -/* Save the current line in saved_line_for_history. */ -int -maybe_save_line () -{ - if (saved_line_for_history == 0) - { - saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); - saved_line_for_history->line = savestring (the_line); - saved_line_for_history->data = (char *)rl_undo_list; - } - return 0; -} - -/* **************************************************************** */ -/* */ -/* History Commands */ -/* */ -/* **************************************************************** */ - -/* Meta-< goes to the start of the history. */ -int -rl_beginning_of_history (count, key) - int count, key; -{ - return (rl_get_previous_history (1 + where_history (), key)); -} - -/* Meta-> goes to the end of the history. (The current line). */ -int -rl_end_of_history (count, key) - int count, key; -{ - maybe_replace_line (); - using_history (); - maybe_unsave_line (); - return 0; -} - -/* Move down to the next history line. */ -int -rl_get_next_history (count, key) - int count, key; -{ - HIST_ENTRY *temp; - int line_len; - - if (count < 0) - return (rl_get_previous_history (-count, key)); - - if (count == 0) - return 0; - - maybe_replace_line (); - - temp = (HIST_ENTRY *)NULL; - while (count) - { - temp = next_history (); - if (!temp) - break; - --count; - } - - if (temp == 0) - maybe_unsave_line (); - else - { - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strlcpy (the_line, temp->line, rl_line_buffer_len); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = strlen (the_line); -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } - return 0; -} - -/* Get the previous item out of our interactive history, making it the current - line. If there is no previous history, just ding. */ -int -rl_get_previous_history (count, key) - int count, key; -{ - HIST_ENTRY *old_temp, *temp; - int line_len; - - if (count < 0) - return (rl_get_next_history (-count, key)); - - if (count == 0) - return 0; - - /* If we don't have a line saved, then save this one. */ - maybe_save_line (); - - /* If the current line has changed, save the changes. */ - maybe_replace_line (); - - temp = old_temp = (HIST_ENTRY *)NULL; - while (count) - { - temp = previous_history (); - if (temp == 0) - break; - - old_temp = temp; - --count; - } - - /* If there was a large argument, and we moved back to the start of the - history, that is not an error. So use the last value found. */ - if (!temp && old_temp) - temp = old_temp; - - if (temp == 0) - ding (); - else - { - line_len = strlen (temp->line); - - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - - strlcpy (the_line, temp->line, rl_line_buffer_len); - rl_undo_list = (UNDO_LIST *)temp->data; - rl_end = rl_point = line_len; - -#if defined (VI_MODE) - if (rl_editing_mode == vi_mode) - rl_point = 0; -#endif /* VI_MODE */ - } - return 0; -} - -/* **************************************************************** */ -/* */ -/* The Mark and the Region. */ -/* */ -/* **************************************************************** */ - -/* Set the mark at POSITION. */ -int -_rl_set_mark_at_pos (position) - int position; -{ - if (position > rl_end) + if (sp == 0) return -1; - rl_mark = position; - return 0; -} - -/* A bindable command to set the mark. */ -int -rl_set_mark (count, key) - int count, key; -{ - return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point)); -} - -/* Exchange the position of mark and point. */ -int -rl_exchange_point_and_mark (count, key) - int count, key; -{ - if (rl_mark > rl_end) - rl_mark = -1; - - if (rl_mark == -1) - { - ding (); - return -1; - } - else - SWAP (rl_point, rl_mark); - - return 0; -} - -/* **************************************************************** */ -/* */ -/* Editing Modes */ -/* */ -/* **************************************************************** */ -/* How to toggle back and forth between editing modes. */ -int -rl_vi_editing_mode (count, key) - int count, key; -{ -#if defined (VI_MODE) - rl_editing_mode = vi_mode; - rl_vi_insertion_mode (1, key); -#endif /* VI_MODE */ - return 0; -} + rl_point = sp->point; + rl_end = sp->end; + rl_mark = sp->mark; + the_line = rl_line_buffer = sp->buffer; + rl_line_buffer_len = sp->buflen; + rl_undo_list = sp->ul; + rl_prompt = sp->prompt; + + rl_readline_state = sp->rlstate; + rl_done = sp->done; + _rl_keymap = sp->kmap; + + rl_last_func = sp->lastfunc; + rl_insert_mode = sp->insmode; + rl_editing_mode = sp->edmode; + rl_key_sequence_length = sp->kseqlen; + rl_instream = sp->inf; + rl_outstream = sp->outf; + rl_pending_input = sp->pendingin; + rl_executing_macro = sp->macro; + + rl_catch_signals = sp->catchsigs; + rl_catch_sigwinch = sp->catchsigwinch; -int -rl_emacs_editing_mode (count, key) - int count, key; -{ - rl_editing_mode = emacs_mode; - _rl_keymap = emacs_standard_keymap; - return 0; + return (0); } diff --git a/gnu/lib/libreadline/readline.h b/gnu/lib/libreadline/readline.h index 1531b8f7753..f11b3d0357c 100644 --- a/gnu/lib/libreadline/readline.h +++ b/gnu/lib/libreadline/readline.h @@ -29,14 +29,21 @@ extern "C" { #if defined (READLINE_LIBRARY) # include "rlstdc.h" +# include "rltypedefs.h" # include "keymaps.h" # include "tilde.h" #else # include <readline/rlstdc.h> +# include <readline/rltypedefs.h> # include <readline/keymaps.h> # include <readline/tilde.h> #endif +/* Hex-encoded Readline version number. */ +#define RL_READLINE_VERSION 0x0403 /* Readline 4.3 */ +#define RL_VERSION_MAJOR 4 +#define RL_VERSION_MINOR 3 + /* Readline data structures. */ /* Maintaining the state of undo. We remember individual deletes and inserts @@ -60,8 +67,8 @@ extern UNDO_LIST *rl_undo_list; /* The data structure for mapping textual names to code addresses. */ typedef struct _funmap { - char *name; - Function *function; + const char *name; + rl_command_func_t *function; } FUNMAP; extern FUNMAP **funmap; @@ -73,184 +80,191 @@ extern FUNMAP **funmap; /* **************************************************************** */ /* Bindable commands for numeric arguments. */ -extern int rl_digit_argument __P((int, int)); -extern int rl_universal_argument __P((int, int)); +extern int rl_digit_argument PARAMS((int, int)); +extern int rl_universal_argument PARAMS((int, int)); /* Bindable commands for moving the cursor. */ -extern int rl_forward __P((int, int)); -extern int rl_backward __P((int, int)); -extern int rl_beg_of_line __P((int, int)); -extern int rl_end_of_line __P((int, int)); -extern int rl_forward_word __P((int, int)); -extern int rl_backward_word __P((int, int)); -extern int rl_refresh_line __P((int, int)); -extern int rl_clear_screen __P((int, int)); -extern int rl_arrow_keys __P((int, int)); +extern int rl_forward_byte PARAMS((int, int)); +extern int rl_forward_char PARAMS((int, int)); +extern int rl_forward PARAMS((int, int)); +extern int rl_backward_byte PARAMS((int, int)); +extern int rl_backward_char PARAMS((int, int)); +extern int rl_backward PARAMS((int, int)); +extern int rl_beg_of_line PARAMS((int, int)); +extern int rl_end_of_line PARAMS((int, int)); +extern int rl_forward_word PARAMS((int, int)); +extern int rl_backward_word PARAMS((int, int)); +extern int rl_refresh_line PARAMS((int, int)); +extern int rl_clear_screen PARAMS((int, int)); +extern int rl_arrow_keys PARAMS((int, int)); /* Bindable commands for inserting and deleting text. */ -extern int rl_insert __P((int, int)); -extern int rl_quoted_insert __P((int, int)); -extern int rl_tab_insert __P((int, int)); -extern int rl_newline __P((int, int)); -extern int rl_do_lowercase_version __P((int, int)); -extern int rl_rubout __P((int, int)); -extern int rl_delete __P((int, int)); -extern int rl_rubout_or_delete __P((int, int)); -extern int rl_delete_horizontal_space __P((int, int)); -extern int rl_delete_or_show_completions __P((int, int)); -extern int rl_insert_comment __P((int, int)); +extern int rl_insert PARAMS((int, int)); +extern int rl_quoted_insert PARAMS((int, int)); +extern int rl_tab_insert PARAMS((int, int)); +extern int rl_newline PARAMS((int, int)); +extern int rl_do_lowercase_version PARAMS((int, int)); +extern int rl_rubout PARAMS((int, int)); +extern int rl_delete PARAMS((int, int)); +extern int rl_rubout_or_delete PARAMS((int, int)); +extern int rl_delete_horizontal_space PARAMS((int, int)); +extern int rl_delete_or_show_completions PARAMS((int, int)); +extern int rl_insert_comment PARAMS((int, int)); /* Bindable commands for changing case. */ -extern int rl_upcase_word __P((int, int)); -extern int rl_downcase_word __P((int, int)); -extern int rl_capitalize_word __P((int, int)); +extern int rl_upcase_word PARAMS((int, int)); +extern int rl_downcase_word PARAMS((int, int)); +extern int rl_capitalize_word PARAMS((int, int)); /* Bindable commands for transposing characters and words. */ -extern int rl_transpose_words __P((int, int)); -extern int rl_transpose_chars __P((int, int)); +extern int rl_transpose_words PARAMS((int, int)); +extern int rl_transpose_chars PARAMS((int, int)); /* Bindable commands for searching within a line. */ -extern int rl_char_search __P((int, int)); -extern int rl_backward_char_search __P((int, int)); +extern int rl_char_search PARAMS((int, int)); +extern int rl_backward_char_search PARAMS((int, int)); /* Bindable commands for readline's interface to the command history. */ -extern int rl_beginning_of_history __P((int, int)); -extern int rl_end_of_history __P((int, int)); -extern int rl_get_next_history __P((int, int)); -extern int rl_get_previous_history __P((int, int)); +extern int rl_beginning_of_history PARAMS((int, int)); +extern int rl_end_of_history PARAMS((int, int)); +extern int rl_get_next_history PARAMS((int, int)); +extern int rl_get_previous_history PARAMS((int, int)); /* Bindable commands for managing the mark and region. */ -extern int rl_set_mark __P((int, int)); -extern int rl_exchange_point_and_mark __P((int, int)); +extern int rl_set_mark PARAMS((int, int)); +extern int rl_exchange_point_and_mark PARAMS((int, int)); /* Bindable commands to set the editing mode (emacs or vi). */ -extern int rl_vi_editing_mode __P((int, int)); -extern int rl_emacs_editing_mode __P((int, int)); +extern int rl_vi_editing_mode PARAMS((int, int)); +extern int rl_emacs_editing_mode PARAMS((int, int)); + +/* Bindable commands to change the insert mode (insert or overwrite) */ +extern int rl_overwrite_mode PARAMS((int, int)); /* Bindable commands for managing key bindings. */ -extern int rl_re_read_init_file __P((int, int)); -extern int rl_dump_functions __P((int, int)); -extern int rl_dump_macros __P((int, int)); -extern int rl_dump_variables __P((int, int)); +extern int rl_re_read_init_file PARAMS((int, int)); +extern int rl_dump_functions PARAMS((int, int)); +extern int rl_dump_macros PARAMS((int, int)); +extern int rl_dump_variables PARAMS((int, int)); /* Bindable commands for word completion. */ -extern int rl_complete __P((int, int)); -extern int rl_possible_completions __P((int, int)); -extern int rl_insert_completions __P((int, int)); -extern int rl_menu_complete __P((int, int)); +extern int rl_complete PARAMS((int, int)); +extern int rl_possible_completions PARAMS((int, int)); +extern int rl_insert_completions PARAMS((int, int)); +extern int rl_menu_complete PARAMS((int, int)); /* Bindable commands for killing and yanking text, and managing the kill ring. */ -extern int rl_kill_word __P((int, int)); -extern int rl_backward_kill_word __P((int, int)); -extern int rl_kill_line __P((int, int)); -extern int rl_backward_kill_line __P((int, int)); -extern int rl_kill_full_line __P((int, int)); -extern int rl_unix_word_rubout __P((int, int)); -extern int rl_unix_line_discard __P((int, int)); -extern int rl_copy_region_to_kill __P((int, int)); -extern int rl_kill_region __P((int, int)); -extern int rl_copy_forward_word __P((int, int)); -extern int rl_copy_backward_word __P((int, int)); -extern int rl_yank __P((int, int)); -extern int rl_yank_pop __P((int, int)); -extern int rl_yank_nth_arg __P((int, int)); -extern int rl_yank_last_arg __P((int, int)); -/* Not available unless __CYGWIN32__ is defined. */ -#ifdef __CYGWIN32__ -extern int rl_paste_from_clipboard __P((int, int)); +extern int rl_kill_word PARAMS((int, int)); +extern int rl_backward_kill_word PARAMS((int, int)); +extern int rl_kill_line PARAMS((int, int)); +extern int rl_backward_kill_line PARAMS((int, int)); +extern int rl_kill_full_line PARAMS((int, int)); +extern int rl_unix_word_rubout PARAMS((int, int)); +extern int rl_unix_line_discard PARAMS((int, int)); +extern int rl_copy_region_to_kill PARAMS((int, int)); +extern int rl_kill_region PARAMS((int, int)); +extern int rl_copy_forward_word PARAMS((int, int)); +extern int rl_copy_backward_word PARAMS((int, int)); +extern int rl_yank PARAMS((int, int)); +extern int rl_yank_pop PARAMS((int, int)); +extern int rl_yank_nth_arg PARAMS((int, int)); +extern int rl_yank_last_arg PARAMS((int, int)); +/* Not available unless __CYGWIN__ is defined. */ +#ifdef __CYGWIN__ +extern int rl_paste_from_clipboard PARAMS((int, int)); #endif /* Bindable commands for incremental searching. */ -extern int rl_reverse_search_history __P((int, int)); -extern int rl_forward_search_history __P((int, int)); +extern int rl_reverse_search_history PARAMS((int, int)); +extern int rl_forward_search_history PARAMS((int, int)); /* Bindable keyboard macro commands. */ -extern int rl_start_kbd_macro __P((int, int)); -extern int rl_end_kbd_macro __P((int, int)); -extern int rl_call_last_kbd_macro __P((int, int)); +extern int rl_start_kbd_macro PARAMS((int, int)); +extern int rl_end_kbd_macro PARAMS((int, int)); +extern int rl_call_last_kbd_macro PARAMS((int, int)); /* Bindable undo commands. */ -extern int rl_revert_line __P((int, int)); -extern int rl_undo_command __P((int, int)); +extern int rl_revert_line PARAMS((int, int)); +extern int rl_undo_command PARAMS((int, int)); /* Bindable tilde expansion commands. */ -extern int rl_tilde_expand __P((int, int)); +extern int rl_tilde_expand PARAMS((int, int)); /* Bindable terminal control commands. */ -extern int rl_restart_output __P((int, int)); -extern int rl_stop_output __P((int, int)); +extern int rl_restart_output PARAMS((int, int)); +extern int rl_stop_output PARAMS((int, int)); /* Miscellaneous bindable commands. */ -extern int rl_abort __P((int, int)); -extern int rl_tty_status __P((int, int)); +extern int rl_abort PARAMS((int, int)); +extern int rl_tty_status PARAMS((int, int)); /* Bindable commands for incremental and non-incremental history searching. */ -extern int rl_history_search_forward __P((int, int)); -extern int rl_history_search_backward __P((int, int)); -extern int rl_noninc_forward_search __P((int, int)); -extern int rl_noninc_reverse_search __P((int, int)); -extern int rl_noninc_forward_search_again __P((int, int)); -extern int rl_noninc_reverse_search_again __P((int, int)); +extern int rl_history_search_forward PARAMS((int, int)); +extern int rl_history_search_backward PARAMS((int, int)); +extern int rl_noninc_forward_search PARAMS((int, int)); +extern int rl_noninc_reverse_search PARAMS((int, int)); +extern int rl_noninc_forward_search_again PARAMS((int, int)); +extern int rl_noninc_reverse_search_again PARAMS((int, int)); /* Bindable command used when inserting a matching close character. */ -extern int rl_insert_close __P((int, int)); +extern int rl_insert_close PARAMS((int, int)); /* Not available unless READLINE_CALLBACKS is defined. */ -extern void rl_callback_handler_install __P((char *, VFunction *)); -extern void rl_callback_read_char __P((void)); -extern void rl_callback_handler_remove __P((void)); +extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *)); +extern void rl_callback_read_char PARAMS((void)); +extern void rl_callback_handler_remove PARAMS((void)); /* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */ /* VI-mode bindable commands. */ -extern int rl_vi_redo __P((int, int)); -extern int rl_vi_undo __P((int, int)); -extern int rl_vi_yank_arg __P((int, int)); -extern int rl_vi_fetch_history __P((int, int)); -extern int rl_vi_search_again __P((int, int)); -extern int rl_vi_search __P((int, int)); -extern int rl_vi_complete __P((int, int)); -extern int rl_vi_tilde_expand __P((int, int)); -extern int rl_vi_prev_word __P((int, int)); -extern int rl_vi_next_word __P((int, int)); -extern int rl_vi_end_word __P((int, int)); -extern int rl_vi_insert_beg __P((int, int)); -extern int rl_vi_append_mode __P((int, int)); -extern int rl_vi_append_eol __P((int, int)); -extern int rl_vi_eof_maybe __P((int, int)); -extern int rl_vi_insertion_mode __P((int, int)); -extern int rl_vi_movement_mode __P((int, int)); -extern int rl_vi_arg_digit __P((int, int)); -extern int rl_vi_change_case __P((int, int)); -extern int rl_vi_put __P((int, int)); -extern int rl_vi_column __P((int, int)); -extern int rl_vi_delete_to __P((int, int)); -extern int rl_vi_change_to __P((int, int)); -extern int rl_vi_yank_to __P((int, int)); -extern int rl_vi_delete __P((int, int)); -extern int rl_vi_back_to_indent __P((int, int)); -extern int rl_vi_first_print __P((int, int)); -extern int rl_vi_char_search __P((int, int)); -extern int rl_vi_match __P((int, int)); -extern int rl_vi_change_char __P((int, int)); -extern int rl_vi_subst __P((int, int)); -extern int rl_vi_overstrike __P((int, int)); -extern int rl_vi_overstrike_delete __P((int, int)); -extern int rl_vi_replace __P((int, int)); -extern int rl_vi_set_mark __P((int, int)); -extern int rl_vi_goto_mark __P((int, int)); +extern int rl_vi_redo PARAMS((int, int)); +extern int rl_vi_undo PARAMS((int, int)); +extern int rl_vi_yank_arg PARAMS((int, int)); +extern int rl_vi_fetch_history PARAMS((int, int)); +extern int rl_vi_search_again PARAMS((int, int)); +extern int rl_vi_search PARAMS((int, int)); +extern int rl_vi_complete PARAMS((int, int)); +extern int rl_vi_tilde_expand PARAMS((int, int)); +extern int rl_vi_prev_word PARAMS((int, int)); +extern int rl_vi_next_word PARAMS((int, int)); +extern int rl_vi_end_word PARAMS((int, int)); +extern int rl_vi_insert_beg PARAMS((int, int)); +extern int rl_vi_append_mode PARAMS((int, int)); +extern int rl_vi_append_eol PARAMS((int, int)); +extern int rl_vi_eof_maybe PARAMS((int, int)); +extern int rl_vi_insertion_mode PARAMS((int, int)); +extern int rl_vi_movement_mode PARAMS((int, int)); +extern int rl_vi_arg_digit PARAMS((int, int)); +extern int rl_vi_change_case PARAMS((int, int)); +extern int rl_vi_put PARAMS((int, int)); +extern int rl_vi_column PARAMS((int, int)); +extern int rl_vi_delete_to PARAMS((int, int)); +extern int rl_vi_change_to PARAMS((int, int)); +extern int rl_vi_yank_to PARAMS((int, int)); +extern int rl_vi_delete PARAMS((int, int)); +extern int rl_vi_back_to_indent PARAMS((int, int)); +extern int rl_vi_first_print PARAMS((int, int)); +extern int rl_vi_char_search PARAMS((int, int)); +extern int rl_vi_match PARAMS((int, int)); +extern int rl_vi_change_char PARAMS((int, int)); +extern int rl_vi_subst PARAMS((int, int)); +extern int rl_vi_overstrike PARAMS((int, int)); +extern int rl_vi_overstrike_delete PARAMS((int, int)); +extern int rl_vi_replace PARAMS((int, int)); +extern int rl_vi_set_mark PARAMS((int, int)); +extern int rl_vi_goto_mark PARAMS((int, int)); /* VI-mode utility functions. */ -extern int rl_vi_check __P((void)); -extern int rl_vi_domove __P((int, int *)); -extern int rl_vi_bracktype __P((int)); +extern int rl_vi_check PARAMS((void)); +extern int rl_vi_domove PARAMS((int, int *)); +extern int rl_vi_bracktype PARAMS((int)); /* VI-mode pseudo-bindable commands, used as utility functions. */ -extern int rl_vi_fWord __P((int, int)); -extern int rl_vi_bWord __P((int, int)); -extern int rl_vi_eWord __P((int, int)); -extern int rl_vi_fword __P((int, int)); -extern int rl_vi_bword __P((int, int)); -extern int rl_vi_eword __P((int, int)); +extern int rl_vi_fWord PARAMS((int, int)); +extern int rl_vi_bWord PARAMS((int, int)); +extern int rl_vi_eWord PARAMS((int, int)); +extern int rl_vi_fword PARAMS((int, int)); +extern int rl_vi_bword PARAMS((int, int)); +extern int rl_vi_eword PARAMS((int, int)); /* **************************************************************** */ /* */ @@ -260,142 +274,176 @@ extern int rl_vi_eword __P((int, int)); /* Readline functions. */ /* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */ -extern char *readline __P((char *)); +extern char *readline PARAMS((const char *)); -extern int rl_initialize __P((void)); +extern int rl_set_prompt PARAMS((const char *)); +extern int rl_expand_prompt PARAMS((char *)); -extern int rl_discard_argument __P((void)); +extern int rl_initialize PARAMS((void)); + +/* Undocumented; unused by readline */ +extern int rl_discard_argument PARAMS((void)); /* Utility functions to bind keys to readline commands. */ -extern int rl_add_defun __P((char *, Function *, int)); -extern int rl_bind_key __P((int, Function *)); -extern int rl_bind_key_in_map __P((int, Function *, Keymap)); -extern int rl_unbind_key __P((int)); -extern int rl_unbind_key_in_map __P((int, Keymap)); -extern int rl_unbind_function_in_map __P((Function *, Keymap)); -extern int rl_unbind_command_in_map __P((char *, Keymap)); -extern int rl_set_key __P((char *, Function *, Keymap)); -extern int rl_generic_bind __P((int, char *, char *, Keymap)); -extern int rl_variable_bind __P((char *, char *)); +extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int)); +extern int rl_bind_key PARAMS((int, rl_command_func_t *)); +extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap)); +extern int rl_unbind_key PARAMS((int)); +extern int rl_unbind_key_in_map PARAMS((int, Keymap)); +extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap)); +extern int rl_unbind_command_in_map PARAMS((const char *, Keymap)); +extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap)); +extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap)); +extern int rl_variable_bind PARAMS((const char *, const char *)); /* Backwards compatibility, use rl_generic_bind instead. */ -extern int rl_macro_bind __P((char *, char *, Keymap)); +extern int rl_macro_bind PARAMS((const char *, const char *, Keymap)); /* Undocumented in the texinfo manual; not really useful to programs. */ -extern int rl_translate_keyseq __P((char *, char *, int *)); -extern char *rl_untranslate_keyseq __P((int)); +extern int rl_translate_keyseq PARAMS((const char *, char *, int *)); +extern char *rl_untranslate_keyseq PARAMS((int)); -extern Function *rl_named_function __P((char *)); -extern Function *rl_function_of_keyseq __P((char *, Keymap, int *)); +extern rl_command_func_t *rl_named_function PARAMS((const char *)); +extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *)); -extern void rl_list_funmap_names __P((void)); -extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap)); -extern char **rl_invoking_keyseqs __P((Function *)); +extern void rl_list_funmap_names PARAMS((void)); +extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap)); +extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *)); -extern void rl_function_dumper __P((int)); -extern void rl_macro_dumper __P((int)); -extern void rl_variable_dumper __P((int)); +extern void rl_function_dumper PARAMS((int)); +extern void rl_macro_dumper PARAMS((int)); +extern void rl_variable_dumper PARAMS((int)); -extern int rl_read_init_file __P((char *)); -extern int rl_parse_and_bind __P((char *)); +extern int rl_read_init_file PARAMS((const char *)); +extern int rl_parse_and_bind PARAMS((char *)); /* Functions for manipulating keymaps. */ -extern Keymap rl_make_bare_keymap __P((void)); -extern Keymap rl_copy_keymap __P((Keymap)); -extern Keymap rl_make_keymap __P((void)); -extern void rl_discard_keymap __P((Keymap)); - -extern Keymap rl_get_keymap_by_name __P((char *)); -extern char *rl_get_keymap_name __P((Keymap)); -extern void rl_set_keymap __P((Keymap)); -extern Keymap rl_get_keymap __P((void)); -extern void rl_set_keymap_from_edit_mode __P((void)); -extern char *rl_get_keymap_name_from_edit_mode __P((void)); +extern Keymap rl_make_bare_keymap PARAMS((void)); +extern Keymap rl_copy_keymap PARAMS((Keymap)); +extern Keymap rl_make_keymap PARAMS((void)); +extern void rl_discard_keymap PARAMS((Keymap)); + +extern Keymap rl_get_keymap_by_name PARAMS((const char *)); +extern char *rl_get_keymap_name PARAMS((Keymap)); +extern void rl_set_keymap PARAMS((Keymap)); +extern Keymap rl_get_keymap PARAMS((void)); +/* Undocumented; used internally only. */ +extern void rl_set_keymap_from_edit_mode PARAMS((void)); +extern char *rl_get_keymap_name_from_edit_mode PARAMS((void)); /* Functions for manipulating the funmap, which maps command names to functions. */ -extern int rl_add_funmap_entry __P((char *, Function *)); -extern void rl_initialize_funmap __P((void)); -extern char **rl_funmap_names __P((void)); +extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *)); +extern const char **rl_funmap_names PARAMS((void)); +/* Undocumented, only used internally -- there is only one funmap, and this + function may be called only once. */ +extern void rl_initialize_funmap PARAMS((void)); /* Utility functions for managing keyboard macros. */ -extern void rl_push_macro_input __P((char *)); +extern void rl_push_macro_input PARAMS((char *)); /* Functions for undoing, from undo.c */ -extern void rl_add_undo __P((enum undo_code, int, int, char *)); -extern void free_undo_list __P((void)); -extern int rl_do_undo __P((void)); -extern int rl_begin_undo_group __P((void)); -extern int rl_end_undo_group __P((void)); -extern int rl_modifying __P((int, int)); +extern void rl_add_undo PARAMS((enum undo_code, int, int, char *)); +extern void rl_free_undo_list PARAMS((void)); +extern int rl_do_undo PARAMS((void)); +extern int rl_begin_undo_group PARAMS((void)); +extern int rl_end_undo_group PARAMS((void)); +extern int rl_modifying PARAMS((int, int)); /* Functions for redisplay. */ -extern void rl_redisplay __P((void)); -extern int rl_on_new_line __P((void)); -extern int rl_on_new_line_with_prompt __P((void)); -extern int rl_forced_update_display __P((void)); -extern int rl_clear_message __P((void)); -extern int rl_reset_line_state __P((void)); +extern void rl_redisplay PARAMS((void)); +extern int rl_on_new_line PARAMS((void)); +extern int rl_on_new_line_with_prompt PARAMS((void)); +extern int rl_forced_update_display PARAMS((void)); +extern int rl_clear_message PARAMS((void)); +extern int rl_reset_line_state PARAMS((void)); +extern int rl_crlf PARAMS((void)); #if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG) -extern int rl_message (const char *, ...); +extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2))); #else extern int rl_message (); #endif +extern int rl_show_char PARAMS((int)); + /* Undocumented in texinfo manual. */ -extern int rl_show_char __P((int)); -extern int rl_character_len __P((int, int)); -extern int crlf __P((void)); +extern int rl_character_len PARAMS((int, int)); /* Save and restore internal prompt redisplay information. */ -extern void rl_save_prompt __P((void)); -extern void rl_restore_prompt __P((void)); +extern void rl_save_prompt PARAMS((void)); +extern void rl_restore_prompt PARAMS((void)); /* Modifying text. */ -extern int rl_insert_text __P((char *)); -extern int rl_delete_text __P((int, int)); -extern int rl_kill_text __P((int, int)); -extern char *rl_copy_text __P((int, int)); +extern void rl_replace_line PARAMS((const char *, int)); +extern int rl_insert_text PARAMS((const char *)); +extern int rl_delete_text PARAMS((int, int)); +extern int rl_kill_text PARAMS((int, int)); +extern char *rl_copy_text PARAMS((int, int)); /* Terminal and tty mode management. */ -extern void rl_prep_terminal __P((int)); -extern void rl_deprep_terminal __P((void)); -extern void rltty_set_default_bindings __P((Keymap)); +extern void rl_prep_terminal PARAMS((int)); +extern void rl_deprep_terminal PARAMS((void)); +extern void rl_tty_set_default_bindings PARAMS((Keymap)); -extern int rl_reset_terminal __P((char *)); -extern void rl_resize_terminal __P((void)); +extern int rl_reset_terminal PARAMS((const char *)); +extern void rl_resize_terminal PARAMS((void)); +extern void rl_set_screen_size PARAMS((int, int)); +extern void rl_get_screen_size PARAMS((int *, int *)); -/* `Public' utility functions . */ -extern void rl_extend_line_buffer __P((int)); -extern int ding __P((void)); +extern char *rl_get_termcap PARAMS((const char *)); /* Functions for character input. */ -extern int rl_stuff_char __P((int)); -extern int rl_execute_next __P((int)); -extern int rl_read_key __P((void)); -extern int rl_getc __P((FILE *)); +extern int rl_stuff_char PARAMS((int)); +extern int rl_execute_next PARAMS((int)); +extern int rl_clear_pending_input PARAMS((void)); +extern int rl_read_key PARAMS((void)); +extern int rl_getc PARAMS((FILE *)); +extern int rl_set_keyboard_input_timeout PARAMS((int)); + +/* `Public' utility functions . */ +extern void rl_extend_line_buffer PARAMS((int)); +extern int rl_ding PARAMS((void)); +extern int rl_alphabetic PARAMS((int)); /* Readline signal handling, from signals.c */ -extern int rl_set_signals __P((void)); -extern int rl_clear_signals __P((void)); -extern void rl_cleanup_after_signal __P((void)); -extern void rl_reset_after_signal __P((void)); -extern void rl_free_line_state __P((void)); +extern int rl_set_signals PARAMS((void)); +extern int rl_clear_signals PARAMS((void)); +extern void rl_cleanup_after_signal PARAMS((void)); +extern void rl_reset_after_signal PARAMS((void)); +extern void rl_free_line_state PARAMS((void)); -/* Undocumented. */ -extern int rl_expand_prompt __P((char *)); +extern int rl_set_paren_blink_timeout PARAMS((int)); -extern int maybe_save_line __P((void)); -extern int maybe_unsave_line __P((void)); -extern int maybe_replace_line __P((void)); +/* Undocumented. */ +extern int rl_maybe_save_line PARAMS((void)); +extern int rl_maybe_unsave_line PARAMS((void)); +extern int rl_maybe_replace_line PARAMS((void)); /* Completion functions. */ -extern int rl_complete_internal __P((int)); -extern void rl_display_match_list __P((char **, int, int)); +extern int rl_complete_internal PARAMS((int)); +extern void rl_display_match_list PARAMS((char **, int, int)); + +extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *)); +extern char *rl_username_completion_function PARAMS((const char *, int)); +extern char *rl_filename_completion_function PARAMS((const char *, int)); + +extern int rl_completion_mode PARAMS((rl_command_func_t *)); -extern char **completion_matches __P((char *, CPFunction *)); -extern char *username_completion_function __P((char *, int)); -extern char *filename_completion_function __P((char *, int)); +#if 0 +/* Backwards compatibility (compat.c). These will go away sometime. */ +extern void free_undo_list PARAMS((void)); +extern int maybe_save_line PARAMS((void)); +extern int maybe_unsave_line PARAMS((void)); +extern int maybe_replace_line PARAMS((void)); + +extern int ding PARAMS((void)); +extern int alphabetic PARAMS((int)); +extern int crlf PARAMS((void)); + +extern char **completion_matches PARAMS((char *, rl_compentry_func_t *)); +extern char *username_completion_function PARAMS((const char *, int)); +extern char *filename_completion_function PARAMS((const char *, int)); +#endif /* **************************************************************** */ /* */ @@ -404,14 +452,26 @@ extern char *filename_completion_function __P((char *, int)); /* **************************************************************** */ /* The version of this incarnation of the readline library. */ -extern char *rl_library_version; +extern const char *rl_library_version; /* e.g., "4.2" */ +extern int rl_readline_version; /* e.g., 0x0402 */ /* True if this is real GNU readline. */ extern int rl_gnu_readline_p; +/* Flags word encapsulating the current readline state. */ +extern int rl_readline_state; + +/* Says which editing mode readline is currently using. 1 means emacs mode; + 0 means vi mode. */ +extern int rl_editing_mode; + +/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means + overwrite mode. Reset to insert mode on each input line. */ +extern int rl_insert_mode; + /* The name of the calling program. You should initialize this to whatever was in argv[0]. It is used when parsing conditionals. */ -extern char *rl_readline_name; +extern const char *rl_readline_name; /* The prompt readline uses. This is set from the argument to readline (), and should not be assigned to directly. */ @@ -421,7 +481,8 @@ extern char *rl_prompt; extern char *rl_line_buffer; /* The location of point, and end. */ -extern int rl_point, rl_end; +extern int rl_point; +extern int rl_end; /* The mark, or saved cursor position. */ extern int rl_mark; @@ -438,29 +499,44 @@ extern int rl_pending_input; or directly from an application. */ extern int rl_dispatching; +/* Non-zero if the user typed a numeric argument before executing the + current function. */ +extern int rl_explicit_arg; + +/* The current value of the numeric argument specified by the user. */ +extern int rl_numeric_arg; + +/* The address of the last command function Readline executed. */ +extern rl_command_func_t *rl_last_func; + /* The name of the terminal to use. */ -extern char *rl_terminal_name; +extern const char *rl_terminal_name; /* The input and output streams. */ -extern FILE *rl_instream, *rl_outstream; +extern FILE *rl_instream; +extern FILE *rl_outstream; /* If non-zero, then this is the address of a function to call just before readline_internal () prints the first prompt. */ -extern Function *rl_startup_hook; +extern rl_hook_func_t *rl_startup_hook; /* If non-zero, this is the address of a function to call just before readline_internal_setup () returns and readline_internal starts reading input characters. */ -extern Function *rl_pre_input_hook; +extern rl_hook_func_t *rl_pre_input_hook; /* The address of a function to call periodically while Readline is awaiting character input, or NULL, for no event handling. */ -extern Function *rl_event_hook; +extern rl_hook_func_t *rl_event_hook; + +/* The address of the function to call to fetch a character from the current + Readline input stream */ +extern rl_getc_func_t *rl_getc_function; -extern Function *rl_getc_function; -extern VFunction *rl_redisplay_function; -extern VFunction *rl_prep_term_function; -extern VFunction *rl_deprep_term_function; +extern rl_voidfunc_t *rl_redisplay_function; + +extern rl_vintfunc_t *rl_prep_term_function; +extern rl_voidfunc_t *rl_deprep_term_function; /* Dispatch variables. */ extern Keymap rl_executing_keymap; @@ -481,6 +557,9 @@ extern int rl_already_prompted; up to a character bound to accept-line. */ extern int rl_num_chars_to_read; +/* The text of a currently-executing keyboard macro. */ +extern char *rl_executing_macro; + /* Variables to control readline signal handling. */ /* If non-zero, readline will install its own signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */ @@ -495,9 +574,9 @@ extern int rl_catch_sigwinch; /* Completion variables. */ /* Pointer to the generator function for completion_matches (). - NULL means to use filename_entry_function (), the default filename - completer. */ -extern Function *rl_completion_entry_function; + NULL means to use rl_filename_completion_function (), the default + filename completer. */ +extern rl_compentry_func_t *rl_completion_entry_function; /* If rl_ignore_some_completions_function is non-NULL it is the address of a function to call after all of the possible matches have been @@ -505,7 +584,7 @@ extern Function *rl_completion_entry_function; The function is called with one argument; a NULL terminated array of (char *). If your function removes any of the elements, they must be free()'ed. */ -extern Function *rl_ignore_some_completions_function; +extern rl_compignore_func_t *rl_ignore_some_completions_function; /* Pointer to alternative function to create matches. Function is called with TEXT, START, and END. @@ -514,39 +593,50 @@ extern Function *rl_ignore_some_completions_function; If this function exists and returns NULL then call the value of rl_completion_entry_function to try to match, otherwise use the array of strings returned. */ -extern CPPFunction *rl_attempted_completion_function; +extern rl_completion_func_t *rl_attempted_completion_function; /* The basic list of characters that signal a break between words for the completer routine. The initial contents of this variable is what breaks words in the shell, i.e. "n\"\\'`@$>". */ -extern char *rl_basic_word_break_characters; +extern const char *rl_basic_word_break_characters; /* The list of characters that signal a break between words for rl_complete_internal. The default list is the contents of rl_basic_word_break_characters. */ -extern char *rl_completer_word_break_characters; +extern const char *rl_completer_word_break_characters; /* List of characters which can be used to quote a substring of the line. Completion occurs on the entire substring, and within the substring rl_completer_word_break_characters are treated as any other character, unless they also appear within this list. */ -extern char *rl_completer_quote_characters; +extern const char *rl_completer_quote_characters; /* List of quote characters which cause a word break. */ -extern char *rl_basic_quote_characters; +extern const char *rl_basic_quote_characters; /* List of characters that need to be quoted in filenames by the completer. */ -extern char *rl_filename_quote_characters; +extern const char *rl_filename_quote_characters; /* List of characters that are word break characters, but should be left in TEXT when it is passed to the completion function. The shell uses this to help determine what kind of completing to do. */ -extern char *rl_special_prefixes; +extern const char *rl_special_prefixes; /* If non-zero, then this is the address of a function to call when completing on a directory name. The function is called with - the address of a string (the current directory name) as an arg. */ -extern Function *rl_directory_completion_hook; + the address of a string (the current directory name) as an arg. It + changes what is displayed when the possible completions are printed + or inserted. */ +extern rl_icppfunc_t *rl_directory_completion_hook; + +/* If non-zero, this is the address of a function to call when completing + a directory name. This function takes the address of the directory name + to be modified as an argument. Unlike rl_directory_completion_hook, it + only modifies the directory name used in opendir(2), not what is displayed + when the possible completions are printed or inserted. It is called + before rl_directory_completion_hook. I'm not happy with how this works + yet, so it's undocumented. */ +extern rl_icppfunc_t *rl_directory_rewrite_hook; /* Backwards compatibility with previous versions of readline. */ #define rl_symbolic_link_hook rl_directory_completion_hook @@ -558,7 +648,7 @@ extern Function *rl_directory_completion_hook; where MATCHES is the array of strings that matched, NUM_MATCHES is the number of strings in that array, and MAX_LENGTH is the length of the longest string in that array. */ -extern VFunction *rl_completion_display_matches_hook; +extern rl_compdisp_func_t *rl_completion_display_matches_hook; /* Non-zero means that the results of the matches are to be treated as filenames. This is ALWAYS zero on entry, and can only be changed @@ -576,17 +666,17 @@ extern int rl_filename_quoting_desired; Called with the text to quote, the type of match found (single or multiple) and a pointer to the quoting character to be used, which the function can reset if desired. */ -extern CPFunction *rl_filename_quoting_function; +extern rl_quote_func_t *rl_filename_quoting_function; /* Function to call to remove quoting characters from a filename. Called before completion is attempted, so the embedded quotes do not interfere with matching names in the file system. */ -extern CPFunction *rl_filename_dequoting_function; +extern rl_dequote_func_t *rl_filename_dequoting_function; /* Function to call to decide whether or not a word break character is quoted. If a character is quoted, it does not break words for the completer. */ -extern Function *rl_char_is_quoted_p; +extern rl_linebuf_func_t *rl_char_is_quoted_p; /* Non-zero means to suppress normal filename completion after the user-specified completion function has been called. */ @@ -601,18 +691,33 @@ extern int rl_completion_type; default is a space. Nothing is added if this is '\0'. */ extern int rl_completion_append_character; +/* If set to non-zero by an application completion function, + rl_completion_append_character will not be appended. */ +extern int rl_completion_suppress_append; + /* Up to this many items will be displayed in response to a possible-completions call. After that, we ask the user if she is sure she wants to see them all. The default value is 100. */ extern int rl_completion_query_items; +/* If non-zero, a slash will be appended to completed filenames that are + symbolic links to directory names, subject to the value of the + mark-directories variable (which is user-settable). This exists so + that application completion functions can override the user's preference + (set via the mark-symlinked-directories variable) if appropriate. + It's set to the value of _rl_complete_mark_symlink_dirs in + rl_complete_internal before any application-specific completion + function is called, so without that function doing anything, the user's + preferences are honored. */ +extern int rl_completion_mark_symlink_dirs; + /* If non-zero, then disallow duplicates in the matches. */ extern int rl_ignore_completion_duplicates; /* If this is non-zero, completion is (temporarily) inhibited, and the completion character will be inserted as any other. */ extern int rl_inhibit_completion; - + /* Definitions available for use by readline clients. */ #define RL_PROMPT_START_IGNORE '\001' #define RL_PROMPT_END_IGNORE '\002' @@ -623,6 +728,70 @@ extern int rl_inhibit_completion; #define SINGLE_MATCH 1 #define MULT_MATCH 2 +/* Possible state values for rl_readline_state */ +#define RL_STATE_NONE 0x00000 /* no state; before first call */ + +#define RL_STATE_INITIALIZING 0x00001 /* initializing */ +#define RL_STATE_INITIALIZED 0x00002 /* initialization done */ +#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */ +#define RL_STATE_READCMD 0x00008 /* reading a command key */ +#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */ +#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */ +#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */ +#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */ +#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */ +#define RL_STATE_SEARCH 0x00200 /* doing a history search */ +#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */ +#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */ +#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */ +#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */ +#define RL_STATE_COMPLETING 0x04000 /* doing completion */ +#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */ +#define RL_STATE_UNDOING 0x10000 /* doing an undo */ +#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */ + +#define RL_STATE_DONE 0x80000 /* done; accepted line */ + +#define RL_SETSTATE(x) (rl_readline_state |= (x)) +#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) +#define RL_ISSTATE(x) (rl_readline_state & (x)) + +struct readline_state { + /* line state */ + int point; + int end; + int mark; + char *buffer; + int buflen; + UNDO_LIST *ul; + char *prompt; + + /* global state */ + int rlstate; + int done; + Keymap kmap; + + /* input state */ + rl_command_func_t *lastfunc; + int insmode; + int edmode; + int kseqlen; + FILE *inf; + FILE *outf; + int pendingin; + char *macro; + + /* signal state */ + int catchsigs; + int catchsigwinch; + + /* reserved for future expansion, so the struct size doesn't change */ + char reserved[64]; +}; + +extern int rl_save_state PARAMS((struct readline_state *)); +extern int rl_restore_state PARAMS((struct readline_state *)); + #ifdef __cplusplus } #endif diff --git a/gnu/lib/libreadline/rldefs.h b/gnu/lib/libreadline/rldefs.h index 9841a960ce5..93eb773f2ee 100644 --- a/gnu/lib/libreadline/rldefs.h +++ b/gnu/lib/libreadline/rldefs.h @@ -30,6 +30,8 @@ # include "config.h" #endif +#include "rlstdc.h" + #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING) # define TERMIOS_TTY_DRIVER #else @@ -71,7 +73,14 @@ extern char *strchr (), *strrchr (); #define _rl_stricmp strcasecmp #define _rl_strnicmp strncasecmp #else -extern int _rl_stricmp (), _rl_strnicmp (); +extern int _rl_stricmp PARAMS((char *, char *)); +extern int _rl_strnicmp PARAMS((char *, char *, int)); +#endif + +#if defined (HAVE_STRPBRK) +# define _rl_strpbrk(a,b) strpbrk((a),(b)) +#else +extern char *_rl_strpbrk PARAMS((const char *, const char *)); #endif #if !defined (emacs_mode) @@ -80,6 +89,13 @@ extern int _rl_stricmp (), _rl_strnicmp (); # define emacs_mode 1 #endif +#if !defined (RL_IM_INSERT) +# define RL_IM_INSERT 1 +# define RL_IM_OVERWRITE 0 +# +# define RL_IM_DEFAULT RL_IM_INSERT +#endif + /* If you cast map[key].function to type (Keymap) on a Cray, the compiler takes the value of map[key].function and divides it by 4 to convert between pointer types (pointers @@ -87,17 +103,16 @@ extern int _rl_stricmp (), _rl_strnicmp (); This is not what is wanted. */ #if defined (CRAY) # define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function) -# define KEYMAP_TO_FUNCTION(data) (Function *)((int)(data)) +# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data)) #else # define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function) -# define KEYMAP_TO_FUNCTION(data) (Function *)(data) +# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data) #endif -extern char *xmalloc (); #if !defined (savestring) #include <stdio.h> static char * -xstrdup(char *s) +xstrdup(const char *s) { char * cp; cp = strdup(s); @@ -125,9 +140,10 @@ xstrdup(char *s) /* Possible values for the found_quote flags word used by the completion functions. It says what kind of (shell-like) quoting we found anywhere in the line. */ -#define RL_QF_SINGLE_QUOTE 0x1 -#define RL_QF_DOUBLE_QUOTE 0x2 -#define RL_QF_BACKSLASH 0x4 +#define RL_QF_SINGLE_QUOTE 0x01 +#define RL_QF_DOUBLE_QUOTE 0x02 +#define RL_QF_BACKSLASH 0x04 +#define RL_QF_OTHER_QUOTE 0x08 /* Default readline line buffer length. */ #define DEFAULT_BUFFER_SIZE 256 @@ -142,6 +158,10 @@ xstrdup(char *s) # define FREE(x) if (x) free (x) #endif +#if !defined (SWAP) +# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0) +#endif + /* CONFIGURATION SECTION */ #include "rlconf.h" diff --git a/gnu/lib/libreadline/rltty.c b/gnu/lib/libreadline/rltty.c index bacd2fbfd0b..755efebaadf 100644 --- a/gnu/lib/libreadline/rltty.c +++ b/gnu/lib/libreadline/rltty.c @@ -49,8 +49,13 @@ extern int errno; #endif /* !errno */ -VFunction *rl_prep_term_function = rl_prep_terminal; -VFunction *rl_deprep_term_function = rl_deprep_terminal; +rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal; +rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal; + +static void block_sigint PARAMS((void)); +static void release_sigint PARAMS((void)); + +static void set_winsize PARAMS((int)); /* **************************************************************** */ /* */ @@ -173,6 +178,14 @@ struct bsdtty { static TIOTYPE otio; +static void save_tty_chars PARAMS((TIOTYPE *)); +static int _get_tty_settings PARAMS((int, TIOTYPE *)); +static int get_tty_settings PARAMS((int, TIOTYPE *)); +static int _set_tty_settings PARAMS((int, TIOTYPE *)); +static int set_tty_settings PARAMS((int, TIOTYPE *)); + +static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *)); + static void save_tty_chars (tiop) TIOTYPE *tiop; @@ -218,22 +231,23 @@ get_tty_settings (tty, tiop) tiop->flags = tiop->lflag = 0; - ioctl (tty, TIOCGETP, &(tiop->sgttyb)); + if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0) + return -1; tiop->flags |= SGTTY_SET; #if defined (TIOCLGET) - ioctl (tty, TIOCLGET, &(tiop->lflag)); - tiop->flags |= LFLAG_SET; + if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0) + tiop->flags |= LFLAG_SET; #endif #if defined (TIOCGETC) - ioctl (tty, TIOCGETC, &(tiop->tchars)); - tiop->flags |= TCHARS_SET; + if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0) + tiop->flags |= TCHARS_SET; #endif #if defined (TIOCGLTC) - ioctl (tty, TIOCGLTC, &(tiop->ltchars)); - tiop->flags |= LTCHARS_SET; + if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0) + tiop->flags |= LTCHARS_SET; #endif return 0; @@ -279,23 +293,23 @@ set_tty_settings (tty, tiop) } static void -prepare_terminal_settings (meta_flag, otio, tiop) +prepare_terminal_settings (meta_flag, oldtio, tiop) int meta_flag; - TIOTYPE otio, *tiop; + TIOTYPE oldtio, *tiop; { - readline_echoing_p = (otio.sgttyb.sg_flags & ECHO); + readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO); /* Copy the original settings to the structure we're going to use for our settings. */ - tiop->sgttyb = otio.sgttyb; - tiop->lflag = otio.lflag; + tiop->sgttyb = oldtio.sgttyb; + tiop->lflag = oldtio.lflag; #if defined (TIOCGETC) - tiop->tchars = otio.tchars; + tiop->tchars = oldtio.tchars; #endif #if defined (TIOCGLTC) - tiop->ltchars = otio.ltchars; + tiop->ltchars = oldtio.ltchars; #endif - tiop->flags = otio.flags; + tiop->flags = oldtio.flags; /* First, the basic settings to put us into character-at-a-time, no-echo input mode. */ @@ -308,8 +322,8 @@ prepare_terminal_settings (meta_flag, otio, tiop) #if !defined (ANYP) # define ANYP (EVENP | ODDP) #endif - if (((otio.sgttyb.sg_flags & ANYP) == ANYP) || - ((otio.sgttyb.sg_flags & ANYP) == 0)) + if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) || + ((oldtio.sgttyb.sg_flags & ANYP) == 0)) { tiop->sgttyb.sg_flags |= ANYP; @@ -328,13 +342,13 @@ prepare_terminal_settings (meta_flag, otio, tiop) tiop->tchars.t_startc = -1; /* C-q */ /* If there is an XON character, bind it to restart the output. */ - if (otio.tchars.t_startc != -1) - rl_bind_key (otio.tchars.t_startc, rl_restart_output); + if (oldtio.tchars.t_startc != -1) + rl_bind_key (oldtio.tchars.t_startc, rl_restart_output); # endif /* USE_XON_XOFF */ /* If there is an EOF char, bind _rl_eof_char to it. */ - if (otio.tchars.t_eofc != -1) - _rl_eof_char = otio.tchars.t_eofc; + if (oldtio.tchars.t_eofc != -1) + _rl_eof_char = oldtio.tchars.t_eofc; # if defined (NO_KILL_INTR) /* Get rid of terminal-generated SIGQUIT and SIGINT. */ @@ -373,11 +387,19 @@ prepare_terminal_settings (meta_flag, otio, tiop) # define TIOTYPE struct termio # define DRAIN_OUTPUT(fd) # define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop)) -# define SETATTR(tty, tiop) (ioctl (tty, TCSETA, tiop)) +# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop)) #endif /* !TERMIOS_TTY_DRIVER */ static TIOTYPE otio; +static void save_tty_chars PARAMS((TIOTYPE *)); +static int _get_tty_settings PARAMS((int, TIOTYPE *)); +static int get_tty_settings PARAMS((int, TIOTYPE *)); +static int _set_tty_settings PARAMS((int, TIOTYPE *)); +static int set_tty_settings PARAMS((int, TIOTYPE *)); + +static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *)); + #if defined (FLUSHO) # define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO) #else @@ -545,16 +567,16 @@ set_tty_settings (tty, tiop) } static void -prepare_terminal_settings (meta_flag, otio, tiop) +prepare_terminal_settings (meta_flag, oldtio, tiop) int meta_flag; - TIOTYPE otio, *tiop; + TIOTYPE oldtio, *tiop; { - readline_echoing_p = (otio.c_lflag & ECHO); + readline_echoing_p = (oldtio.c_lflag & ECHO); tiop->c_lflag &= ~(ICANON | ECHO); - if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE) - _rl_eof_char = otio.c_cc[VEOF]; + if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE) + _rl_eof_char = oldtio.c_cc[VEOF]; #if defined (USE_XON_XOFF) #if defined (IXANY) @@ -585,7 +607,7 @@ prepare_terminal_settings (meta_flag, otio, tiop) if (OUTPUT_BEING_FLUSHED (tiop)) { tiop->c_lflag &= ~FLUSHO; - otio.c_lflag &= ~FLUSHO; + oldtio.c_lflag &= ~FLUSHO; } #endif @@ -645,6 +667,7 @@ rl_prep_terminal (meta_flag) fflush (rl_outstream); terminal_prepped = 1; + RL_SETSTATE(RL_STATE_TERMPREPPED); release_sigint (); } @@ -675,6 +698,7 @@ rl_deprep_terminal () } terminal_prepped = 0; + RL_UNSETSTATE(RL_STATE_TERMPREPPED); release_sigint (); } @@ -751,6 +775,9 @@ rl_stop_output (count, key) /* Default Key Bindings */ /* */ /* **************************************************************** */ + +/* Set the system's default editing characters to their readline equivalents + in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */ void rltty_set_default_bindings (kmap) Keymap kmap; @@ -765,8 +792,8 @@ rltty_set_default_bindings (kmap) { \ int ic; \ ic = sc; \ - if (ic != -1 && kmap[ic].type == ISFUNC) \ - kmap[ic].function = func; \ + if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \ + kmap[(unsigned char)ic].function = func; \ } \ while (0) @@ -815,6 +842,15 @@ rltty_set_default_bindings (kmap) #endif /* !NEW_TTY_DRIVER */ } +/* New public way to set the system default editing chars to their readline + equivalents. */ +void +rl_tty_set_default_bindings (kmap) + Keymap kmap; +{ + rltty_set_default_bindings (kmap); +} + #if defined (HANDLE_SIGNALS) #if defined (NEW_TTY_DRIVER) @@ -846,6 +882,7 @@ _rl_disable_tty_signals () nosigstty = sigstty; nosigstty.c_lflag &= ~ISIG; + nosigstty.c_iflag &= ~IXON; if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0) return (_set_tty_settings (fileno (rl_instream), &sigstty)); @@ -857,10 +894,17 @@ _rl_disable_tty_signals () int _rl_restore_tty_signals () { + int r; + if (tty_sigs_disabled == 0) return 0; - return (_set_tty_settings (fileno (rl_instream), &sigstty)); + r = _set_tty_settings (fileno (rl_instream), &sigstty); + + if (r == 0) + tty_sigs_disabled = 0; + + return r; } #endif /* !NEW_TTY_DRIVER */ diff --git a/gnu/lib/libreadline/savestring.c b/gnu/lib/libreadline/savestring.c index c2189470b79..7eb2dccc9d7 100644 --- a/gnu/lib/libreadline/savestring.c +++ b/gnu/lib/libreadline/savestring.c @@ -20,14 +20,17 @@ have a copy of the license, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ +#include <config.h> #include <stdio.h> -#include <string.h> +#ifdef HAVE_STRING_H +# include <string.h> +#endif /* Backwards compatibility, now that savestring has been removed from all `public' readline header files. */ - char * -savestring(char *s) +savestring (s) + const char *s; { char * cp; cp = strdup(s); @@ -37,4 +40,3 @@ savestring(char *s) } return(cp); } - diff --git a/gnu/lib/libreadline/search.c b/gnu/lib/libreadline/search.c index 8a6d42b12a3..7e0d60b5eb4 100644 --- a/gnu/lib/libreadline/search.c +++ b/gnu/lib/libreadline/search.c @@ -40,6 +40,8 @@ #endif #include "rldefs.h" +#include "rlmbutil.h" + #include "readline.h" #include "history.h" @@ -51,10 +53,10 @@ #endif #define abs(x) (((x) >= 0) ? (x) : -(x)) -extern HIST_ENTRY *saved_line_for_history; +extern HIST_ENTRY *_rl_saved_line_for_history; /* Functions imported from the rest of the library. */ -extern int _rl_free_history_entry __P((HIST_ENTRY *)); +extern int _rl_free_history_entry PARAMS((HIST_ENTRY *)); static char *noninc_search_string = (char *) NULL; static int noninc_history_pos; @@ -66,6 +68,13 @@ static int rl_history_search_pos; static char *history_search_string; static int history_string_size; +static void make_history_line_current PARAMS((HIST_ENTRY *)); +static int noninc_search_from_pos PARAMS((char *, int, int)); +static void noninc_dosearch PARAMS((char *, int)); +static void noninc_search PARAMS((int, int)); +static int rl_history_search_internal PARAMS((int, int)); +static void rl_history_search_reinit PARAMS((void)); + /* Make the data from the history entry ENTRY be the contents of the current line. This doesn't do anything with rl_point; the caller must set it. */ @@ -73,19 +82,12 @@ static void make_history_line_current (entry) HIST_ENTRY *entry; { - int line_len; - - line_len = strlen (entry->line); - if (line_len >= rl_line_buffer_len) - rl_extend_line_buffer (line_len); - strlcpy (rl_line_buffer, entry->line, rl_line_buffer_len); - + rl_replace_line (entry->line, 0); rl_undo_list = (UNDO_LIST *)entry->data; - rl_end = line_len; - if (saved_line_for_history) - _rl_free_history_entry (saved_line_for_history); - saved_line_for_history = (HIST_ENTRY *)NULL; + if (_rl_saved_line_for_history) + _rl_free_history_entry (_rl_saved_line_for_history); + _rl_saved_line_for_history = (HIST_ENTRY *)NULL; } /* Search the history list for STRING starting at absolute history position @@ -100,13 +102,19 @@ noninc_search_from_pos (string, pos, dir) { int ret, old; + if (pos < 0) + return -1; + old = where_history (); - history_set_pos (pos); + if (history_set_pos (pos) == 0) + return -1; + RL_SETSTATE(RL_STATE_SEARCH); if (*string == '^') ret = history_search_prefix (string + 1, dir); else ret = history_search (string, dir); + RL_UNSETSTATE(RL_STATE_SEARCH); if (ret != -1) ret = where_history (); @@ -128,7 +136,7 @@ noninc_dosearch (string, dir) if (string == 0 || *string == '\0' || noninc_history_pos < 0) { - ding (); + rl_ding (); return; } @@ -136,10 +144,10 @@ noninc_dosearch (string, dir) if (pos == -1) { /* Search failed, current history position unchanged. */ - maybe_unsave_line (); + rl_maybe_unsave_line (); rl_clear_message (); rl_point = 0; - ding (); + rl_ding (); return; } @@ -156,6 +164,8 @@ noninc_dosearch (string, dir) make_history_line_current (entry); rl_point = 0; + rl_mark = rl_end; + rl_clear_message (); } @@ -169,11 +179,15 @@ noninc_search (dir, pchar) int dir; int pchar; { - int saved_point, c; + int saved_point, saved_mark, c; char *p; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; +#endif - maybe_save_line (); + rl_maybe_save_line (); saved_point = rl_point; + saved_mark = rl_mark; /* Use the line buffer to read the search string. */ rl_line_buffer[0] = 0; @@ -183,23 +197,37 @@ noninc_search (dir, pchar) rl_message (p, 0, 0); free (p); -#define SEARCH_RETURN rl_restore_prompt (); return +#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return + RL_SETSTATE(RL_STATE_NSEARCH); /* Read the search string. */ - while (c = rl_read_key ()) + while (1) { + RL_SETSTATE(RL_STATE_MOREINPUT); + c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = _rl_read_mbstring (c, mb, MB_LEN_MAX); +#endif + + if (c == 0) + break; + switch (c) { case CTRL('H'): case RUBOUT: if (rl_point == 0) { - maybe_unsave_line (); + rl_maybe_unsave_line (); rl_clear_message (); rl_point = saved_point; + rl_mark = saved_mark; SEARCH_RETURN; } - rl_rubout (1, c); + _rl_rubout_char (1, c); break; case CTRL('W'): @@ -218,20 +246,28 @@ noninc_search (dir, pchar) case CTRL('C'): case CTRL('G'): - maybe_unsave_line (); + rl_maybe_unsave_line (); rl_clear_message (); rl_point = saved_point; - ding (); + rl_mark = saved_mark; + rl_ding (); SEARCH_RETURN; default: - rl_insert (1, c); +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + rl_insert_text (mb); + else +#endif + _rl_insert_char (1, c); break; } (*rl_redisplay_function) (); } dosearch: + rl_mark = saved_mark; + /* If rl_point == 0, we want to re-use the previous search string and start from the saved history position. If there's no previous search string, punt. */ @@ -239,7 +275,7 @@ noninc_search (dir, pchar) { if (!noninc_search_string) { - ding (); + rl_ding (); SEARCH_RETURN; } } @@ -253,6 +289,7 @@ noninc_search (dir, pchar) rl_restore_prompt (); noninc_dosearch (noninc_search_string, dir); + RL_UNSETSTATE(RL_STATE_NSEARCH); } /* Search forward through the history list for a string. If the vi-mode @@ -283,7 +320,7 @@ rl_noninc_forward_search_again (count, key) { if (!noninc_search_string) { - ding (); + rl_ding (); return (-1); } noninc_dosearch (noninc_search_string, 1); @@ -298,7 +335,7 @@ rl_noninc_reverse_search_again (count, key) { if (!noninc_search_string) { - ding (); + rl_ding (); return (-1); } noninc_dosearch (noninc_search_string, -1); @@ -312,7 +349,7 @@ rl_history_search_internal (count, dir) HIST_ENTRY *temp; int ret, oldpos; - maybe_save_line (); + rl_maybe_save_line (); temp = (HIST_ENTRY *)NULL; /* Search COUNT times through the history for a line whose prefix @@ -341,8 +378,8 @@ rl_history_search_internal (count, dir) /* If we didn't find anything at all, return. */ if (temp == 0) { - maybe_unsave_line (); - ding (); + rl_maybe_unsave_line (); + rl_ding (); /* If you don't want the saved history line (last match) to show up in the line buffer after the search fails, change the #if 0 to #if 1 */ @@ -351,9 +388,11 @@ rl_history_search_internal (count, dir) { rl_point = rl_end = rl_history_search_len; rl_line_buffer[rl_end] = '\0'; + rl_mark = 0; } #else - rl_point = rl_history_search_len; /* maybe_unsave_line changes it */ + rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */ + rl_mark = rl_end; #endif return 1; } @@ -362,6 +401,8 @@ rl_history_search_internal (count, dir) make_history_line_current (temp); rl_point = rl_history_search_len; + rl_mark = rl_end; + return 0; } @@ -376,12 +417,13 @@ rl_history_search_reinit () if (rl_history_search_len >= history_string_size - 2) { history_string_size = rl_history_search_len + 2; - history_search_string = xrealloc (history_search_string, history_string_size); + history_search_string = (char *)xrealloc (history_search_string, history_string_size); } history_search_string[0] = '^'; strncpy (history_search_string + 1, rl_line_buffer, rl_point); history_search_string[rl_point + 1] = '\0'; } + _rl_free_saved_history_line (); } /* Search forward in the history for the string of characters diff --git a/gnu/lib/libreadline/shell.c b/gnu/lib/libreadline/shell.c index 6458b6a9820..1f20c2699ff 100644 --- a/gnu/lib/libreadline/shell.c +++ b/gnu/lib/libreadline/shell.c @@ -44,28 +44,49 @@ # include <strings.h> #endif /* !HAVE_STRING_H */ +#if defined (HAVE_LIMITS_H) +# include <limits.h> +#endif + #include <fcntl.h> #include <pwd.h> #include <stdio.h> +#include "rlstdc.h" #include "rlshell.h" #include "xmalloc.h" #if !defined (HAVE_GETPW_DECLS) -extern struct passwd *getpwuid (); +extern struct passwd *getpwuid PARAMS((uid_t)); #endif /* !HAVE_GETPW_DECLS */ #ifndef NULL # define NULL 0 #endif +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* Nonzero if the integer type T is signed. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + +/* Bound on length of the string representing an integer value of type T. + Subtract one for the sign bit if T is signed; + 302 / 1000 is log10 (2) rounded up; + add one for integer division truncation; + add one more for a minus sign if t is signed. */ +#define INT_STRLEN_BOUND(t) \ + ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \ + + 1 + TYPE_SIGNED (t)) + /* All of these functions are resolved from bash if we are linking readline as part of bash. */ /* Does shell-like quoting using single quotes. */ char * -single_quote (string) +sh_single_quote (string) char *string; { register int c; @@ -96,7 +117,7 @@ single_quote (string) /* Set the environment variables LINES and COLUMNS to lines and cols, respectively. */ void -set_lines_and_columns (lines, cols) +sh_set_lines_and_columns (lines, cols) int lines, cols; { char *b; @@ -121,14 +142,14 @@ set_lines_and_columns (lines, cols) } char * -get_env_value (varname) - char *varname; +sh_get_env_value (varname) + const char *varname; { return ((char *)getenv (varname)); } char * -get_home_dir () +sh_get_home_dir () { char *home_dir; struct passwd *entry; @@ -147,7 +168,7 @@ get_home_dir () #endif int -unset_nodelay_mode (fd) +sh_unset_nodelay_mode (fd) int fd; { int flags, bflags; diff --git a/gnu/lib/libreadline/shlib_version b/gnu/lib/libreadline/shlib_version index 1edea46de91..b52599a164f 100644 --- a/gnu/lib/libreadline/shlib_version +++ b/gnu/lib/libreadline/shlib_version @@ -1,2 +1,2 @@ -major=1 +major=2 minor=0 diff --git a/gnu/lib/libreadline/support/config.guess b/gnu/lib/libreadline/support/config.guess index b7471c332dd..401fa05c9f3 100644 --- a/gnu/lib/libreadline/support/config.guess +++ b/gnu/lib/libreadline/support/config.guess @@ -1,7 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. -# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002 Free Software Foundation, Inc. + +timestamp='2002-03-20' + # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -21,92 +24,113 @@ # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Written by Per Bothner <bothner@cygnus.com>. -# The master version of this file is at the FSF in /home/gd/gnu/lib. +# Originally written by Per Bothner <per@bothner.com>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you -# don't specify an explicit system type (host/target name). -# -# Only a few systems have been added to this list; please add others -# (but try to keep the structure clean). -# - -# Use $HOST_CC if defined. $CC may point to a cross-compiler -if test x"$CC_FOR_BUILD" = x; then - if test x"$HOST_CC" != x; then - CC_FOR_BUILD="$HOST_CC" - else - if test x"$CC" != x; then - CC_FOR_BUILD="$CC" - else - CC_FOR_BUILD=cc - fi - fi +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 fi + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 c99 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + # This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 8/24/94.) +# (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH -elif (test -f /usr/5bin/uname) >/dev/null 2>&1 ; then +elif (test -f /usr/5bin/uname) >/dev/null 2>&1 ; then # bash PATH=$PATH:/usr/5bin fi -UNAME=`(uname) 2>/dev/null` || UNAME=unknown +UNAME=`(uname) 2>/dev/null` || UNAME=unknown # bash UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -RELEASE=`expr "$UNAME_RELEASE" : '[^0-9]*\([0-9]*\)'` # 4 -case "$RELEASE" in -"") RELEASE=0 ;; -*) RELEASE=`expr "$RELEASE" + 0` ;; -esac -REL_LEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.\([0-9]*\)'` # 1 -REL_SUBLEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.[0-9]*.\([0-9]*\)'` # 2 - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 - -# Some versions of i386 SVR4.2 make `uname' equivalent to `uname -n', which -# is contrary to all other versions of uname -if [ -n "$UNAME" ] && [ "$UNAME_S" != "$UNAME" ] && [ "$UNAME_S" = UNIX_SV ]; then - UNAME=UNIX_SV -fi - # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - # Begin cases added for Bash - alpha:NetBSD:*:*) - echo alpha-dec-netbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OpenBSD:*:*) - echo alpha-dec-openbsd${UNAME_RELEASE} - exit 0 ;; - i?86:NetBSD:*:*) - echo ${UNAME_MACHINE}-pc-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - i?86:OpenBSD:*:*) - echo ${UNAME_MACHINE}-pc-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - sparc:NetBSD:*:*) - echo sparc-unknown-netbsd${UNAME_RELEASE} - exit 0 ;; - sparc:OpenBSD:*:*) - echo sparc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - vax:NetBSD:*:*) - echo vax-dec-netbsd${UNAME_RELEASE} - exit 0 ;; - vax:OpenBSD:*:*) - echo vax-dec-openbsd${UNAME_RELEASE} - exit 0 ;; + # NOTE -- begin cases added for bash (mostly legacy) -- NOTE mac68k:machten:*:*) echo mac68k-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -132,20 +156,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in mips:4.4BSD:*:*) echo mips-mips-bsd4.4 exit 0 ;; - MIServer-S:SMP_DC.OSx:*:dcosx) - echo mips-pyramid-sysv4 + MIS*:SMP_DC.OSx:*:dcosx) # not the same as below + echo pyramid-pyramid-sysv4 exit 0 ;; news*:NEWS*:*:*) echo mips-sony-newsos${UNAME_RELEASE} exit 0 ;; - i?86:NEXTSTEP:*:*) - echo i386-next-nextstep${RELEASE} - exit 0 ;; - *680?0:NEXTSTEP:*:*) - echo m68k-next-nextstep${RELEASE} - exit 0 ;; *370:AIX:*:*) - echo ibm370-ibm-aix + echo ibm370-ibm-aix${UNAME_RELEASE} exit 0 ;; ksr1:OSF*1:*:*) echo ksr1-ksr-osf1 @@ -159,16 +177,105 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *3b2*:*:*:*) echo we32k-att-sysv3 exit 0 ;; - *:QNX:*:42*) - echo i386-qssl-qnx`echo ${UNAME_VERSION}` - exit 0 ;; - Alpha*:Windows:NT:*:SP*) + Alpha*:Windows_NT:*:SP*) echo alpha-pc-opennt exit 0 ;; - *:Windows:NT:*:SP*) - echo intel-pc-opennt + *:Windows_NT:*:SP*) + echo i386-pc-opennt + exit 0 ;; + + # NOTE -- end legacy cases added for bash -- NOTE + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + luna88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + vax:OpenBSD:*:*) # bash + echo vax-dec-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; - # end cases added for Bash alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -178,92 +285,85 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <<EOF >$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text .globl main + .align 4 .ent main main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit .end main EOF + eval $set_cc_for_build $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then - ./$dummy - case "$?" in - 7) + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; - 15) + 1-0) UNAME_MACHINE="alphaev5" ;; - 14) + 1-1) UNAME_MACHINE="alphaev56" ;; - 10) + 1-101) UNAME_MACHINE="alphapca56" ;; - 16) + 2-303) UNAME_MACHINE="alphaev6" ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-cbm-sysv4 + echo m68k-unknown-sysv4 exit 0;; - amiga:NetBSD:*:*) - echo m68k-cbm-netbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-cbm-openbsd${UNAME_RELEASE} - exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} + *:OS/390:*:*) + echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; - arm32:NetBSD:*:*) - echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - exit 0 ;; - SR2?01:HI-UX/MPP:*:*) + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) @@ -274,12 +374,12 @@ EOF echo pyramid-pyramid-bsd fi exit 0 ;; - NILE:*:*:*:dcosx) + NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; @@ -305,7 +405,7 @@ EOF echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) @@ -319,29 +419,23 @@ EOF aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; - atari*:NetBSD:*:*) - echo m68k-atari-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor + # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; @@ -351,36 +445,9 @@ EOF *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; - sun3*:NetBSD:*:*) - echo m68k-sun-netbsd${UNAME_RELEASE} - exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:NetBSD:*:*) - echo m68k-apple-netbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:"Mac OS":*:*) - echo `uname -p`-apple-macos${UNAME_RELEASE} - exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; - macppc:NetBSD:*:*) - echo powerpc-apple-netbsd${UNAME_RELEASE} - exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; @@ -394,8 +461,10 @@ EOF echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { @@ -416,10 +485,13 @@ EOF EOF $CC_FOR_BUILD $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm $dummy.c $dummy && exit 0 + && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; @@ -433,17 +505,19 @@ EOF echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ - -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then echo m88k-dg-dgux${UNAME_RELEASE} - else + else echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi + fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -465,11 +539,20 @@ EOF ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i?86:AIX:*:*) + i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include <sys/systemcfg.h> @@ -481,7 +564,7 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then @@ -490,21 +573,17 @@ EOF echo rs6000-ibm-aix3.2 fi exit 0 ;; - *:AIX:*:4) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` - if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` - elif grep bos410 /usr/include/stdio.h >/dev/null 2>&1; then - IBM_REV=4.1 - elif grep bos411 /usr/include/stdio.h >/dev/null 2>&1; then - IBM_REV=4.1.1 else - IBM_REV=4.${UNAME_RELEASE} + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; @@ -514,7 +593,7 @@ EOF ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) @@ -530,11 +609,30 @@ EOF echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - sed 's/^ //' << EOF >$dummy.c + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE #include <stdlib.h> #include <unistd.h> @@ -565,13 +663,19 @@ EOF exit (0); } EOF - ($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - rm -f $dummy.c $dummy + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; esac - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; 3050*:HI-UX:*:*) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include <unistd.h> int @@ -597,7 +701,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; @@ -607,16 +711,16 @@ EOF 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; - *9??*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; - i?86:OSF1:*:*) + i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else @@ -626,9 +730,6 @@ EOF parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; @@ -647,289 +748,235 @@ EOF C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY*T3E:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} - exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; - F300:UNIX_System_V:*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - F301:UNIX_System_V:*:*) - echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - hp3[0-9][05]:NetBSD:*:*) - echo m68k-hp-netbsd${UNAME_RELEASE} + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; - i?86:BSD/386:*:* | i?86:BSD/OS:*:*) + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - if test -x /usr/bin/objformat; then - if test "elf" = "`/usr/bin/objformat`"; then - echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` - exit 0 - fi - fi - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-=(].*//'` + echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; - *:NetBSD:*:*) - echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin32 + echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:3*) + echo i386-pc-interix3 + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit 0 ;; + exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; - *:Linux:*:*) - # uname on the ARM produces all sorts of strangeness, and we need to - # filter it out. - case "$UNAME_MACHINE" in - armv*) UNAME_MACHINE=$UNAME_MACHINE ;; - arm* | sa110*) UNAME_MACHINE="arm" ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + rm -f $dummy.c + test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; esac - + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent + # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. - ld_help_string=`cd /; ld --help 2>&1` - ld_supported_emulations=`echo $ld_help_string \ - | sed -ne '/supported emulations:/!d + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g - s/.*supported emulations: *// + s/.*supported targets: *// s/ .*// p'` - case "$ld_supported_emulations" in - *ia64) echo "${UNAME_MACHINE}-unknown-linux" ; exit 0 ;; - i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; - i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; - sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; - elf32ppc | elf32ppclinux) - # Determine Lib Version - cat >$dummy.c <<EOF -#include <features.h> -#if defined(__GLIBC__) -extern char __libc_version[]; -extern char __libc_release[]; -#endif -main(argc, argv) - int argc; - char *argv[]; -{ -#if defined(__GLIBC__) - printf("%s %s\n", __libc_version, __libc_release); -#else - printf("unkown\n"); -#endif - return 0; -} -EOF - LIBC="" - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy | grep 1\.99 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.c $dummy - echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;; - esac - - if test "${UNAME_MACHINE}" = "alpha" ; then - sed 's/^ //' <<EOF >$dummy.s - .globl main - .ent main - main: - .frame \$30,0,\$26,0 - .prologue 0 - .long 0x47e03d80 # implver $0 - lda \$2,259 - .long 0x47e20c21 # amask $2,$1 - srl \$1,8,\$2 - sll \$2,2,\$2 - sll \$0,3,\$0 - addl \$1,\$0,\$0 - addl \$2,\$0,\$0 - ret \$31,(\$26),1 - .end main -EOF - LIBC="" - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - ./$dummy - case "$?" in - 7) - UNAME_MACHINE="alpha" - ;; - 15) - UNAME_MACHINE="alphaev5" - ;; - 14) - UNAME_MACHINE="alphaev56" - ;; - 10) - UNAME_MACHINE="alphapca56" - ;; - 16) - UNAME_MACHINE="alphaev6" - ;; - esac - - objdump --private-headers $dummy | \ - grep ld.so.1 > /dev/null - if test "$?" = 0 ; then - LIBC="libc1" - fi - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 - elif test "${UNAME_MACHINE}" = "mips" ; then - cat >$dummy.c <<EOF -#ifdef __cplusplus -int main (int argc, char *argv[]) { -#else -int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __MIPSEB__ - printf ("%s-unknown-linux-gnu\n", argv[1]); -#endif -#ifdef __MIPSEL__ - printf ("%sel-unknown-linux-gnu\n", argv[1]); -#endif - return 0; -} -EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - else - # Either a pre-BFD a.out linker (linux-gnuoldld) - # or one that does not give us useful --help. - # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. - # If ld does not provide *any* "supported emulations:" - # that means it is gnuoldld. - echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" - test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - - case "${UNAME_MACHINE}" in - i?86) - VENDOR=pc; - ;; - *) - VENDOR=unknown; - ;; - esac - # Determine whether the default compiler is a.out or elf - cat >$dummy.c <<EOF -#include <features.h> -#ifdef __cplusplus - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); -#endif - return 0; -} + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif EOF - ${CC-cc} $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - fi ;; -# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions -# are messed up and put the nodename in both sysname and nodename. - i?86:DYNIX/ptx:4*:*) + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + rm -f $dummy.c + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; -# added by chet for bash based on usenet posting from <hops@sco.com> and -# documentation on SCO's web site -- UnixWare 7 (SVR5) -# i?86:UnixWare:5*:*) -# echo ${UNAME_MACHINE}-pc-sysv5uw${UNAME_VERSION} -# exit 0 ;; - i?86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; - i?86:*:4.*:* | i?86:SYSTEM_V:4.*:* | i?86:UNIX_SV:4.*:*) + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; - i?86:*:5:7*) - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585 - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE} - exit 0 ;; - i?86:*:3.2:*) + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` echo ${UNAME_MACHINE}-pc-isc$UNAME_REL @@ -947,11 +994,15 @@ EOF echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; pc:*:*:*) - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp - exit 0 ;; + exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; @@ -971,7 +1022,7 @@ EOF exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -980,30 +1031,33 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - m68*:LynxOS:2.*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) - echo i386-pc-lynxos${UNAME_RELEASE} + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; - rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; - *:LynxOS:*:*) - echo ${UNAME_MACHINE}-unknown-lynxos${UNAME_RELEASE} + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; - RM*:SINIX-*:*:* | RM*:ReliantUNIX-*:*:*) + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) @@ -1014,10 +1068,10 @@ EOF echo ns32k-sni-sysv fi exit 0 ;; - PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm @@ -1026,27 +1080,31 @@ EOF *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; - news*:NEWS-OS:*:6*) + news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; - R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BeMac:BeOS:*:*) + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; - BePC:BeOS:*:*) + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) @@ -1061,11 +1119,78 @@ EOF *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 +eval $set_cc_for_build cat >$dummy.c <<EOF #ifdef _SEQUENT_ # include <sys/types.h> @@ -1091,11 +1216,7 @@ main () #endif #if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp9000) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); + printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) @@ -1156,129 +1277,35 @@ main () #endif #if defined (vax) -#if !defined (ultrix) - printf ("vax-dec-bsd\n"); exit (0); -#else - printf ("vax-dec-ultrix\n"); exit (0); -#endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - -/* Begin cases added for Bash */ -#if defined (tahoe) - printf ("tahoe-cci-bsd\n"); exit (0); -#endif - -#if defined (nec_ews) -# if defined (SYSTYPE_SYSV) - printf ("ews4800-nec-sysv4\n"); exit 0; +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif # else - printf ("ews4800-nec-bsd\n"); exit (0); + printf ("vax-dec-bsd\n"); exit (0); # endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif #endif -#if defined (sony) -# if defined (SYSTYPE_SYSV) - printf ("mips-sony-sysv4\n"); exit 0; -# else - printf ("mips-sony-bsd\n"); exit (0); -# endif -#endif - -#if defined (ardent) - printf ("titan-ardent-bsd\n"); exit (0); -#endif - -#if defined (stardent) - printf ("stardent-stardent-sysv\n"); exit (0); -#endif - -#if defined (ibm032) - printf ("ibmrt-ibm-bsd4.3\n"); exit (0); -#endif - -#if defined (sequent) && defined (i386) - printf ("i386-sequent-bsd\n"); exit (0); -#endif - -#if defined (qnx) && defined (i386) - printf ("i386-pc-qnx\n"); exit (0); -#endif - -#if defined (gould) - printf ("gould-gould-bsd\n"); exit (0); -#endif - -#if defined (unixpc) - printf ("unixpc-att-sysv\n"); exit (0); -#endif - -#if defined (att386) - printf ("i386-att-sysv3\n"); exit (0); -#endif - -#if defined (__m88k) && defined (__UMAXV__) - printf ("m88k-encore-sysv3\n"); exit (0); -#endif - -#if defined (drs6000) - printf ("drs6000-icl-sysv4.2\n"); exit (0); -#endif - -#if defined (clipper) - printf ("clipper-orion-bsd\n"); exit (0); -#endif - -#if defined (is68k) - printf ("m68k-isi-bsd\n"); exit (0); -#endif - -#if defined (luna88k) - printf ("luna88k-omron-bsd\n"); exit (0); -#endif - -#if defined (butterfly) && defined (BFLY1) - printf ("butterfly-bbn-mach\n"); exit (0); -#endif - -#if defined (tower32) - printf ("tower32-ncr-sysv4\n"); exit (0); -#endif - -#if defined (MagicStation) - printf ("magicstation-unknown-bsd\n"); exit (0); -#endif - -#if defined (scs) - printf ("symmetric-scs-bsd4.2\n"); exit (0); -#endif - -#if defined (tandem) - printf ("tandem-tandem-sysv\n"); exit (0); -#endif - -#if defined (cadmus) - printf ("cadmus-pcs-sysv\n"); exit (0); -#endif - -#if defined (masscomp) - printf ("masscomp-masscomp-sysv3\n"); exit (0); -#endif - -#if defined (hbullx20) - printf ("hbullx20-bull-sysv3\n"); exit (0); +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); #endif -/* End cases added for Bash */ - exit (1); } EOF -${CC-cc} $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. @@ -1311,21 +1338,59 @@ then esac fi -# Begin cases added for Bash +# NOTE -- Begin fallback cases added for bash -- NOTE case "$UNAME" in uts) echo uts-amdahl-sysv${UNAME_RELEASE}; exit 0 ;; esac -if [ -d /usr/amiga ]; then - echo m68k-cbm-sysv${UNAME_RELEASE}; exit 0; -fi - if [ -f /bin/fxc.info ]; then echo fxc-alliant-concentrix exit 0 fi -# end cases added for Bash +# NOTE -- End fallback cases added for bash -- NOTE -#echo '(Unable to guess system type)' 1>&2 +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + ftp://ftp.gnu.org/pub/gnu/config/ + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/gnu/lib/libreadline/terminal.c b/gnu/lib/libreadline/terminal.c index 71964b9a165..6970856adb0 100644 --- a/gnu/lib/libreadline/terminal.c +++ b/gnu/lib/libreadline/terminal.c @@ -64,6 +64,10 @@ #include "rlprivate.h" #include "rlshell.h" +#include "xmalloc.h" + +#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) +#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) /* **************************************************************** */ /* */ @@ -76,9 +80,6 @@ static char *term_string_buffer = (char *)NULL; static int tcap_initialized; -/* Non-zero means this terminal can't really do anything. */ -static int dumb_term; - #if !defined (__linux__) # if defined (__EMX__) || defined (NEED_EXTERN_PC) extern @@ -87,27 +88,36 @@ char PC, *BC, *UP; #endif /* __linux__ */ /* Some strings to control terminal actions. These are output by tputs (). */ -char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace; -char *term_pc; +char *_rl_term_clreol; +char *_rl_term_clrpag; +char *_rl_term_cr; +char *_rl_term_backspace; +char *_rl_term_goto; +char *_rl_term_pc; /* Non-zero if we determine that the terminal can do character insertion. */ -int terminal_can_insert = 0; +int _rl_terminal_can_insert = 0; /* How to insert characters. */ -char *term_im, *term_ei, *term_ic, *term_ip, *term_IC; +char *_rl_term_im; +char *_rl_term_ei; +char *_rl_term_ic; +char *_rl_term_ip; +char *_rl_term_IC; /* How to delete characters. */ -char *term_dc, *term_DC; +char *_rl_term_dc; +char *_rl_term_DC; #if defined (HACK_TERMCAP_MOTION) -char *term_forward_char; +char *_rl_term_forward_char; #endif /* HACK_TERMCAP_MOTION */ /* How to go up a line. */ -char *term_up; +char *_rl_term_up; -/* A visible bell, if the terminal can be made to flash the screen. */ -static char *visible_bell; +/* A visible bell; char if the terminal can be made to flash the screen. */ +static char *_rl_visible_bell; /* Non-zero means the terminal can auto-wrap lines. */ int _rl_term_autowrap; @@ -116,20 +126,36 @@ int _rl_term_autowrap; static int term_has_meta; /* The sequences to write to turn on and off the meta key, if this - terminal has one. */ -static char *term_mm, *term_mo; + terminal has one. */ +static char *_rl_term_mm; +static char *_rl_term_mo; /* The key sequences output by the arrow keys, if this terminal has any. */ -static char *term_ku, *term_kd, *term_kr, *term_kl; +static char *_rl_term_ku; +static char *_rl_term_kd; +static char *_rl_term_kr; +static char *_rl_term_kl; /* How to initialize and reset the arrow keys, if this terminal has any. */ -static char *term_ks, *term_ke; +static char *_rl_term_ks; +static char *_rl_term_ke; /* The key sequences sent by the Home and End keys, if any. */ -static char *term_kh, *term_kH; +static char *_rl_term_kh; +static char *_rl_term_kH; +static char *_rl_term_at7; /* @7 */ + +/* Insert key */ +static char *_rl_term_kI; + +/* Cursor control */ +static char *_rl_term_vs; /* very visible */ +static char *_rl_term_ve; /* normal */ + +static void bind_termcap_arrow_keys PARAMS((Keymap)); /* Variables that hold the screen dimensions, used by the display code. */ -int screenwidth, screenheight, screenchars; +int _rl_screenwidth, _rl_screenheight, _rl_screenchars; /* Non-zero means the user wants to enable the keypad. */ int _rl_enable_keypad; @@ -169,84 +195,107 @@ _rl_get_screen_size (tty, ignore_env) #if defined (TIOCGWINSZ) if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) { - screenwidth = (int) window_size.ws_col; - screenheight = (int) window_size.ws_row; + _rl_screenwidth = (int) window_size.ws_col; + _rl_screenheight = (int) window_size.ws_row; } #endif /* TIOCGWINSZ */ #if defined (__EMX__) - _emx_get_screensize (&screenwidth, &screenheight); + _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight); #endif /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV is unset. */ - if (screenwidth <= 0) + if (_rl_screenwidth <= 0) { - if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")) && *ss != '\0') - screenwidth = atoi (ss); + if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")) && *ss != '\0') + _rl_screenwidth = atoi (ss); #if !defined (__DJGPP__) - if (screenwidth <= 0 && term_string_buffer) - screenwidth = tgetnum ("co"); + if (_rl_screenwidth <= 0 && term_string_buffer) + _rl_screenwidth = tgetnum ("co"); #endif } /* Environment variable LINES overrides setting of "li" if IGNORE_ENV is unset. */ - if (screenheight <= 0) + if (_rl_screenheight <= 0) { - if (ignore_env == 0 && (ss = get_env_value ("LINES")) && *ss != '\0') - screenheight = atoi (ss); + if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")) && *ss != '\0') + _rl_screenheight = atoi (ss); #if !defined (__DJGPP__) - if (screenheight <= 0 && term_string_buffer) - screenheight = tgetnum ("li"); + if (_rl_screenheight <= 0 && term_string_buffer) + _rl_screenheight = tgetnum ("li"); #endif } /* If all else fails, default to 80x24 terminal. */ - if (screenwidth <= 1) - screenwidth = 80; + if (_rl_screenwidth <= 1) + _rl_screenwidth = 80; - if (screenheight <= 0) - screenheight = 24; + if (_rl_screenheight <= 0) + _rl_screenheight = 24; /* If we're being compiled as part of bash, set the environment variables $LINES and $COLUMNS to new values. Otherwise, just do a pair of putenv () or setenv () calls. */ - set_lines_and_columns (screenheight, screenwidth); + sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth); if (_rl_term_autowrap == 0) - screenwidth--; + _rl_screenwidth--; - screenchars = screenwidth * screenheight; + _rl_screenchars = _rl_screenwidth * _rl_screenheight; } void _rl_set_screen_size (rows, cols) int rows, cols; { - screenheight = rows; - screenwidth = cols; + if (rows == 0 || cols == 0) + return; + + _rl_screenheight = rows; + _rl_screenwidth = cols; if (_rl_term_autowrap == 0) - screenwidth--; + _rl_screenwidth--; - screenchars = screenwidth * screenheight; + _rl_screenchars = _rl_screenwidth * _rl_screenheight; } void +rl_set_screen_size (rows, cols) + int rows, cols; +{ + _rl_set_screen_size (rows, cols); +} + +void +rl_get_screen_size (rows, cols) + int *rows, *cols; +{ + if (rows) + *rows = _rl_screenheight; + if (cols) + *cols = _rl_screenwidth; +} + +void rl_resize_terminal () { if (readline_echoing_p) { _rl_get_screen_size (fileno (rl_instream), 1); - _rl_redisplay_after_sigwinch (); + if (CUSTOM_REDISPLAY_FUNC ()) + rl_forced_update_display (); + else + _rl_redisplay_after_sigwinch (); } } struct _tc_string { - char *tc_var; + const char *tc_var; char **tc_value; }; @@ -254,32 +303,36 @@ struct _tc_string { search algorithm to something smarter. */ static struct _tc_string tc_strings[] = { - { "DC", &term_DC }, - { "IC", &term_IC }, - { "ce", &term_clreol }, - { "cl", &term_clrpag }, - { "cr", &term_cr }, - { "dc", &term_dc }, - { "ei", &term_ei }, - { "ic", &term_ic }, - { "im", &term_im }, - { "kd", &term_kd }, - { "kh", &term_kh }, /* home */ - { "kH", &term_kH }, /* end */ - { "kl", &term_kl }, - { "kr", &term_kr }, - { "ku", &term_ku }, - { "ks", &term_ks }, - { "ke", &term_ke }, - { "le", &term_backspace }, - { "mm", &term_mm }, - { "mo", &term_mo }, + { "@7", &_rl_term_at7 }, + { "DC", &_rl_term_DC }, + { "IC", &_rl_term_IC }, + { "ce", &_rl_term_clreol }, + { "cl", &_rl_term_clrpag }, + { "cr", &_rl_term_cr }, + { "dc", &_rl_term_dc }, + { "ei", &_rl_term_ei }, + { "ic", &_rl_term_ic }, + { "im", &_rl_term_im }, + { "kH", &_rl_term_kH }, /* home down ?? */ + { "kI", &_rl_term_kI }, /* insert */ + { "kd", &_rl_term_kd }, + { "ke", &_rl_term_ke }, /* end keypad mode */ + { "kh", &_rl_term_kh }, /* home */ + { "kl", &_rl_term_kl }, + { "kr", &_rl_term_kr }, + { "ks", &_rl_term_ks }, /* start keypad mode */ + { "ku", &_rl_term_ku }, + { "le", &_rl_term_backspace }, + { "mm", &_rl_term_mm }, + { "mo", &_rl_term_mo }, #if defined (HACK_TERMCAP_MOTION) - { "nd", &term_forward_char }, + { "nd", &_rl_term_forward_char }, #endif - { "pc", &term_pc }, - { "up", &term_up }, - { "vb", &visible_bell }, + { "pc", &_rl_term_pc }, + { "up", &_rl_term_up }, + { "vb", &_rl_visible_bell }, + { "vs", &_rl_term_vs }, + { "ve", &_rl_term_ve }, }; #define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string)) @@ -294,26 +347,27 @@ get_term_capabilities (bp) register int i; for (i = 0; i < NUM_TC_STRINGS; i++) +# ifdef __LCC__ + *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp); +# else *(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp); +# endif #endif tcap_initialized = 1; } -#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) -#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) - int _rl_init_terminal_io (terminal_name) - char *terminal_name; + const char *terminal_name; { - char *term, *buffer; + const char *term; + char *buffer; int tty, tgetent_ret; - Keymap xkeymap; - term = terminal_name ? terminal_name : get_env_value ("TERM"); - term_clrpag = term_cr = term_clreol = (char *)NULL; + term = terminal_name ? terminal_name : sh_get_env_value ("TERM"); + _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL; tty = rl_instream ? fileno (rl_instream) : 0; - screenwidth = screenheight = 0; + _rl_screenwidth = _rl_screenheight = 0; if (term == 0 || *term == '\0') term = "dumb"; @@ -328,10 +382,10 @@ _rl_init_terminal_io (terminal_name) else { if (term_string_buffer == 0) - term_string_buffer = xmalloc(2032); + term_string_buffer = (char *)xmalloc(2032); if (term_buffer == 0) - term_buffer = xmalloc(4080); + term_buffer = (char *)xmalloc(4080); buffer = term_string_buffer; @@ -344,41 +398,43 @@ _rl_init_terminal_io (terminal_name) FREE (term_buffer); buffer = term_buffer = term_string_buffer = (char *)NULL; - dumb_term = 1; _rl_term_autowrap = 0; /* used by _rl_get_screen_size */ #if defined (__EMX__) - _emx_get_screensize (&screenwidth, &screenheight); - screenwidth--; + _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight); + _rl_screenwidth--; #else /* !__EMX__ */ _rl_get_screen_size (tty, 0); #endif /* !__EMX__ */ /* Defaults. */ - if (screenwidth <= 0 || screenheight <= 0) + if (_rl_screenwidth <= 0 || _rl_screenheight <= 0) { - screenwidth = 79; - screenheight = 24; + _rl_screenwidth = 79; + _rl_screenheight = 24; } /* Everything below here is used by the redisplay code (tputs). */ - screenchars = screenwidth * screenheight; - term_cr = "\r"; - term_im = term_ei = term_ic = term_IC = (char *)NULL; - term_up = term_dc = term_DC = visible_bell = (char *)NULL; - term_ku = term_kd = term_kl = term_kr = (char *)NULL; - term_mm = term_mo = (char *)NULL; + _rl_screenchars = _rl_screenwidth * _rl_screenheight; + _rl_term_cr = "\r"; + _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL; + _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL; + _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL; + _rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL; + _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL; + _rl_term_mm = _rl_term_mo = (char *)NULL; + _rl_term_ve = _rl_term_vs = (char *)NULL; #if defined (HACK_TERMCAP_MOTION) term_forward_char = (char *)NULL; #endif - terminal_can_insert = term_has_meta = 0; + _rl_terminal_can_insert = term_has_meta = 0; /* Reasonable defaults for tgoto(). Readline currently only uses - tgoto if term_IC or term_DC is defined, but just in case we + tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we change that later... */ PC = '\0'; - BC = term_backspace = "\b"; - UP = term_up; + BC = _rl_term_backspace = "\b"; + UP = _rl_term_up; return 0; } @@ -387,12 +443,12 @@ _rl_init_terminal_io (terminal_name) /* Set up the variables that the termcap library expects the application to provide. */ - PC = term_pc ? *term_pc : 0; - BC = term_backspace; - UP = term_up; + PC = _rl_term_pc ? *_rl_term_pc : 0; + BC = _rl_term_backspace; + UP = _rl_term_up; - if (!term_cr) - term_cr = "\r"; + if (!_rl_term_cr) + _rl_term_cr = "\r"; _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn"); @@ -402,46 +458,51 @@ _rl_init_terminal_io (terminal_name) character insertion if *any one of* the capabilities `IC', `im', `ic' or `ip' is provided." But we can't do anything if only `ip' is provided, so... */ - terminal_can_insert = (term_IC || term_im || term_ic); + _rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic); /* Check to see if this terminal has a meta key and clear the capability variables if there is none. */ term_has_meta = (tgetflag ("km") || tgetflag ("MT")); if (!term_has_meta) - term_mm = term_mo = (char *)NULL; + _rl_term_mm = _rl_term_mo = (char *)NULL; /* Attempt to find and bind the arrow keys. Do not override already bound keys in an overzealous attempt, however. */ - xkeymap = _rl_keymap; - _rl_keymap = emacs_standard_keymap; - _rl_bind_if_unbound (term_ku, rl_get_previous_history); - _rl_bind_if_unbound (term_kd, rl_get_next_history); - _rl_bind_if_unbound (term_kr, rl_forward); - _rl_bind_if_unbound (term_kl, rl_backward); - - _rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */ - _rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */ + bind_termcap_arrow_keys (emacs_standard_keymap); #if defined (VI_MODE) - _rl_keymap = vi_movement_keymap; - _rl_bind_if_unbound (term_ku, rl_get_previous_history); - _rl_bind_if_unbound (term_kd, rl_get_next_history); - _rl_bind_if_unbound (term_kr, rl_forward); - _rl_bind_if_unbound (term_kl, rl_backward); - - _rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */ - _rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */ + bind_termcap_arrow_keys (vi_movement_keymap); + bind_termcap_arrow_keys (vi_insertion_keymap); #endif /* VI_MODE */ - _rl_keymap = xkeymap; - return 0; } +/* Bind the arrow key sequences from the termcap description in MAP. */ +static void +bind_termcap_arrow_keys (map) + Keymap map; +{ + Keymap xkeymap; + + xkeymap = _rl_keymap; + _rl_keymap = map; + + _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history); + _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history); + _rl_bind_if_unbound (_rl_term_kr, rl_forward); + _rl_bind_if_unbound (_rl_term_kl, rl_backward); + + _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */ + _rl_bind_if_unbound (_rl_term_at7, rl_end_of_line); /* End */ + + _rl_keymap = xkeymap; +} + char * rl_get_termcap (cap) - char *cap; + const char *cap; { register int i; @@ -459,7 +520,7 @@ rl_get_termcap (cap) has changed. */ int rl_reset_terminal (terminal_name) - char *terminal_name; + const char *terminal_name; { _rl_init_terminal_io (terminal_name); return 0; @@ -485,7 +546,7 @@ _rl_output_character_function (c) /* Write COUNT characters from STRING to the output stream. */ void _rl_output_some_chars (string, count) - char *string; + const char *string; int count; { fwrite (string, 1, count, _rl_out_stream); @@ -498,9 +559,9 @@ _rl_backspace (count) { register int i; - if (term_backspace) + if (_rl_term_backspace) for (i = 0; i < count; i++) - tputs (term_backspace, 1, _rl_output_character_function); + tputs (_rl_term_backspace, 1, _rl_output_character_function); else for (i = 0; i < count; i++) putc ('\b', _rl_out_stream); @@ -509,11 +570,11 @@ _rl_backspace (count) /* Move to the start of the next line. */ int -crlf () +rl_crlf () { #if defined (NEW_TTY_DRIVER) - if (term_cr) - tputs (term_cr, 1, _rl_output_character_function); + if (_rl_term_cr) + tputs (_rl_term_cr, 1, _rl_output_character_function); #endif /* NEW_TTY_DRIVER */ putc ('\n', _rl_out_stream); return 0; @@ -521,7 +582,7 @@ crlf () /* Ring the terminal bell. */ int -ding () +rl_ding () { if (readline_echoing_p) { @@ -531,9 +592,9 @@ ding () default: break; case VISIBLE_BELL: - if (visible_bell) + if (_rl_visible_bell) { - tputs (visible_bell, 1, _rl_output_character_function); + tputs (_rl_visible_bell, 1, _rl_output_character_function); break; } /* FALLTHROUGH */ @@ -557,8 +618,8 @@ void _rl_enable_meta_key () { #if !defined (__DJGPP__) - if (term_has_meta && term_mm) - tputs (term_mm, 1, _rl_output_character_function); + if (term_has_meta && _rl_term_mm) + tputs (_rl_term_mm, 1, _rl_output_character_function); #endif } @@ -567,9 +628,35 @@ _rl_control_keypad (on) int on; { #if !defined (__DJGPP__) - if (on && term_ks) - tputs (term_ks, 1, _rl_output_character_function); - else if (!on && term_ke) - tputs (term_ke, 1, _rl_output_character_function); + if (on && _rl_term_ks) + tputs (_rl_term_ks, 1, _rl_output_character_function); + else if (!on && _rl_term_ke) + tputs (_rl_term_ke, 1, _rl_output_character_function); #endif } + +/* **************************************************************** */ +/* */ +/* Controlling the Cursor */ +/* */ +/* **************************************************************** */ + +/* Set the cursor appropriately depending on IM, which is one of the + insert modes (insert or overwrite). Insert mode gets the normal + cursor. Overwrite mode gets a very visible cursor. Only does + anything if we have both capabilities. */ +void +_rl_set_cursor (im, force) + int im, force; +{ + if (_rl_term_ve && _rl_term_vs) + { + if (force || im != rl_insert_mode) + { + if (im == RL_IM_OVERWRITE) + tputs (_rl_term_vs, 1, _rl_output_character_function); + else + tputs (_rl_term_ve, 1, _rl_output_character_function); + } + } +} diff --git a/gnu/lib/libreadline/text.c b/gnu/lib/libreadline/text.c index 2a7b724f481..81b9da3dc2f 100644 --- a/gnu/lib/libreadline/text.c +++ b/gnu/lib/libreadline/text.c @@ -198,7 +198,7 @@ rl_replace_line (text, clear_undo) len = strlen (text); if (len >= rl_line_buffer_len) rl_extend_line_buffer (len); - strcpy (rl_line_buffer, text); + strlcpy (rl_line_buffer, text, len); rl_end = len; if (clear_undo) diff --git a/gnu/lib/libreadline/tilde.c b/gnu/lib/libreadline/tilde.c index e87a8f6f2b7..85eefb86772 100644 --- a/gnu/lib/libreadline/tilde.c +++ b/gnu/lib/libreadline/tilde.c @@ -48,24 +48,20 @@ #include "tilde.h" #if defined (TEST) || defined (STATIC_MALLOC) -static char *xmalloc (), *xrealloc (); +static void *xmalloc (), *xrealloc (); #else -# if defined __STDC__ -extern char *xmalloc (int); -extern char *xrealloc (void *, int); -# else -extern char *xmalloc (), *xrealloc (); -# endif /* !__STDC__ */ +# include "xmalloc.h" #endif /* TEST || STATIC_MALLOC */ #if !defined (HAVE_GETPW_DECLS) -extern struct passwd *getpwuid (), *getpwnam (); +extern struct passwd *getpwuid PARAMS((uid_t)); +extern struct passwd *getpwnam PARAMS((const char *)); #endif /* !HAVE_GETPW_DECLS */ #if !defined (savestring) #include <stdio.h> static char * -xstrdup(char *s) +xstrdup(const char *s) { char * cp; cp = strdup(s); @@ -89,49 +85,54 @@ xstrdup(char *s) /* If being compiled as part of bash, these will be satisfied from variables.o. If being compiled as part of readline, they will be satisfied from shell.o. */ -extern char *get_home_dir __P((void)); -extern char *get_env_value __P((char *)); +extern char *sh_get_home_dir PARAMS((void)); +extern char *sh_get_env_value PARAMS((const char *)); /* The default value of tilde_additional_prefixes. This is set to whitespace preceding a tilde so that simple programs which do not perform any word separation get desired behaviour. */ -static char *default_prefixes[] = - { " ~", "\t~", (char *)NULL }; +static const char *default_prefixes[] = + { " ~", "\t~", (const char *)NULL }; /* The default value of tilde_additional_suffixes. This is set to whitespace or newline so that simple programs which do not perform any word separation get desired behaviour. */ -static char *default_suffixes[] = - { " ", "\n", (char *)NULL }; +static const char *default_suffixes[] = + { " ", "\n", (const char *)NULL }; /* If non-null, this contains the address of a function that the application wants called before trying the standard tilde expansions. The function is called with the text sans tilde, and returns a malloc()'ed string which is the expansion, or a NULL pointer if the expansion fails. */ -CPFunction *tilde_expansion_preexpansion_hook = (CPFunction *)NULL; +tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL; /* If non-null, this contains the address of a function to call if the standard meaning for expanding a tilde fails. The function is called with the text (sans tilde, as in "foo"), and returns a malloc()'ed string which is the expansion, or a NULL pointer if there is no expansion. */ -CPFunction *tilde_expansion_failure_hook = (CPFunction *)NULL; +tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL; /* When non-null, this is a NULL terminated array of strings which are duplicates for a tilde prefix. Bash uses this to expand `=~' and `:~'. */ -char **tilde_additional_prefixes = default_prefixes; +char **tilde_additional_prefixes = (char **)default_prefixes; /* When non-null, this is a NULL terminated array of strings which match the end of a username, instead of just "/". Bash sets this to `:' and `=~'. */ -char **tilde_additional_suffixes = default_suffixes; +char **tilde_additional_suffixes = (char **)default_suffixes; + +static int tilde_find_prefix PARAMS((const char *, int *)); +static int tilde_find_suffix PARAMS((const char *)); +static char *isolate_tilde_prefix PARAMS((const char *, int *)); +static char *glue_prefix_and_suffix PARAMS((char *, const char *, int)); /* Find the start of a tilde expansion in STRING, and return the index of the tilde which starts the expansion. Place the length of the text which identified this tilde starter in LEN, excluding the tilde itself. */ static int tilde_find_prefix (string, len) - char *string; + const char *string; int *len; { register int i, j, string_len; @@ -166,7 +167,7 @@ tilde_find_prefix (string, len) the character which ends the tilde definition. */ static int tilde_find_suffix (string) - char *string; + const char *string; { register int i, j, string_len; register char **suffixes; @@ -195,16 +196,16 @@ tilde_find_suffix (string) /* Return a new string which is the result of tilde expanding STRING. */ char * tilde_expand (string) - char *string; + const char *string; { char *result; int result_size, result_index; result_index = result_size = 0; if (result = strchr (string, '~')) - result = xmalloc (result_size = (strlen (string) + 16)); + result = (char *)xmalloc (result_size = (strlen (string) + 16)); else - result = xmalloc (result_size = (strlen (string) + 1)); + result = (char *)xmalloc (result_size = (strlen (string) + 1)); /* Scan through STRING expanding tildes as we come to them. */ while (1) @@ -218,7 +219,7 @@ tilde_expand (string) /* Copy the skipped text into the result. */ if ((result_index + start + 1) > result_size) - result = xrealloc (result, 1 + (result_size += (start + 20))); + result = (char *)xrealloc (result, 1 + (result_size += (start + 20))); strncpy (result + result_index, string, start); result_index += start; @@ -235,7 +236,7 @@ tilde_expand (string) break; /* Expand the entire tilde word, and copy it into RESULT. */ - tilde_word = xmalloc (1 + end); + tilde_word = (char *)xmalloc (1 + end); strncpy (tilde_word, string, end); tilde_word[end] = '\0'; string += end; @@ -244,14 +245,14 @@ tilde_expand (string) free (tilde_word); len = strlen (expansion); -#ifdef __CYGWIN32__ +#ifdef __CYGWIN__ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when - $HOME for `user' is /. On cygwin, // denotes a network drive. */ + $HOME for `user' is /. On cygwin, // denotes a network drive. */ if (len > 1 || *expansion != '/' || *string != '/') #endif { if ((result_index + len + 1) > result_size) - result = xrealloc (result, 1 + (result_size += (len + 20))); + result = (char *)xrealloc (result, 1 + (result_size += (len + 20))); strlcpy (result + result_index, expansion, result_size - result_index); @@ -270,13 +271,13 @@ tilde_expand (string) the location it points to. */ static char * isolate_tilde_prefix (fname, lenp) - char *fname; + const char *fname; int *lenp; { char *ret; int i; - ret = xmalloc (strlen (fname)); + ret = (char *)xmalloc (strlen (fname)); #if defined (__MSDOS__) for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++) #else @@ -293,7 +294,8 @@ isolate_tilde_prefix (fname, lenp) SUFFIND. */ static char * glue_prefix_and_suffix (prefix, suffix, suffind) - char *prefix, *suffix; + char *prefix; + const char *suffix; int suffind; { char *ret; @@ -301,7 +303,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind) plen = (prefix && *prefix) ? strlen (prefix) : 0; slen = strlen (suffix + suffind); - ret = xmalloc (plen + slen + 1); + ret = (char *)xmalloc (plen + slen + 1); if (plen) strlcpy (ret, prefix, plen + slen + 1); strlcat (ret, suffix + suffind, plen + slen + 1); @@ -313,7 +315,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind) This always returns a newly-allocated string, never static storage. */ char * tilde_expand_word (filename) - char *filename; + const char *filename; { char *dirname, *expansion, *username; int user_len; @@ -331,12 +333,12 @@ tilde_expand_word (filename) if (filename[1] == '\0' || filename[1] == '/') { /* Prefix $HOME to the rest of the string. */ - expansion = get_env_value ("HOME"); + expansion = sh_get_env_value ("HOME"); /* If there is no HOME variable, look up the directory in the password database. */ if (expansion == 0 || *expansion == '\0') - expansion = get_home_dir (); + expansion = sh_get_home_dir (); return (glue_prefix_and_suffix (expansion, filename, 1)); } @@ -426,28 +428,28 @@ main (argc, argv) static void memory_error_and_abort (); -static char * +static void * xmalloc (bytes) - int bytes; + size_t bytes; { - char *temp = (char *)malloc (bytes); + void *temp = (char *)malloc (bytes); if (!temp) memory_error_and_abort (); return (temp); } -static char * +static void * xrealloc (pointer, bytes) - char *pointer; + void *pointer; int bytes; { - char *temp; + void *temp; if (!pointer) - temp = (char *)malloc (bytes); + temp = malloc (bytes); else - temp = (char *)realloc (pointer, bytes); + temp = realloc (pointer, bytes); if (!temp) memory_error_and_abort (); diff --git a/gnu/lib/libreadline/util.c b/gnu/lib/libreadline/util.c index e96a401dfd3..1557a652022 100644 --- a/gnu/lib/libreadline/util.c +++ b/gnu/lib/libreadline/util.c @@ -55,8 +55,6 @@ #include "rlprivate.h" #include "xmalloc.h" -#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0) - /* **************************************************************** */ /* */ /* Utility Functions */ @@ -67,10 +65,10 @@ in words, or 1 if it is. */ int _rl_allow_pathname_alphabetic_chars = 0; -static char *pathname_alphabetic_chars = "/-_=~.#$"; +static const char *pathname_alphabetic_chars = "/-_=~.#$"; int -alphabetic (c) +rl_alphabetic (c) int c; { if (ALPHABETIC (c)) @@ -84,16 +82,16 @@ alphabetic (c) int _rl_abort_internal () { - ding (); + rl_ding (); rl_clear_message (); _rl_init_argument (); - rl_pending_input = 0; + rl_clear_pending_input (); - _rl_defining_kbd_macro = 0; - while (_rl_executing_macro) + RL_UNSETSTATE (RL_STATE_MACRODEF); + while (rl_executing_macro) _rl_pop_executing_macro (); - rl_last_func = (Function *)NULL; + rl_last_func = (rl_command_func_t *)NULL; longjmp (readline_top_level, 1); return (0); } @@ -113,7 +111,7 @@ rl_tty_status (count, key) ioctl (1, TIOCSTAT, (char *)0); rl_refresh_line (count, key); #else - ding (); + rl_ding (); #endif return 0; } @@ -132,7 +130,7 @@ rl_copy_text (from, to) SWAP (from, to); length = to - from; - copy = xmalloc (1 + length); + copy = (char *)xmalloc (1 + length); strncpy (copy, rl_line_buffer + from, length); copy[length] = '\0'; return (copy); @@ -147,7 +145,7 @@ rl_extend_line_buffer (len) while (len >= rl_line_buffer_len) { rl_line_buffer_len += DEFAULT_BUFFER_SIZE; - rl_line_buffer = xrealloc (rl_line_buffer, rl_line_buffer_len); + rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len); } _rl_set_the_line (); @@ -193,7 +191,7 @@ rl_tilde_expand (ignore, key) if (rl_line_buffer[start] == '~') { len = end - start + 1; - temp = xmalloc (len + 1); + temp = (char *)xmalloc (len + 1); strncpy (temp, rl_line_buffer + start, len); temp[len] = '\0'; homedir = tilde_expand (temp); @@ -215,16 +213,51 @@ rl_tilde_expand (ignore, key) match in s1. The compare is case insensitive. */ char * _rl_strindex (s1, s2) - register char *s1, *s2; + register const char *s1, *s2; { register int i, l, len; for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++) if (_rl_strnicmp (s1 + i, s2, l) == 0) - return (s1 + i); + return ((char *) (s1 + i)); return ((char *)NULL); } +#ifndef HAVE_STRPBRK +/* Find the first occurrence in STRING1 of any character from STRING2. + Return a pointer to the character in STRING1. */ +char * +_rl_strpbrk (string1, string2) + const char *string1, *string2; +{ + register const char *scan; +#if defined (HANDLE_MULTIBYTE) + mbstate_t ps; + register int i, v; + + memset (&ps, 0, sizeof (mbstate_t)); +#endif + + for (; *string1; string1++) + { + for (scan = string2; *scan; scan++) + { + if (*string1 == *scan) + return ((char *)string1); + } +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + v = _rl_get_char_len (string1, &ps); + if (v > 1) + string += v - 1; /* -1 to account for auto-increment in loop */ + } +#endif + } + return ((char *)NULL); +} +#endif + #if !defined (HAVE_STRCASECMP) /* Compare at most COUNT characters from string1 to string2. Case doesn't matter. */ @@ -283,69 +316,23 @@ _rl_qsort_string_compare (s1, s2) #endif } -/* Function equivalents for the macros defined in chartypes.h. */ -#undef _rl_uppercase_p -int -_rl_uppercase_p (c) - int c; -{ - return (isupper (c)); -} - -#undef _rl_lowercase_p -int -_rl_lowercase_p (c) - int c; -{ - return (islower (c)); -} - -#undef _rl_pure_alphabetic -int -_rl_pure_alphabetic (c) - int c; -{ - return (isupper (c) || islower (c)); -} - -#undef _rl_digit_p -int -_rl_digit_p (c) - int c; -{ - return (isdigit (c)); -} +/* Function equivalents for the macros defined in chardefs.h. */ +#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); } -#undef _rl_to_lower -int -_rl_to_lower (c) - int c; -{ - return (isupper (c) ? tolower (c) : c); -} - -#undef _rl_to_upper -int -_rl_to_upper (c) - int c; -{ - return (islower (c) ? toupper (c) : c); -} - -#undef _rl_digit_value -int -_rl_digit_value (c) - int c; -{ - return (isdigit (c) ? c - '0' : c); -} +FUNCTION_FOR_MACRO (_rl_digit_p) +FUNCTION_FOR_MACRO (_rl_digit_value) +FUNCTION_FOR_MACRO (_rl_lowercase_p) +FUNCTION_FOR_MACRO (_rl_pure_alphabetic) +FUNCTION_FOR_MACRO (_rl_to_lower) +FUNCTION_FOR_MACRO (_rl_to_upper) +FUNCTION_FOR_MACRO (_rl_uppercase_p) /* Backwards compatibility, now that savestring has been removed from all `public' readline header files. */ #undef _rl_savestring char * _rl_savestring (s) - char *s; + const char *s; { char *cp; cp = strdup(s); diff --git a/gnu/lib/libreadline/xmalloc.c b/gnu/lib/libreadline/xmalloc.c index 4a8633c5b0f..8ee4a7f5056 100644 --- a/gnu/lib/libreadline/xmalloc.c +++ b/gnu/lib/libreadline/xmalloc.c @@ -43,26 +43,26 @@ /* Return a pointer to free()able block of memory large enough to hold BYTES number of bytes. If the memory cannot be allocated, print an error message and abort. */ -char * +PTR_T xmalloc (bytes) - int bytes; + size_t bytes; { - char *temp; + PTR_T temp; - temp = (char *)malloc (bytes); + temp = malloc (bytes); if (temp == 0) memory_error_and_abort ("xmalloc"); return (temp); } -char * +PTR_T xrealloc (pointer, bytes) PTR_T pointer; - int bytes; + size_t bytes; { - char *temp; + PTR_T temp; - temp = pointer ? (char *)realloc (pointer, bytes) : (char *)malloc (bytes); + temp = pointer ? realloc (pointer, bytes) : malloc (bytes); if (temp == 0) memory_error_and_abort ("xrealloc"); diff --git a/gnu/lib/libreadline/xmalloc.h b/gnu/lib/libreadline/xmalloc.h index 055125bce76..0b894e9f568 100644 --- a/gnu/lib/libreadline/xmalloc.h +++ b/gnu/lib/libreadline/xmalloc.h @@ -29,6 +29,8 @@ # include <readline/rlstdc.h> #endif +#include <stdio.h> + #ifndef PTR_T #ifdef __STDC__ @@ -39,9 +41,10 @@ #endif /* !PTR_T */ -extern char *xmalloc __P((int)); -extern char *xrealloc __P((void *, int)); -extern void xfree __P((void *)); +extern PTR_T xmalloc PARAMS((size_t)); +extern PTR_T xrealloc PARAMS((void *, size_t)); +extern void xfree PARAMS((void *)); + static void memory_error_and_abort (fname) char *fname; @@ -49,4 +52,5 @@ memory_error_and_abort (fname) fprintf (stderr, "%s: out of virtual memory\n", fname); exit (2); } + #endif /* _XMALLOC_H_ */ |