diff options
author | Jari Aalto <jari.aalto@cante.net> | 1997-06-05 14:59:13 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:50 +0000 |
commit | d166f048818e10cf3799aa24a174fb22835f1acc (patch) | |
tree | 1ca27f9243900f8b236d0cde6a3862002aea9e19 /lib/readline | |
parent | ccc6cda312fea9f0468ee65b8f368e9653e1380b (diff) | |
download | android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.gz android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.tar.bz2 android_external_bash-d166f048818e10cf3799aa24a174fb22835f1acc.zip |
Imported from ../bash-2.01.tar.gz.
Diffstat (limited to 'lib/readline')
36 files changed, 1190 insertions, 477 deletions
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in index c5ac183..90e3756 100644 --- a/lib/readline/Makefile.in +++ b/lib/readline/Makefile.in @@ -1,8 +1,8 @@ -## -*- text -*- #################################################### -# # -# Makefile for the GNU Readline and History Libraries. # -# # -#################################################################### +## -*- text -*- ############################################################# +# # +# Makefile for the Bash versions of the GNU Readline and History Libraries. # +# # +############################################################################# srcdir = @srcdir@ VPATH = .:@srcdir@ @@ -20,7 +20,11 @@ RM = rm -f CP = cp MV = mv -# See the file STANDALONE for the -D defines that readline understands +SHELL = /bin/sh + +# Programs to make tags files. +ETAGS = etags -tw +CTAGS = ctags -tw CFLAGS = @CFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@ @@ -28,13 +32,12 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ DEFS = @DEFS@ +LOCAL_DEFS = @LOCAL_DEFS@ INCLUDES = -I. -I$(BUILD_DIR) -I$(topdir) -I$(topdir)/lib -CCFLAGS = $(DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS) +CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS) -# Here is a rule for making .o files from .c files that doesn't force -# the type of the machine (like -sun3) into the flags. .c.o: $(CC) -c $(CCFLAGS) $< @@ -50,20 +53,20 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \ $(srcdir)/undo.c $(srcdir)/macro.c $(srcdir)/input.c \ $(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \ $(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \ - $(srcdir)/histfile.c $(srcdir)/nls.c \ - $(srcdir)/tilde.c \ + $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \ + $(srcdir)/shell.c $(srcdir)/tilde.c # The header files for this library. HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \ - posixstat.h tilde.h rlconf.h tcap.h + posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \ + ansi_stdlib.h tcap.h -HISTOBJ = history.o histexpand.o histfile.o histsearch.o -TILDEOBJ= tilde.o +HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o +TILDEOBJ = tilde.o OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \ rltty.o complete.o bind.o isearch.o display.o signals.o \ util.o kill.o undo.o macro.o input.o callback.o terminal.o \ - nls.o xmalloc.o \ - $(HISTOBJ) $(TILDEOBJ) + nls.o $(HISTOBJ) $(TILDEOBJ) xmalloc.o # The texinfo files which document this library. DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo @@ -84,12 +87,12 @@ INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h all: libreadline.a libhistory.a libreadline.a: $(OBJECTS) - $(RM) -f $@ + $(RM) $@ $(AR) cr $@ $(OBJECTS) -test -n "$(RANLIB)" && $(RANLIB) $@ libhistory.a: $(HISTOBJ) xmalloc.o - $(RM) -f $@ + $(RM) $@ $(AR) cr $@ $(HISTOBJ) xmalloc.o -test -n "$(RANLIB)" && $(RANLIB) $@ @@ -99,94 +102,113 @@ documentation: force force: -# The rule for 'includes' is written funny so that the if statement -# always returns TRUE unless there really was an error installing the -# include files. -install: installdirs libreadline.a - for file in $(INSTALLED_HEADERS) ; do \ - $(INSTALL_DATA) $(srcdir)/$$file $(includedir)/readline ; \ - done - -${MV} $(libdir)/libreadline.a $(libdir)/libreadline.old - ${INSTALL_DATA} libreadline.a $(libdir)/libreadline.a - -test -n "$(RANLIB)" && $(RANLIB) -t $(bindir)/libreadline.a - -installdirs: $(topdir)/support/mkdirs - $(SHELL) $(topdir)/support/mkdirs $(includedir) \ - $(includedir)/readline $(libdir) $(infodir) $(man3dir) +install: + @echo "This version of the readline library should not be installed." uninstall: - cd $(includedir)/readline && ${RM} -f ${INSTALLED_HEADERS} - cd $(libdir) && ${RM} -f libreadline.a libreadline.old - -tags: force - etags $(CSOURCES) $(HSOURCES) + @echo "This version of the readline library should not be installed." TAGS: force - ctags -x $(CSOURCES) $(HSOURCES) > $@ + $(ETAGS) $(CSOURCES) $(HSOURCES) -readline: readline.h rldefs.h chardefs.h -readline: $(OBJECTS) - $(CC) $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \ - $(LOCAL_INCLUDES) -DTEST -o readline readline.c vi_mode.o funmap.o \ - keymaps.o -ltermcap +tags: force + $(CTAGS) $(CSOURCES) $(HSOURCES) clean: force $(RM) $(OBJECTS) *.a -( cd doc && $(MAKE) $(MFLAGS) $@ ) -distclean realclean maintainer-clean: clean +mostlyclean: clean -( cd doc && $(MAKE) $(MFLAGS) $@ ) - $(RM) Makefile -mostlyclean: clean +distclean maintainer-clean: clean -( cd doc && $(MAKE) $(MFLAGS) $@ ) + $(RM) Makefile + $(RM) TAGS tags # Dependencies -readline.o: readline.c readline.h rldefs.h rlconf.h chardefs.h tcap.h -readline.o: keymaps.h history.h -vi_mode.o: rldefs.h rlconf.h readline.h history.h -funmap.o: funmap.c readline.h rlconf.h -keymaps.o: keymaps.c emacs_keymap.c vi_keymap.c keymaps.h chardefs.h rlconf.h -history.o: history.h histlib.h +bind.o: ansi_stdlib.h posixstat.h +bind.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +bind.o: readline.h keymaps.h chardefs.h tilde.h +bind.o: history.h +callback.o: rlconf.h +callback.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +callback.o: readline.h keymaps.h chardefs.h tilde.h +complete.o: ansi_stdlib.h posixdir.h posixstat.h +complete.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +complete.o: readline.h keymaps.h chardefs.h tilde.h +display.o: ansi_stdlib.h posixstat.h +display.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +display.o: tcap.h +display.o: readline.h keymaps.h chardefs.h tilde.h +display.o: history.h +funmap.o: readline.h keymaps.h chardefs.h tilde.h +funmap.o: rlconf.h ansi_stdlib.h +funmap.o: ${BUILD_DIR}/config.h +histexpand.o: ansi_stdlib.h histexpand.o: history.h histlib.h -histsearch.o: history.h histlib.h +histexpand.o: ${BUILD_DIR}/config.h +histfile.o: ansi_stdlib.h histfile.o: history.h histlib.h -isearch.o: readline.h history.h -search.o: readline.h history.h -display.o: readline.h history.h rldefs.h rlconf.h tcap.h -complete.o: readline.h rldefs.h rlconf.h posixdir.h posixstat.h -rltty.o: rldefs.h rlconf.h readline.h rltty.h -bind.o: rldefs.h rlconf.h readline.h history.h -signals.o: rldefs.h rlconf.h readline.h history.h -parens.o: readline.h -kill.o: rldefs.h rlconf.h readline.h history.h -macro.o: rldefs.h rlconf.h readline.h history.h -undo.o: rldefs.h rlconf.h readline.h history.h -input.o: rldefs.h rlconf.h readline.h history.h -callback.o: rlconf.h rldefs.h readline.h -terminal.o: rlconf.h rldefs.h readline.h tcap.h history.h - -bind.o: $(BUILD_DIR)/config.h -callback.o: $(BUILD_DIR)/config.h -complete.o: $(BUILD_DIR)/config.h -display.o: $(BUILD_DIR)/config.h -funmap.o: $(BUILD_DIR)/config.h -histexpand.o: $(BUILD_DIR)/config.h -histfile.o: $(BUILD_DIR)/config.h -history.o: $(BUILD_DIR)/config.h -histsearch.o: $(BUILD_DIR)/config.h -input.o: $(BUILD_DIR)/config.h -isearch.o: $(BUILD_DIR)/config.h -keymaps.o: $(BUILD_DIR)/config.h -kill.o: $(BUILD_DIR)/config.h -macro.o: $(BUILD_DIR)/config.h -parens.o: $(BUILD_DIR)/config.h -readline.o: $(BUILD_DIR)/config.h -rltty.o: $(BUILD_DIR)/config.h -search.o: $(BUILD_DIR)/config.h -signals.o: $(BUILD_DIR)/config.h -tilde.o: $(BUILD_DIR)/config.h -undo.o: $(BUILD_DIR)/config.h -util.o: $(BUILD_DIR)/config.h -vi_mode.o: $(BUILD_DIR)/config.h -xmalloc.o: $(BUILD_DIR)/config.h +histfile.o: ${BUILD_DIR}/config.h +history.o: ansi_stdlib.h +history.o: history.h histlib.h +history.o: ${BUILD_DIR}/config.h +histsearch.o: ansi_stdlib.h +histsearch.o: history.h histlib.h +histsearch.o: ${BUILD_DIR}/config.h +input.o: ansi_stdlib.h +input.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +input.o: readline.h keymaps.h chardefs.h tilde.h +isearch.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +isearch.o: readline.h keymaps.h chardefs.h tilde.h +isearch.o: ansi_stdlib.h history.h +keymaps.o: emacs_keymap.c vi_keymap.c +keymaps.o: keymaps.h chardefs.h rlconf.h ansi_stdlib.h +keymaps.o: readline.h keymaps.h chardefs.h tilde.h +keymaps.o: ${BUILD_DIR}/config.h +kill.o: ansi_stdlib.h +kill.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +kill.o: readline.h keymaps.h chardefs.h tilde.h +kill.o: history.h +macro.o: ansi_stdlib.h +macro.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +macro.o: readline.h keymaps.h chardefs.h tilde.h +macro.o: history.h +nls.o: ansi_stdlib.h +nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +parens.o: rlconf.h +parens.o: ${BUILD_DIR}/config.h +parens.o: readline.h keymaps.h chardefs.h tilde.h +readline.o: readline.h keymaps.h chardefs.h tilde.h +readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +readline.o: history.h +readline.o: posixstat.h ansi_stdlib.h posixjmp.h +rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +rltty.o: rltty.h +rltty.o: readline.h keymaps.h chardefs.h tilde.h +search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +search.o: readline.h keymaps.h chardefs.h tilde.h +search.o: ansi_stdlib.h history.h +signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +signals.o: readline.h keymaps.h chardefs.h tilde.h +signals.o: history.h +terminal.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +terminal.o: tcap.h +terminal.o: readline.h keymaps.h chardefs.h tilde.h +terminal.o: history.h +tilde.o: ansi_stdlib.h +tilde.o: ${BUILD_DIR}/config.h +tilde.o: tilde.h +undo.o: ansi_stdlib.h +undo.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +undo.o: readline.h keymaps.h chardefs.h tilde.h +undo.o: history.h +util.o: posixjmp.h ansi_stdlib.h +util.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +util.o: readline.h keymaps.h chardefs.h tilde.h +vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h +vi_mode.o: readline.h keymaps.h chardefs.h tilde.h +vi_mode.o: history.h ansi_stdlib.h +xmalloc.o: ${BUILD_DIR}/config.h +xmalloc.o: ansi_stdlib.h diff --git a/lib/readline/bind.c b/lib/readline/bind.c index bd899ca..24c8c48 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -89,11 +89,16 @@ extern Keymap _rl_keymap; extern char *possible_control_prefixes[], *possible_meta_prefixes[]; +/* Functions imported from funmap.c */ extern char **rl_funmap_names (); extern int rl_add_funmap_entry (); +/* Functions imported from util.c */ extern char *_rl_strindex (); +/* Functions imported from shell.c */ +extern char *get_env_value (); + /* Variables exported by this file. */ Keymap rl_binding_keymap; @@ -202,7 +207,7 @@ rl_set_key (keyseq, function, map) Function *function; Keymap map; { - return (rl_generic_bind (ISFUNC, keyseq, function, map)); + return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map)); } /* Bind the key sequence represented by the string KEYSEQ to @@ -381,7 +386,7 @@ rl_untranslate_keyseq (seq) kseq[i++] = '\\'; kseq[i++] = 'C'; kseq[i++] = '-'; - c = UNCTRL (c); + c = _rl_to_lower (UNCTRL (c)); } else if (c == RUBOUT) { @@ -394,7 +399,7 @@ rl_untranslate_keyseq (seq) if (c == ESC) { kseq[i++] = '\\'; - kseq[i++] = 'e'; + c = 'e'; } else if (c == '\\' || c == '"') { @@ -406,6 +411,53 @@ rl_untranslate_keyseq (seq) return kseq; } +static char * +_rl_untranslate_macro_value (seq) + char *seq; +{ + char *ret, *r, *s; + int c; + + r = ret = xmalloc (7 * strlen (seq) + 1); + for (s = seq; *s; s++) + { + c = *s; + if (META_CHAR (c)) + { + *r++ = '\\'; + *r++ = 'M'; + *r++ = '-'; + c = UNMETA (c); + } + else if (CTRL_CHAR (c) && c != ESC) + { + *r++ = '\\'; + *r++ = 'C'; + *r++ = '-'; + c = _rl_to_lower (UNCTRL (c)); + } + else if (c == RUBOUT) + { + *r++ = '\\'; + *r++ = 'C'; + *r++ = '-'; + c = '?'; + } + + if (c == ESC) + { + *r++ = '\\'; + c = 'e'; + } + else if (c == '\\' || c == '"') + *r++ = '\\'; + + *r++ = (unsigned char)c; + } + *r = '\0'; + return ret; +} + /* Return a pointer to the function that STRING represents. If STRING doesn't have a matching function, then a NULL pointer is returned. */ @@ -523,7 +575,7 @@ rl_read_init_file (filename) { filename = last_readline_init_file; if (filename == 0) - filename = getenv ("INPUTRC"); + filename = get_env_value ("INPUTRC"); if (filename == 0) filename = DEFAULT_INPUTRC; } @@ -990,14 +1042,14 @@ rl_parse_and_bind (string) /* Temporary. Handle old-style keyname with macro-binding. */ if (*funname == '\'' || *funname == '"') { - char seq[2]; + unsigned char useq[2]; int fl = strlen (funname); - seq[0] = key; seq[1] = '\0'; + useq[0] = key; useq[1] = '\0'; if (fl && funname[fl - 1] == *funname) funname[fl - 1] = '\0'; - rl_macro_bind (seq, &funname[1], _rl_keymap); + rl_macro_bind (useq, &funname[1], _rl_keymap); } #if defined (PREFIX_META_HACK) /* Ugly, but working hack to keep prefix-meta around. */ @@ -1528,6 +1580,8 @@ int rl_dump_functions (count, key) int count, key; { + if (rl_dispatching) + fprintf (rl_outstream, "\r\n"); rl_function_dumper (rl_explicit_arg); rl_on_new_line (); return (0); @@ -1549,7 +1603,11 @@ _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, @@ -1559,6 +1617,9 @@ _rl_macro_dumper_internal (print_readably, map, prefix) keyname, out ? out : ""); free (keyname); +#if 1 + free (out); +#endif break; case ISFUNC: break; @@ -1604,6 +1665,8 @@ int rl_dump_macros (count, key) int count, key; { + if (rl_dispatching) + fprintf (rl_outstream, "\r\n"); rl_macro_dumper (rl_explicit_arg); rl_on_new_line (); return (0); @@ -1674,6 +1737,8 @@ int rl_dump_variables (count, key) int count, key; { + if (rl_dispatching) + fprintf (rl_outstream, "\r\n"); rl_variable_dumper (rl_explicit_arg); rl_on_new_line (); return (0); diff --git a/lib/readline/callback.c b/lib/readline/callback.c index ad57f75..04c5bbd 100644 --- a/lib/readline/callback.c +++ b/lib/readline/callback.c @@ -39,6 +39,7 @@ extern void readline_internal_startup (); extern char *readline_internal_teardown (); extern int readline_internal_char (); +extern void _rl_init_line_state (); extern int _rl_meta_flag; extern char *rl_prompt; @@ -120,6 +121,10 @@ rl_callback_read_char () in_handler = 0; (*rl_linefunc) (line); + /* If the user did not clear out the line, do it for him. */ + if (rl_line_buffer[0]) + _rl_init_line_state (); + /* Redisplay the prompt if readline_handler_{install,remove} not called. */ if (in_handler == 0 && rl_linefunc) _rl_callback_newline (); diff --git a/lib/readline/complete.c b/lib/readline/complete.c index f9e27eb..b17c63e 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -25,7 +25,6 @@ # include <config.h> #endif -#include <stdio.h> #include <sys/types.h> #include <fcntl.h> #if defined (HAVE_SYS_FILE_H) @@ -42,6 +41,8 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ +#include <stdio.h> + #include <errno.h> #if !defined (errno) extern int errno; @@ -137,7 +138,7 @@ int rl_visible_stats = 0; static int completion_changed_buffer; /* Pointer to the generator function for completion_matches (). - NULL means to use filename_entry_function (), the default filename + NULL means to use filename_completion_function (), the default filename completer. */ Function *rl_completion_entry_function = (Function *)NULL; @@ -761,12 +762,13 @@ insert_text (text, start, end) } static char * -make_quoted_replacement (match, mtype, quote_char) +make_quoted_replacement (match, mtype, qc) char *match; - int mtype, quote_char; + int mtype; + char *qc; /* Pointer to quoting character, if any */ { int should_quote, do_replace; - char *replacement, qc; + char *replacement; /* If we are doing completion on quoted substrings, and any matches contain any of the completer_word_break_characters, then auto- @@ -784,10 +786,10 @@ make_quoted_replacement (match, mtype, quote_char) if (should_quote) #if defined (SHELL) - should_quote = should_quote && (!quote_char || quote_char == '"' || quote_char == '\''); -#else - should_quote = should_quote && !quote_char; -#endif + should_quote = should_quote && (!qc || !*qc || *qc == '"' || *qc == '\''); +#else /* !SHELL */ + should_quote = should_quote && (!qc || !*qc); +#endif /* !SHELL */ if (should_quote) { @@ -797,37 +799,37 @@ make_quoted_replacement (match, mtype, quote_char) should_quote = rl_strpbrk (match, rl_filename_quote_characters) != 0; do_replace = should_quote ? mtype : NO_MATCH; - if (do_replace != NO_MATCH) - { - /* Quote the replacement, since we found an embedded - word break character in a potential match. */ - if (rl_filename_quoting_function) - { - qc = quote_char; /* must pass a (char *) to quoting function */ - replacement = (*rl_filename_quoting_function) - (match, do_replace, &qc); - quote_char = qc; - } - } + /* Quote the replacement, since we found an embedded + word break character in a potential match. */ + if (do_replace != NO_MATCH && rl_filename_quoting_function) + replacement = (*rl_filename_quoting_function) (match, do_replace, qc); } return (replacement); } static void -insert_match (match, start, mtype, quote_char) +insert_match (match, start, mtype, qc) char *match; - int start, mtype, quote_char; + int start, mtype; + char *qc; { char *replacement; + char oqc; - replacement = make_quoted_replacement (match, mtype, quote_char); + oqc = qc ? *qc : '\0'; + replacement = make_quoted_replacement (match, mtype, qc); /* Now insert the match. */ if (replacement) { /* Don't double an opening quote character. */ - if (quote_char && start && rl_line_buffer[start - 1] == quote_char && - replacement[0] == quote_char) + if (qc && *qc && start && rl_line_buffer[start - 1] == *qc && + replacement[0] == *qc) + start--; + /* If make_quoted_replacement changed the quoting character, remove + the opening quote and insert the (fully-quoted) replacement. */ + else if (qc && (*qc != oqc) && start && rl_line_buffer[start - 1] == oqc && + replacement[0] != oqc) start--; insert_text (replacement, start, rl_point - 1); if (replacement != match) @@ -882,9 +884,10 @@ append_to_match (text, delimiter, quote_char) } static void -insert_all_matches (matches, point, quote_char) +insert_all_matches (matches, point, qc) char **matches; - int point, quote_char; + int point; + char *qc; { int i; char *rp; @@ -892,7 +895,7 @@ insert_all_matches (matches, point, quote_char) rl_begin_undo_group (); /* remove any opening quote character; make_quoted_replacement will add it back. */ - if (quote_char && point && rl_line_buffer[point - 1] == quote_char) + if (qc && *qc && point && rl_line_buffer[point - 1] == *qc) point--; rl_delete_text (point, rl_point); rl_point = point; @@ -901,7 +904,7 @@ insert_all_matches (matches, point, quote_char) { for (i = 1; matches[i]; i++) { - rp = make_quoted_replacement (matches[i], SINGLE_MATCH, quote_char); + rp = make_quoted_replacement (matches[i], SINGLE_MATCH, qc); rl_insert_text (rp); rl_insert_text (" "); if (rp != matches[i]) @@ -910,7 +913,7 @@ insert_all_matches (matches, point, quote_char) } else { - rp = make_quoted_replacement (matches[0], SINGLE_MATCH, quote_char); + rp = make_quoted_replacement (matches[0], SINGLE_MATCH, qc); rl_insert_text (rp); rl_insert_text (" "); if (rp != matches[0]) @@ -964,12 +967,12 @@ rl_complete_internal (what_to_do) text = rl_copy_text (start, end); matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char); - free (text); if (matches == 0) { ding (); FREE (saved_line_buffer); + free (text); return 0; } @@ -998,6 +1001,7 @@ rl_complete_internal (what_to_do) FREE (matches); ding (); FREE (saved_line_buffer); + FREE (text); return 0; } else @@ -1013,6 +1017,7 @@ rl_complete_internal (what_to_do) } } } + free (text); switch (what_to_do) { @@ -1020,7 +1025,7 @@ rl_complete_internal (what_to_do) case '!': /* Insert the first match with proper quoting. */ if (*matches[0]) - insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, quote_char); + insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); /* If there are more matches, ring the bell to indicate. If we are in vi mode, Posix.2 says to not ring the bell. @@ -1046,7 +1051,7 @@ rl_complete_internal (what_to_do) break; case '*': - insert_all_matches (matches, start, quote_char); + insert_all_matches (matches, start, "e_char); break; case '?': @@ -1102,10 +1107,14 @@ stat_char (filename) character = 0; if (S_ISDIR (finfo.st_mode)) character = '/'; +#if defined (S_ISCHR) else if (S_ISCHR (finfo.st_mode)) character = '%'; +#endif /* S_ISCHR */ +#if defined (S_ISBLK) else if (S_ISBLK (finfo.st_mode)) character = '#'; +#endif /* S_ISBLK */ #if defined (S_ISLNK) else if (S_ISLNK (finfo.st_mode)) character = '@'; @@ -1321,7 +1330,7 @@ filename_completion_function (text, state) int state; char *text; { - static DIR *directory; + static DIR *directory = (DIR *)NULL; static char *filename = (char *)NULL; static char *dirname = (char *)NULL; static char *users_dirname = (char *)NULL; @@ -1333,6 +1342,13 @@ filename_completion_function (text, state) /* If we don't have any state, then do some initialization. */ if (state == 0) { + /* If we were interrupted before closing the directory or reading + all of its contents, close it. */ + if (directory) + { + closedir (directory); + directory = (DIR *)NULL; + } FREE (dirname); FREE (filename); FREE (users_dirname); diff --git a/lib/readline/display.c b/lib/readline/display.c index c0dff1f..c283f9a 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -25,20 +25,26 @@ # include <config.h> #endif -#include <stdio.h> #include <sys/types.h> #if defined (HAVE_UNISTD_H) # include <unistd.h> #endif /* HAVE_UNISTD_H */ +#include "posixstat.h" + #if defined (HAVE_STDLIB_H) # include <stdlib.h> #else # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ -#include "posixstat.h" +#include <stdio.h> + +#if defined (__GO32__) +# include <go32.h> +# include <pc.h> +#endif /* __GO32__ */ /* System-specific feature definitions and include files. */ #include "rldefs.h" @@ -69,7 +75,8 @@ extern void _rl_output_some_chars (); extern int _rl_output_character_function (); extern int _rl_backspace (); -extern char *term_clreol, *term_im, *term_ic, *term_ei, *term_DC; +extern char *term_clreol, *term_clrpag; +extern char *term_im, *term_ic, *term_ei, *term_DC; extern char *term_up, *term_dc, *term_cr, *term_IC; extern int screenheight, screenwidth, screenchars; extern int terminal_can_insert, _rl_term_autowrap; @@ -78,8 +85,9 @@ extern int terminal_can_insert, _rl_term_autowrap; by this file. */ void _rl_move_cursor_relative (), _rl_output_some_chars (); void _rl_move_vert (); +void _rl_clear_to_eol (), _rl_clear_screen (); -static void update_line (), clear_to_eol (), space_to_eol (); +static void update_line (), space_to_eol (); static void delete_chars (), insert_some_chars (); static void cr (); @@ -302,7 +310,7 @@ rl_redisplay () register int in, out, c, linenum, cursor_linenum; register char *line; int c_pos, inv_botlin, lb_botlin, lb_linenum; - int newlines, lpos; + int newlines, lpos, temp; char *prompt_this_line; if (!readline_echoing_p) @@ -405,8 +413,19 @@ rl_redisplay () /* inv_lbreaks[i] is where line i starts in the buffer. */ inv_lbreaks[newlines = 0] = 0; + lpos = out - wrap_offset; + + /* XXX - what if lpos is already >= screenwidth before we start drawing the + contents of the command line? */ + while (lpos >= screenwidth) + { + temp = ((newlines + 1) * screenwidth) - ((newlines == 0) ? wrap_offset : 0); + inv_lbreaks[++newlines] = temp; + lpos -= screenwidth; + } - for (in = 0, lpos = out - wrap_offset; in < rl_end; in++) + lb_linenum = 0; + for (in = 0; in < rl_end; in++) { c = (unsigned char)rl_line_buffer[in]; @@ -432,8 +451,6 @@ rl_redisplay () if (lpos + 4 >= screenwidth) { - register int temp; - temp = screenwidth - lpos; inv_lbreaks[++newlines] = out + temp; lpos = 4 - temp; @@ -557,7 +574,7 @@ rl_redisplay () { nleft = screenwidth + wrap_offset - _rl_last_c_pos; if (nleft) - clear_to_eol (nleft); + _rl_clear_to_eol (nleft); } /* Since the new first line is now visible, save its length. */ @@ -575,7 +592,7 @@ rl_redisplay () tt = VIS_CHARS (linenum); _rl_move_vert (linenum); _rl_move_cursor_relative (0, tt); - clear_to_eol + _rl_clear_to_eol ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth); } } @@ -710,7 +727,7 @@ rl_redisplay () t < visible_first_line_len) { nleft = screenwidth - t; - clear_to_eol (nleft); + _rl_clear_to_eol (nleft); } visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset); if (visible_first_line_len > screenwidth) @@ -962,7 +979,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (_rl_term_autowrap && current_line < inv_botlin) space_to_eol (lendiff); else - clear_to_eol (lendiff); + _rl_clear_to_eol (lendiff); } } } @@ -1293,16 +1310,14 @@ _rl_erase_at_end_of_line (l) /* Clear to the end of the line. COUNT is the minimum number of character spaces to clear, */ -static void -clear_to_eol (count) +void +_rl_clear_to_eol (count) int count; { #if !defined (__GO32__) if (term_clreol) - { - tputs (term_clreol, 1, _rl_output_character_function); - } - else + tputs (term_clreol, 1, _rl_output_character_function); + else if (count) #endif /* !__GO32__ */ space_to_eol (count); } @@ -1321,6 +1336,17 @@ space_to_eol (count) _rl_last_c_pos += count; } +void +_rl_clear_screen () +{ +#if !defined (__GO32__) + if (term_clrpag) + tputs (term_clrpag, 1, _rl_output_character_function); + else +#endif /* !__GO32__ */ + crlf (); +} + /* Insert COUNT characters from STRING to the output stream. */ static void insert_some_chars (string, count) @@ -1420,7 +1446,7 @@ _rl_update_final () /* If the cursor is the only thing on an otherwise-blank last line, compensate so we don't print an extra CRLF. */ if (_rl_vis_botlin && _rl_last_c_pos == 0 && - visible_line[inv_lbreaks[_rl_vis_botlin]+1] == 0) + visible_line[vis_lbreaks[_rl_vis_botlin]] == 0) { _rl_vis_botlin--; full_lines = 1; @@ -1432,7 +1458,7 @@ _rl_update_final () char *last_line; last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]]; _rl_move_cursor_relative (screenwidth - 1, last_line); - clear_to_eol (0); + _rl_clear_to_eol (0); putc (last_line[screenwidth - 1], rl_outstream); } _rl_vis_botlin = 0; diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile index 9dbab24..58d4dd7 100644 --- a/lib/readline/doc/Makefile +++ b/lib/readline/doc/Makefile @@ -1,9 +1,13 @@ # This makefile for Readline library documentation is in -*- text -*- mode. # Emacs likes it that way. -TEXI2DVI = texi2dvi - RM = rm -f +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi +TEXI2HTML = texi2html +QUIETPS = #set this to -q to shut up dvips +DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky + INSTALL_DATA = cp infodir = /usr/local/info @@ -15,39 +19,42 @@ INFOOBJ = readline.info history.info PSOBJ = readline.ps history.ps HTMLOBJ = readline.html history.html -all: info dvi html +all: info dvi html ps +nodvi: info html readline.dvi: $(RLSRC) $(TEXI2DVI) rlman.texinfo mv rlman.dvi readline.dvi readline.info: $(RLSRC) - makeinfo --no-split -o $@ rlman.texinfo + $(MAKEINFO) --no-split -o $@ rlman.texinfo history.dvi: ${HISTSRC} $(TEXI2DVI) hist.texinfo mv hist.dvi history.dvi history.info: ${HISTSRC} - makeinfo --no-split -o $@ hist.texinfo + $(MAKEINFO) --no-split -o $@ hist.texinfo readline.ps: readline.dvi - dvips -D 300 -o $@ readline.dvi + $(RM) $@ + $(DVIPS) readline.dvi history.ps: history.dvi - dvips -D 300 -o $@ history.dvi + $(RM) $@ + $(DVIPS) history.dvi readline.html: ${RLSRC} - texi2html rlman.texinfo + $(TEXI2HTML) rlman.texinfo sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman.html > readline.html sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman_toc.html > readline_toc.html - rm -f rlman.html rlman_toc.html + $(RM) rlman.html rlman_toc.html history.html: ${HISTSRC} - texi2html hist.texinfo + $(TEXI2HTML) hist.texinfo sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist.html > history.html sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist_toc.html > history_toc.html - rm -f hist.html hist_toc.html + $(RM) hist.html hist_toc.html info: $(INFOOBJ) dvi: $(DVIOBJ) diff --git a/lib/readline/doc/hstech.texinfo b/lib/readline/doc/hstech.texinfo index be41318..5410090 100644 --- a/lib/readline/doc/hstech.texinfo +++ b/lib/readline/doc/hstech.texinfo @@ -415,6 +415,17 @@ 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 +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}). +It should return a non-zero value if the history expansion starting at +@var{string[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. +@end deftypevar + @node History Programming Example @section History Programming Example diff --git a/lib/readline/doc/rltech.texinfo b/lib/readline/doc/rltech.texinfo index 6704d0e..ea0d317 100644 --- a/lib/readline/doc/rltech.texinfo +++ b/lib/readline/doc/rltech.texinfo @@ -312,7 +312,7 @@ to get a character from the input stream. By default, it is set to (@pxref{Utility Functions}). @end deftypevar -@deftypevar {Function *} rl_redisplay_function +@deftypevar {VFunction *} rl_redisplay_function If non-zero, @code{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} @@ -417,6 +417,11 @@ 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 +@deftypefun {char *} rl_get_keymap_name (Keymap keymap) +Return the name matching @var{keymap}. @var{name} is one which would +be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). +@end deftypefun + @node Binding Keys @subsection Binding Keys @@ -576,7 +581,7 @@ that text. @node Redisplay @subsection Redisplay -@deftypefun int rl_redisplay () +@deftypefun void rl_redisplay () Change what's displayed on the screen to reflect the current contents of @code{rl_line_buffer}. @end deftypefun @@ -650,6 +655,11 @@ before Readline attempts to read characters from the terminal with @code{rl_read_key ()}. @end deftypefun +@deftypefun 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 rl_initialize () Initialize or re-initialize Readline's internal state. @end deftypefun @@ -870,7 +880,7 @@ that does the initial simple matching selection algorithm (see 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_entry_function ()}, is used. +@code{filename_completion_function ()}, is used. @end deftypevar @node Completion Functions @@ -1069,7 +1079,7 @@ by @code{rl_filename_quoting_function}. @end deftypevar @deftypevar int rl_inhibit_completion -If this variable is non-zero, completion is inhibited. The 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}. @end deftypevar diff --git a/lib/readline/doc/rluser.texinfo b/lib/readline/doc/rluser.texinfo index 65111f3..f7d6fd8 100644 --- a/lib/readline/doc/rluser.texinfo +++ b/lib/readline/doc/rluser.texinfo @@ -605,31 +605,31 @@ Meta-Control-h: backward-kill-word Text after the function name is ignored # # Arrow keys in keypad mode # -#"\M-OD" backward-char -#"\M-OC" forward-char -#"\M-OA" previous-history -#"\M-OB" next-history +#"\M-OD": backward-char +#"\M-OC": forward-char +#"\M-OA": previous-history +#"\M-OB": next-history # # Arrow keys in ANSI mode # -"\M-[D" backward-char -"\M-[C" forward-char -"\M-[A" previous-history -"\M-[B" next-history +"\M-[D": backward-char +"\M-[C": forward-char +"\M-[A": previous-history +"\M-[B": next-history # # Arrow keys in 8 bit keypad mode # -#"\M-\C-OD" backward-char -#"\M-\C-OC" forward-char -#"\M-\C-OA" previous-history -#"\M-\C-OB" next-history +#"\M-\C-OD": backward-char +#"\M-\C-OC": forward-char +#"\M-\C-OA": previous-history +#"\M-\C-OB": next-history # # Arrow keys in 8 bit ANSI mode # -#"\M-\C-[D" backward-char -#"\M-\C-[C" forward-char -#"\M-\C-[A" previous-history -#"\M-\C-[B" next-history +#"\M-\C-[D": backward-char +#"\M-\C-[C": forward-char +#"\M-\C-[A": previous-history +#"\M-\C-[B": next-history C-q: quoted-insert @@ -921,10 +921,18 @@ Add this digit to the argument already accumulating, or start a new argument. @key{M--} starts a negative argument. @item universal-argument () -Each time this is executed, the argument count is multiplied by four. +This is another way to specify an argument. +If this command is followed by one or more digits, optionally with a +leading minus sign, those digits define the argument. +If the command is followed by digits, executing @code{universal-argument} +again ends the numeric argument, but is otherwise ignored. +As a special case, if this command is immediately followed by a +character that is neither a digit or minus sign, the argument count +for the next command is multiplied by four. The argument count is initially one, so executing this function the -first time makes the argument count four. By default, this is not -bound to a key. +first time makes the argument count four, a second time makes the +argument count sixteen, and so on. +By default, this is not bound to a key. @end ftable @node Commands For Completion @@ -1122,6 +1130,12 @@ word expansions. @item history-expand-line (M-^) Perform history expansion on the current line. +@item alias-expand-line +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-_) A synonym for @code{yank-last-arg}. diff --git a/lib/readline/examples/Makefile b/lib/readline/examples/Makefile index cfa7745..d72a15d 100644 --- a/lib/readline/examples/Makefile +++ b/lib/readline/examples/Makefile @@ -1,6 +1,6 @@ # This is the Makefile for the examples subdirectory of readline. -*- text -*- # -EXECUTABLES = fileman rltest +EXECUTABLES = fileman rltest rl CFLAGS = -g -I../.. -I.. LDFLAGS = -g -L.. @@ -9,6 +9,10 @@ LDFLAGS = -g -L.. all: $(EXECUTABLES) + +rl: rl.o + $(CC) $(LDFLAGS) -o $@ rl.o -lreadline -ltermcap + fileman: fileman.o $(CC) $(LDFLAGS) -o $@ fileman.o -lreadline -ltermcap @@ -17,3 +21,4 @@ rltest: rltest.o fileman.o: fileman.c rltest.o: rltest.c +rl.o: rl.c diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c index 8709120..0702a5b 100644 --- a/lib/readline/examples/fileman.c +++ b/lib/readline/examples/fileman.c @@ -1,15 +1,38 @@ /* fileman.c -- A tiny application which demonstrates how to use the GNU Readline library. This application interactively allows users to manipulate files and their modes. */ +/* + * Remove the next line if you're compiling this against an installed + * libreadline.a + */ +#define READLINE_LIBRARY + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif -#include <stdio.h> #include <sys/types.h> +#ifdef HAVE_SYS_FILE_H #include <sys/file.h> +#endif #include <sys/stat.h> -#include <sys/errno.h> -#include <readline/readline.h> -#include <readline/history.h> +#include <stdio.h> +#include <errno.h> + +#if defined (HAVE_STRING_H) +# include <string.h> +#else /* !HAVE_STRING_H */ +# include <strings.h> +#endif /* !HAVE_STRING_H */ + +#ifdef READLINE_LIBRARY +# include "readline.h" +# include "history.h" +#else +# include <readline/readline.h> +# include <readline/history.h> +#endif extern char *getwd (); extern char *xmalloc (); @@ -54,7 +77,7 @@ int done; char * dupstr (s) - int s; + char *s; { char *r; @@ -304,7 +327,8 @@ com_stat (arg) printf ("Statistics for `%s':\n", arg); - printf ("%s has %d link%s, and is %d byte%s in length.\n", arg, + printf ("%s has %d link%s, and is %d byte%s in length.\n", + arg, finfo.st_nlink, (finfo.st_nlink == 1) ? "" : "s", finfo.st_size, diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c new file mode 100644 index 0000000..6c2f343 --- /dev/null +++ b/lib/readline/examples/rl.c @@ -0,0 +1,115 @@ +/* + * rl - command-line interface to read a line from the standard input + * (or another fd) using readline. + * + * usage: rl [-p prompt] [-u unit] [-d default] + */ + +/* + * Remove the next line if you're compiling this against an installed + * libreadline.a + */ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +#include <config.h> +#endif + +#include <stdio.h> +#include <sys/types.h> +#include "posixstat.h" +#include "readline.h" +#include "history.h" + +extern int optind; +extern char *optarg; + +extern char *strrchr(); + +static char *progname; +static char *deftext; + +static int +set_deftext () +{ + if (deftext) + { + rl_insert_text (deftext); + deftext = (char *)NULL; + rl_startup_hook = (Function *)NULL; + } +} + +usage() +{ + fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n", + progname, progname); +} + +main (argc, argv) + int argc; + char **argv; +{ + char *temp, *prompt; + struct stat sb; + int done, opt, fd; + FILE *ifp; + + progname = strrchr(argv[0], '/'); + if (progname == 0) + progname = argv[0]; + else + progname++; + + /* defaults */ + prompt = "readline$ "; + fd = 0; + deftext = (char *)0; + + while ((opt = getopt(argc, argv, "p:u:d:")) != EOF) + { + switch (opt) + { + case 'p': + prompt = optarg; + break; + case 'u': + fd = atoi(optarg); + if (fd < 0) + { + fprintf (stderr, "%s: bad file descriptor `%s'\n", progname, optarg); + exit (2); + } + break; + case 'd': + deftext = optarg; + break; + default: + usage (); + exit (2); + } + } + + if (fd != 0) + { + if (fstat (fd, &sb) < 0) + { + fprintf (stderr, "%s: %d: bad file descriptor\n", progname, fd); + exit (1); + } + ifp = fdopen (fd, "r"); + rl_instream = ifp; + } + + if (deftext && *deftext) + rl_startup_hook = set_deftext; + + temp = readline (prompt); + + /* Test for EOF. */ + if (temp == 0) + exit (1); + + puts (temp); + exit (0); +} diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c index 311629f..ff3ad5c 100644 --- a/lib/readline/examples/rltest.c +++ b/lib/readline/examples/rltest.c @@ -4,10 +4,20 @@ /* */ /* **************************************************************** */ +/* + * Remove the next line if you're compiling this against an installed + * libreadline.a + */ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +#include <config.h> +#endif + #include <stdio.h> #include <sys/types.h> -#include "../readline.h" -#include "../history.h" +#include "readline.h" +#include "history.h" main () { diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c index 6b7d351..702fabd 100644 --- a/lib/readline/funmap.c +++ b/lib/readline/funmap.c @@ -76,6 +76,7 @@ static FUNMAP default_funmap[] = { { "do-lowercase-version", rl_do_lowercase_version }, { "downcase-word", rl_downcase_word }, { "dump-functions", rl_dump_functions }, + { "dump-macros", rl_dump_macros }, { "dump-variables", rl_dump_variables }, { "emacs-editing-mode", rl_emacs_editing_mode }, { "end-kbd-macro", rl_end_kbd_macro }, diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c index d916c74..de71d78 100644 --- a/lib/readline/histexpand.c +++ b/lib/readline/histexpand.c @@ -59,11 +59,7 @@ static char *history_find_word (); extern int history_offset; -#if defined (SHELL) extern char *single_quote (); -#else -static char *single_quote (); -#endif /* !SHELL */ static char *quote_breaks (); extern char *xmalloc (), *xrealloc (); @@ -91,6 +87,10 @@ char *history_no_expand_chars = " \t\n\r="; The default is 0. */ int history_quotes_inhibit_expansion = 0; +/* 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; + /* **************************************************************** */ /* */ /* History Expansion */ @@ -289,38 +289,6 @@ hist_string_extract_single_quoted (string, sindex) *sindex = i; } -#if !defined (SHELL) -/* Does shell-like quoting using single quotes. */ -static char * -single_quote (string) - char *string; -{ - register int c; - char *result, *r, *s; - - result = (char *)xmalloc (3 + (3 * strlen (string))); - r = result; - *r++ = '\''; - - for (s = string; s && (c = *s); s++) - { - *r++ = c; - - if (c == '\'') - { - *r++ = '\\'; /* insert escaped single quote */ - *r++ = '\''; - *r++ = '\''; /* start new quoted string */ - } - } - - *r++ = '\''; - *r = '\0'; - - return (result); -} -#endif /* !SHELL */ - static char * quote_breaks (s) char *s; @@ -888,19 +856,14 @@ history_expand (hstring, output) { if (!cc || member (cc, history_no_expand_chars)) continue; -#if defined (SHELL) - /* The shell uses ! as a pattern negation character - in globbing [...] expressions, so let those pass - without expansion. */ - else if (i > 0 && (string[i - 1] == '[') && - member (']', string + i + 1)) - continue; - /* The shell uses ! as the indirect expansion character, so - let those expansions pass as well. */ - else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' && - member ('}', string + i + 1)) + /* If the calling application has set + history_inhibit_expansion_function to a function that checks + for special cases that should not be history expanded, + call the function and skip the expansion if it returns a + non-zero value. */ + else if (history_inhibit_expansion_function && + (*history_inhibit_expansion_function) (string, i)) continue; -#endif /* SHELL */ else break; } diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 355d46e..c3de134 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -52,6 +52,16 @@ # include <strings.h> #endif /* !HAVE_STRING_H */ +#if defined (__EMX__) +# ifndef O_BINARY +# define O_BINARY 0 +# endif +#else /* !__EMX__ */ + /* If we're not compiling for __EMX__, we don't want this at all. Ever. */ +# undef O_BINARY +# define O_BINARY 0 +#endif /* !__EMX__ */ + #include <errno.h> #if !defined (errno) extern int errno; @@ -60,6 +70,9 @@ extern int errno; #include "history.h" #include "histlib.h" +/* Functions imported from shell.c */ +extern char *get_env_value (); + extern char *xmalloc (), *xrealloc (); /* Return the string that should be used in the place of this @@ -77,7 +90,7 @@ history_filename (filename) if (return_val) return (return_val); - home = getenv ("HOME"); + home = get_env_value ("HOME"); if (home == 0) { @@ -121,7 +134,7 @@ read_history_range (filename, from, to) struct stat finfo; input = history_filename (filename); - file = open (input, O_RDONLY, 0666); + file = open (input, O_RDONLY|O_BINARY, 0666); if ((file < 0) || (fstat (file, &finfo) == -1)) goto error_and_exit; @@ -194,11 +207,12 @@ history_truncate_file (fname, lines) { register int i; int file, chars_read; - char *buffer = (char *)NULL, *filename; + char *buffer, *filename; struct stat finfo; + buffer = (char *)NULL; filename = history_filename (fname); - file = open (filename, O_RDONLY, 0666); + file = open (filename, O_RDONLY|O_BINARY, 0666); if (file == -1 || fstat (file, &finfo) == -1) goto truncate_exit; @@ -232,7 +246,7 @@ history_truncate_file (fname, lines) /* 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, 0666)) != -1)) + if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0666)) != -1)) { write (file, buffer + i, finfo.st_size - i); close (file); @@ -255,10 +269,11 @@ history_do_write (filename, nelements, overwrite) int nelements, overwrite; { register int i; - char *output = history_filename (filename); + char *output; int file, mode; - mode = overwrite ? O_WRONLY | O_CREAT | O_TRUNC : O_WRONLY | O_APPEND; + mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY; + output = history_filename (filename); if ((file = open (output, mode, 0666)) == -1) { diff --git a/lib/readline/history.h b/lib/readline/history.h index 17ec877..e49a341 100644 --- a/lib/readline/history.h +++ b/lib/readline/history.h @@ -22,6 +22,14 @@ #ifndef _HISTORY_H_ #define _HISTORY_H_ +#if !defined (_FUNCTION_DEF) +# define _FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +typedef char *CPFunction (); +typedef char **CPPFunction (); +#endif + /* The structure used to store a history entry. */ typedef struct _hist_entry { char *line; @@ -207,4 +215,9 @@ extern char *history_no_expand_chars; extern char *history_search_delimiter_chars; extern int history_quotes_inhibit_expansion; +/* If set, this function is called to decide whether or not a particular + history expansion should be treated as a special case for the calling + application and not expanded. */ +extern Function *history_inhibit_expansion_function; + #endif /* !_HISTORY_H_ */ diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c index fa60fa4..9639a63 100644 --- a/lib/readline/isearch.c +++ b/lib/readline/isearch.c @@ -30,13 +30,19 @@ # include <config.h> #endif +#include <sys/types.h> + #include <stdio.h> #if defined (HAVE_UNISTD_H) # include <unistd.h> #endif -#include <sys/types.h> +#if defined (HAVE_STDLIB_H) +# include <stdlib.h> +#else +# include "ansi_stdlib.h" +#endif #include "rldefs.h" #include "readline.h" @@ -287,7 +293,8 @@ rl_search_history (direction, invoking_key) rl_end = strlen (rl_line_buffer); _rl_restore_prompt(); rl_clear_message (); - free (allocated_line); + if (allocated_line) + free (allocated_line); free (lines); return 0; @@ -403,7 +410,8 @@ rl_search_history (direction, invoking_key) rl_point = line_index; rl_clear_message (); - free (allocated_line); + if (allocated_line) + free (allocated_line); free (lines); return 0; diff --git a/lib/readline/kill.c b/lib/readline/kill.c index 89f6b55..352f37d 100644 --- a/lib/readline/kill.c +++ b/lib/readline/kill.c @@ -53,6 +53,7 @@ extern Function *rl_last_func; extern void _rl_init_argument (); extern int _rl_set_mark_at_pos (); +extern void _rl_fix_point (); extern void _rl_abort_internal (); extern char *xmalloc (), *xrealloc (); @@ -384,7 +385,11 @@ int rl_kill_region (count, ignore) int count, ignore; { - return (region_kill_internal (1)); + int r; + + r = region_kill_internal (1); + _rl_fix_point (1); + return r; } /* Copy COUNT words to the kill ring. DIR says which direction we look @@ -521,7 +526,7 @@ rl_yank_nth_arg (count, ignore) inserts it right *after* rl_point. */ if (rl_editing_mode == vi_mode) { - rl_vi_append_mode (); + rl_vi_append_mode (1, ignore); rl_insert_text (" "); } #endif /* VI_MODE */ diff --git a/lib/readline/nls.c b/lib/readline/nls.c index fad5201..7a00a5f 100644 --- a/lib/readline/nls.c +++ b/lib/readline/nls.c @@ -25,6 +25,8 @@ # include <config.h> #endif +#include <sys/types.h> + #if defined (HAVE_UNISTD_H) # include <unistd.h> #endif /* HAVE_UNISTD_H */ @@ -46,7 +48,11 @@ extern int _rl_convert_meta_chars_to_ascii; extern int _rl_output_meta_chars; extern int _rl_meta_flag; - + +/* Functions imported from shell.c */ +extern char *get_env_value (); + +#if !defined (HAVE_SETLOCALE) /* A list of legal values for the LANG or LC_CTYPE environment variables. If a locale name in this list is the value for the LC_ALL, LC_CTYPE, or LANG environment variable (using the first of those with a value), @@ -69,6 +75,7 @@ static char *legal_lang_values[] = static char *normalize_codeset (); static char *find_codeset (); +#endif /* !HAVE_SETLOCALE */ /* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value to decide the defaults for 8-bit character input and output. Returns @@ -76,12 +83,33 @@ static char *find_codeset (); int _rl_init_eightbit () { +/* If we have setlocale(3), just check the current LC_CTYPE category + value, and go into eight-bit mode if it's not C or POSIX. */ +#if defined (HAVE_SETLOCALE) + char *t; + + /* Set the LC_CTYPE locale category from environment variables. */ + t = setlocale (LC_CTYPE, ""); + if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0)) + { + _rl_meta_flag = 1; + _rl_convert_meta_chars_to_ascii = 0; + _rl_output_meta_chars = 1; + return (1); + } + else + return (0); + +#else /* !HAVE_SETLOCALE */ char *lspec, *t; int i; - lspec = getenv ("LC_ALL"); - if (lspec == 0) lspec = getenv ("LC_CTYPE"); - if (lspec == 0) lspec = getenv ("LANG"); + /* 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 = get_env_value ("LC_CTYPE"); + if (lspec == 0) lspec = get_env_value ("LANG"); if (lspec == 0 || (t = normalize_codeset (lspec)) == 0) return (0); for (i = 0; t && legal_lang_values[i]; i++) @@ -90,15 +118,15 @@ _rl_init_eightbit () _rl_meta_flag = 1; _rl_convert_meta_chars_to_ascii = 0; _rl_output_meta_chars = 1; -#if defined (HAVE_SETLOCALE) - setlocale (LC_CTYPE, lspec); -#endif break; } free (t); return (legal_lang_values[i] ? 1 : 0); + +#endif /* !HAVE_SETLOCALE */ } +#if !defined (HAVE_SETLOCALE) static char * normalize_codeset (codeset) char *codeset; @@ -196,3 +224,4 @@ find_codeset (name, lenp) return result; } +#endif /* !HAVE_SETLOCALE */ diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h index 8b0e5bc..7480a93 100644 --- a/lib/readline/posixdir.h +++ b/lib/readline/posixdir.h @@ -42,7 +42,7 @@ # define D_NAMLEN(d) ((d)->d_namlen) #endif /* !HAVE_DIRENT_H */ -#if defined (STRUCT_DIRENT_HAS_D_INO) +#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO) # define d_fileno d_ino #endif diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h new file mode 100644 index 0000000..8703d17 --- /dev/null +++ b/lib/readline/posixjmp.h @@ -0,0 +1,20 @@ +/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */ + +#ifndef _POSIXJMP_H_ +#define _POSIXJMP_H_ + +#include <setjmp.h> + +/* This *must* be included *after* config.h */ + +#if defined (HAVE_POSIX_SIGSETJMP) +# define procenv_t sigjmp_buf +# undef setjmp +# define setjmp(x) sigsetjmp((x), 1) +# undef longjmp +# define longjmp(x, n) siglongjmp((x), (n)) +#else +# define procenv_t jmp_buf +#endif + +#endif /* _POSIXJMP_H_ */ diff --git a/lib/readline/readline.c b/lib/readline/readline.c index d85789d..dcd8f81 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -49,17 +49,25 @@ #include <signal.h> #include <stdio.h> -#include <setjmp.h> +#include "posixjmp.h" /* System-specific feature definitions and include files. */ #include "rldefs.h" -#include "tcap.h" +#if defined (__EMX__) +# define INCL_DOSPROCESS +# include <os2.h> +#endif /* __EMX__ */ /* Some standard library routines. */ #include "readline.h" #include "history.h" +#ifndef RL_LIBRARY_VERSION +# define RL_LIBRARY_VERSION "2.1-bash" +#endif + +/* Evaluates its arguments multiple times. */ #define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0) /* NOTE: Functions and variables prefixed with `_rl_' are @@ -75,7 +83,6 @@ extern void _rl_get_screen_size (); extern int _rl_enable_meta; extern int _rl_term_autowrap; -extern char *term_backspace, *term_clreol, *term_clrpag; extern int screenwidth, screenheight, screenchars; /* Variables and functions imported from rltty.c. */ @@ -99,9 +106,17 @@ extern int rl_read_key (); /* Functions imported from nls.c */ extern int _rl_init_eightbit (); +/* Functions imported from shell.c */ +extern char *get_env_value (); + /* External redisplay functions and variables from display.c */ extern void _rl_move_vert (); extern void _rl_update_final (); +extern void _rl_clear_to_eol (); +extern void _rl_clear_screen (); + +extern void _rl_save_prompt (); +extern void _rl_restore_prompt (); extern void _rl_erase_at_end_of_line (); extern void _rl_move_cursor_relative (); @@ -153,6 +168,7 @@ static void readline_default_bindings (); #endif /* !__GO32__ */ #if defined (__GO32__) +# include <go32.h> # include <pc.h> # undef HANDLE_SIGNALS #endif /* __GO32__ */ @@ -165,7 +181,7 @@ extern char *xmalloc (), *xrealloc (); /* */ /* **************************************************************** */ -char *rl_library_version = "2.1"; +char *rl_library_version = RL_LIBRARY_VERSION; /* A pointer to the keymap that is currently in use. By default, it is the standard emacs keymap. */ @@ -174,6 +190,11 @@ Keymap _rl_keymap = emacs_standard_keymap; /* The current style of editing. */ int rl_editing_mode = emacs_mode; +/* 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. */ +int rl_dispatching; + /* Non-zero if the previous command was a kill command. */ int _rl_last_command_was_kill = 0; @@ -208,7 +229,7 @@ int rl_done; Function *rl_last_func = (Function *)NULL; /* Top level environment for readline_internal (). */ -jmp_buf readline_top_level; +procenv_t readline_top_level; /* The streams we interact with. */ FILE *_rl_in_stream, *_rl_out_stream; @@ -360,7 +381,7 @@ readline_internal_setup () (*rl_redisplay_function) (); #if defined (VI_MODE) if (rl_editing_mode == vi_mode) - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, 0); #endif /* VI_MODE */ } } @@ -498,6 +519,14 @@ readline_internal () } void +_rl_init_line_state () +{ + rl_point = rl_end = 0; + the_line = rl_line_buffer; + the_line[0] = 0; +} + +void _rl_set_the_line () { the_line = rl_line_buffer; @@ -551,12 +580,14 @@ _rl_dispatch (key, map) _rl_suppress_redisplay = (map[key].function == rl_insert) && _rl_input_available (); #endif + rl_dispatching = 1; r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key); + 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) + if (!rl_pending_input && map[key].function != rl_digit_argument) rl_last_func = map[key].function; } else @@ -603,7 +634,7 @@ _rl_dispatch (key, map) /* */ /* **************************************************************** */ -/* Initliaze readline (and terminal if not already). */ +/* Initialize readline (and terminal if not already). */ int rl_initialize () { @@ -616,9 +647,7 @@ rl_initialize () } /* Initalize the current line information. */ - rl_point = rl_end = 0; - the_line = rl_line_buffer; - the_line[0] = 0; + _rl_init_line_state (); /* We aren't done yet. We haven't even gotten started yet! */ rl_done = 0; @@ -643,12 +672,41 @@ rl_initialize () return 0; } +#if defined (__EMX__) +static void +_emx_build_environ () +{ + TIB *tibp; + PIB *pibp; + char *t, **tp; + int c; + + DosGetInfoBlocks (&tibp, &pibp); + t = pibp->pib_pchenv; + for (c = 1; *t; c++) + t += strlen (t) + 1; + tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *)); + t = pibp->pib_pchenv; + while (*t) + { + *tp++ = t; + t += strlen (t) + 1; + } + *tp = 0; +} +#endif /* __EMX__ */ + /* Initialize the entire state of the world. */ static void readline_initialize_everything () { +#if defined (__EMX__) + if (environ == 0) + _emx_build_environ (); +#endif + /* Find out if we are running in Emacs. */ - running_in_emacs = getenv ("EMACS") != (char *)0; + running_in_emacs = get_env_value ("EMACS") != (char *)0; /* Set up input and output if they are not already set up. */ if (!rl_instream) @@ -664,7 +722,7 @@ readline_initialize_everything () _rl_out_stream = rl_outstream; /* Allocate data structures. */ - if (!rl_line_buffer) + if (rl_line_buffer == 0) rl_line_buffer = xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE); /* Initialize the terminal interface. */ @@ -773,45 +831,56 @@ bind_arrow_keys () static int rl_digit_loop () { - int key, c, sawminus; + int key, c, sawminus, sawdigits; _rl_save_prompt (); - sawminus = 0; + sawminus = sawdigits = 0; while (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) { - rl_numeric_arg *= 4; - continue; - } - c = UNMETA (c); - if (_rl_digit_p (c)) - { - rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0'; - rl_explicit_arg = 1; - } - else - { - if (c == '-' && rl_explicit_arg == 0) + if (sawdigits == 0) { - rl_numeric_arg = sawminus = 1; - rl_arg_sign = -1; + rl_numeric_arg *= 4; + continue; } else { - /* Make M-- command equivalent to M--1 command. */ - if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0) - rl_explicit_arg = 1; + 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; @@ -936,6 +1005,28 @@ rl_delete_text (from, to) 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 + /* **************************************************************** */ /* */ /* Readline character functions */ @@ -1153,8 +1244,7 @@ rl_refresh_line () memset (row_start + col, 0, (width - col) * 2); } #else /* !__GO32__ */ - if (term_clreol) - tputs (term_clreol, 1, _rl_output_character_function); + _rl_clear_to_eol (0); /* arg of 0 means to not use spaces */ #endif /* !__GO32__ */ rl_forced_update_display (); @@ -1176,13 +1266,7 @@ rl_clear_screen (count, key) return 0; } -#if !defined (__GO32__) - if (term_clrpag) - tputs (term_clrpag, 1, _rl_output_character_function); - else -#endif /* !__GO32__ */ - crlf (); - + _rl_clear_screen (); /* calls termcap function to clear screen */ rl_forced_update_display (); rl_display_fixed = 1; @@ -1321,8 +1405,11 @@ rl_newline (count, key) rl_done = 1; #if defined (VI_MODE) - _rl_vi_done_inserting (); - _rl_vi_reset_last (); + if (rl_editing_mode == vi_mode) + { + _rl_vi_done_inserting (); + _rl_vi_reset_last (); + } #endif /* VI_MODE */ if (readline_echoing_p) @@ -1632,10 +1719,7 @@ rl_transpose_chars (count, key) rl_delete_text (rl_point, rl_point + 1); rl_point += count; - if (rl_point > rl_end) - rl_point = rl_end; - else if (rl_point < 0) - rl_point = 0; + _rl_fix_point (0); rl_insert_text (dummy); rl_end_undo_group (); @@ -1988,7 +2072,7 @@ rl_vi_editing_mode (count, key) { #if defined (VI_MODE) rl_editing_mode = vi_mode; - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); #endif /* VI_MODE */ return 0; } diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 4f7d498..d6c1a5c 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -102,7 +102,7 @@ extern int rl_noninc_forward_search_again (), rl_noninc_reverse_search_again (); /* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */ -extern int rl_vi_check (), rl_vi_textmod_command (); +extern int rl_vi_check (); extern int rl_vi_undo (), rl_vi_redo (), rl_vi_tilde_expand (), rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (), @@ -236,6 +236,10 @@ extern char *rl_library_version; whatever was in argv[0]. It is used when parsing conditionals. */ extern char *rl_readline_name; +/* The prompt readline uses. This is set from the argument to + readline (), and should not be assigned to directly. */ +extern char *rl_prompt; + /* The line buffer that is in use. */ extern char *rl_line_buffer; @@ -248,6 +252,11 @@ extern int rl_done; extern int rl_pending_input; +/* 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. */ +int rl_dispatching; + /* The name of the terminal to use. */ extern char *rl_terminal_name; @@ -370,6 +379,14 @@ extern int rl_completion_type; default is a space. Nothing is added if this is '\0'. */ extern int rl_completion_append_character; +/* 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, 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; diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h index 5a9e62a..d4aced4 100644 --- a/lib/readline/rldefs.h +++ b/lib/readline/rldefs.h @@ -40,17 +40,6 @@ # endif #endif -#if defined (HAVE_SYS_STREAM_H) -# include <sys/stream.h> -#endif /* HAVE_SYS_STREAM_H */ -#if defined (HAVE_SYS_PTEM_H) -# include <sys/ptem.h> -# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ -#endif /* HAVE_SYS_PTEM_H */ -#if defined (HAVE_SYS_PTE_H) -# include <sys/pte.h> -#endif /* HAVE_SYS_PTE_H */ - /* Posix macro to check file in statbuf for directory-ness. This requires that <sys/stat.h> be included before this test. */ #if defined (S_IFDIR) && !defined (S_ISDIR) diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c index d35eb6a..8312963 100644 --- a/lib/readline/rltty.c +++ b/lib/readline/rltty.c @@ -53,6 +53,8 @@ extern int _rl_eof_char; extern int _rl_enable_keypad, _rl_enable_meta; +extern void _rl_control_keypad (); + #if defined (__GO32__) # include <pc.h> # undef HANDLE_SIGNALS diff --git a/lib/readline/rltty.h b/lib/readline/rltty.h index 3ee6b3f..3e13704 100644 --- a/lib/readline/rltty.h +++ b/lib/readline/rltty.h @@ -42,6 +42,18 @@ # include <sgtty.h> #endif +/* Stuff for `struct winsize' on various systems. */ +#if defined (HAVE_SYS_STREAM_H) +# include <sys/stream.h> +#endif /* HAVE_SYS_STREAM_H */ +#if defined (HAVE_SYS_PTEM_H) +# include <sys/ptem.h> +# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ +#endif /* HAVE_SYS_PTEM_H */ +#if defined (HAVE_SYS_PTE_H) +# include <sys/pte.h> +#endif /* HAVE_SYS_PTE_H */ + /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and it is not already defined. It is used both to determine if a special character is disabled and to disable certain special diff --git a/lib/readline/search.c b/lib/readline/search.c index 05641a1..3024ee5 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -33,11 +33,20 @@ # include <unistd.h> #endif +#if defined (HAVE_STDLIB_H) +# include <stdlib.h> +#else +# include "ansi_stdlib.h" +#endif + #include "rldefs.h" #include "readline.h" #include "history.h" -#define abs(x) (((x) > 0) ? (x) : -(x)) +#ifdef abs +# undef abs +#endif +#define abs(x) (((x) >= 0) ? (x) : -(x)) extern char *xmalloc (), *xrealloc (); diff --git a/lib/readline/shell.c b/lib/readline/shell.c new file mode 100644 index 0000000..eb99c72 --- /dev/null +++ b/lib/readline/shell.c @@ -0,0 +1,129 @@ +/* shell.c -- readline utility functions that are normally provided by + bash when readline is linked as part of the shell. */ + +/* Copyright (C) 1997 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. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +# include <config.h> +#endif + +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ + +#if defined (HAVE_STDLIB_H) +# include <stdlib.h> +#else +# include "ansi_stdlib.h" +#endif /* HAVE_STDLIB_H */ + +extern char *xmalloc (), *xrealloc (); + +#if !defined (SHELL) + +#ifdef savestring +#undef savestring +#endif + +/* Backwards compatibility, now that savestring has been removed from + all `public' readline header files. */ +char * +savestring (s) + char *s; +{ + return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); +} + +/* Does shell-like quoting using single quotes. */ +char * +single_quote (string) + char *string; +{ + register int c; + char *result, *r, *s; + + result = (char *)xmalloc (3 + (3 * strlen (string))); + r = result; + *r++ = '\''; + + for (s = string; s && (c = *s); s++) + { + *r++ = c; + + if (c == '\'') + { + *r++ = '\\'; /* insert escaped single quote */ + *r++ = '\''; + *r++ = '\''; /* start new quoted string */ + } + } + + *r++ = '\''; + *r = '\0'; + + return (result); +} + +/* Set the environment variables LINES and COLUMNS to lines and cols, + respectively. */ +void +set_lines_and_columns (lines, cols) + int lines, cols; +{ + char *b; + +#if defined (HAVE_PUTENV) + b = xmalloc (24); + sprintf (b, "LINES=%d", lines); + putenv (b); + b = xmalloc (24); + sprintf (b, "COLUMNS=%d", cols); + putenv (b); +#else /* !HAVE_PUTENV */ +# if defined (HAVE_SETENV) + b = xmalloc (8); + sprintf (b, "%d", lines); + setenv ("LINES", b, 1); + b = xmalloc (8); + sprintf (b, "%d", cols); + setenv ("COLUMNS", b, 1); +# endif /* HAVE_SETENV */ +#endif /* !HAVE_PUTENV */ +} + +char * +get_env_value (varname) + char *varname; +{ + return ((char *)getenv (varname)); +} + +#else /* SHELL */ +extern char *get_string_value (); + +char * +get_env_value (varname) + char *varname; +{ + return get_string_value (varname); +} +#endif /* SHELL */ diff --git a/lib/readline/signals.c b/lib/readline/signals.c index 2fe7953..e19c22d 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -87,6 +87,14 @@ static SigHandler *rl_set_sighandler (); /* */ /* **************************************************************** */ +/* If we're not being compiled as part of bash, initialize handlers for + and catch the job control signals (SIGTTIN, SIGTTOU, SIGTSTP) and + SIGTERM. */ +#if !defined (SHELL) +# define HANDLE_JOB_SIGNALS +# define HANDLE_SIGTERM +#endif /* !SHELL */ + #if defined (HAVE_POSIX_SIGNALS) typedef struct sigaction sighandler_cxt; # define rl_sigaction(s, nh, oh) sigaction(s, nh, oh) @@ -97,9 +105,13 @@ typedef struct { SigHandler *sa_handler; } sighandler_cxt; static sighandler_cxt old_int, old_alrm; -#if !defined (SHELL) -static sighandler_cxt old_tstp, old_ttou, old_ttin, old_term; -#endif /* !SHELL */ +#if defined (HANDLE_JOB_SIGNALS) +static sighandler_cxt old_tstp, old_ttou, old_ttin; +#endif /* HANDLE_JOB_SIGNALS */ + +#if defined (HANDLE_SIGTERM) +static sighandler_cxt old_term; +#endif #if defined (SIGWINCH) static sighandler_cxt old_winch; @@ -116,14 +128,16 @@ rl_signal_handler (sig) #else /* !HAVE_POSIX_SIGNALS */ # if defined (HAVE_BSD_SIGNALS) long omask; -# endif /* HAVE_BSD_SIGNALS */ +# else /* !HAVE_BSD_SIGNALS */ + sighandler_cxt dummy_cxt; /* needed for rl_set_sighandler call */ +# endif /* !HAVE_BSD_SIGNALS */ #endif /* !HAVE_POSIX_SIGNALS */ #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) /* Since the signal will not be blocked while we are in the signal handler, ignore it until rl_clear_signals resets the catcher. */ if (sig == SIGINT || sig == SIGALRM) - rl_set_sighandler (sig, SIG_IGN, (sighandler_cxt *)NULL); + rl_set_sighandler (sig, SIG_IGN, &dummy_cxt); #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ switch (sig) @@ -188,6 +202,16 @@ rl_handle_sigwinch (sig) { SigHandler *oh; +#if defined (MUST_REINSTALL_SIGHANDLERS) + sighandler_cxt dummy_winch; + + /* We don't want to change old_winch -- it holds the state of SIGWINCH + disposition set by the calling application. We need this state + because we call the application's SIGWINCH handler after updating + our own idea of the screen size. */ + rl_set_sighandler (SIGWINCH, rl_handle_sigwinch, &dummy_winch); +#endif + if (readline_echoing_p) { _rl_get_screen_size (fileno (rl_instream), 1); @@ -265,7 +289,7 @@ rl_set_signals () rl_sigaction (SIGALRM, &old_alrm, &dummy); #endif /* HAVE_POSIX_SIGNALS */ -#if !defined (SHELL) +#if defined (HANDLE_JOB_SIGNALS) #if defined (SIGTSTP) oh = rl_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp); @@ -286,9 +310,12 @@ rl_set_signals () } #endif /* SIGTTOU */ +#endif /* HANDLE_JOB_SIGNALS */ + +#if defined (HANDLE_SIGTERM) /* Handle SIGTERM if we're not being compiled as part of bash. */ rl_set_sighandler (SIGTERM, rl_signal_handler, &old_term); -#endif /* !SHELL */ +#endif /* HANDLE_SIGTERM */ #if defined (SIGWINCH) rl_set_sighandler (SIGWINCH, rl_handle_sigwinch, &old_winch); @@ -309,7 +336,7 @@ rl_clear_signals () rl_sigaction (SIGINT, &old_int, &dummy); rl_sigaction (SIGALRM, &old_alrm, &dummy); -#if !defined (SHELL) +#if defined (HANDLE_JOB_SIGNALS) #if defined (SIGTSTP) rl_sigaction (SIGTSTP, &old_tstp, &dummy); @@ -320,9 +347,11 @@ rl_clear_signals () rl_sigaction (SIGTTIN, &old_ttin, &dummy); #endif /* SIGTTOU */ - rl_sigaction (SIGTERM, &old_term, &dummy); +#endif /* HANDLE_JOB_SIGNALS */ -#endif /* !SHELL */ +#if defined (HANDLE_SIGTERM) + rl_sigaction (SIGTERM, &old_term, &dummy); +#endif /* HANDLE_SIGTERM */ #if defined (SIGWINCH) sigemptyset (&dummy.sa_mask); diff --git a/lib/readline/tcap.h b/lib/readline/tcap.h index 0673288..acb2d76 100644 --- a/lib/readline/tcap.h +++ b/lib/readline/tcap.h @@ -29,6 +29,9 @@ #endif #if defined (HAVE_TERMCAP_H) +# if defined (__linux__) && !defined (SPEED_T_IN_SYS_TYPES) +# include "rltty.h" +# endif # include <termcap.h> #else diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c index 9ca9bc6..5a8df89 100644 --- a/lib/readline/terminal.c +++ b/lib/readline/terminal.c @@ -53,11 +53,12 @@ /* System-specific feature definitions and include files. */ #include "rldefs.h" -#include "tcap.h" - -#if defined (GWINSZ_IN_SYS_IOCTL) +#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ) # include <sys/ioctl.h> -#endif /* GWINSZ_IN_SYS_IOCTL */ +#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ + +#include "rltty.h" +#include "tcap.h" /* Some standard library routines. */ #include "readline.h" @@ -69,6 +70,13 @@ extern int readline_echoing_p; extern int _rl_bell_preference; extern Keymap _rl_keymap; +/* Functions imported from bind.c */ +extern void _rl_bind_if_unbound (); + +/* Functions imported from shell.c */ +extern void set_lines_and_columns (); +extern char *get_env_value (); + /* **************************************************************** */ /* */ /* Terminal and Termcap */ @@ -84,8 +92,10 @@ static int tcap_initialized; static int dumb_term; #if !defined (__linux__) -/* If this causes problems, add back the `extern'. */ -/*extern*/ char PC, *BC, *UP; +# if defined (__EMX__) || defined (NEED_EXTERN_PC) +extern +# endif /* __EMX__ || NEED_EXTERN_PC */ +char PC, *BC, *UP; #endif /* __linux__ */ /* Some strings to control terminal actions. These are output by tputs (). */ @@ -139,45 +149,6 @@ int _rl_enable_keypad; /* Non-zero means the user wants to enable a meta key. */ int _rl_enable_meta = 1; -/* Re-initialize the terminal considering that the TERM/TERMCAP variable - has changed. */ -int -rl_reset_terminal (terminal_name) - char *terminal_name; -{ - _rl_init_terminal_io (terminal_name); - return 0; -} - -#if !defined (SHELL) -static void -set_lines_and_columns (lines, cols) - int lines, cols; -{ - char *b; - -#if defined (HAVE_PUTENV) - b = xmalloc (24); - sprintf (b, "LINES=%d", lines); - putenv (b); - b = xmalloc (24); - sprintf (b, "COLUMNS=%d", cols); - putenv (b); -#else /* !HAVE_PUTENV */ -# if defined (HAVE_SETENV) - b = xmalloc (8); - sprintf (b, "%d", lines); - setenv ("LINES", b, 1); - b = xmalloc (8); - sprintf (b, "%d", cols); - setenv ("COLUMNS", b, 1); -# endif /* HAVE_SETENV */ -#endif /* !HAVE_PUTENV */ -} -#else /* SHELL */ -extern void set_lines_and_columns (); -#endif /* SHELL */ - /* Get readline's idea of the screen size. TTY is a file descriptor open to the terminal. If IGNORE_ENV is true, we do not pay attention to the values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being @@ -190,6 +161,9 @@ _rl_get_screen_size (tty, ignore_env) #if defined (TIOCGWINSZ) struct winsize window_size; #endif /* TIOCGWINSZ */ +#if defined (__EMX__) + int sz[2]; +#endif #if defined (TIOCGWINSZ) if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) @@ -199,11 +173,17 @@ _rl_get_screen_size (tty, ignore_env) } #endif /* TIOCGWINSZ */ +#if defined (__EMX__) + _scrsize (sz); + screenwidth = sz[0]; + screenheight = sz[1]; +#endif + /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV is unset. */ if (screenwidth <= 0) { - if (ignore_env == 0 && (ss = getenv ("COLUMNS"))) + if (ignore_env == 0 && (ss = get_env_value ("COLUMNS"))) screenwidth = atoi (ss); if (screenwidth <= 0 && term_string_buffer) @@ -214,7 +194,7 @@ _rl_get_screen_size (tty, ignore_env) is unset. */ if (screenheight <= 0) { - if (ignore_env == 0 && (ss = getenv ("LINES"))) + if (ignore_env == 0 && (ss = get_env_value ("LINES"))) screenheight = atoi (ss); if (screenheight <= 0 && term_string_buffer) @@ -334,7 +314,7 @@ _rl_init_terminal_io (terminal_name) int tty; Keymap xkeymap; - term = terminal_name ? terminal_name : getenv ("TERM"); + term = terminal_name ? terminal_name : get_env_value ("TERM"); if (term_string_buffer == 0) term_string_buffer = xmalloc (2032); @@ -443,6 +423,16 @@ rl_get_termcap (cap) return ((char *)NULL); } +/* Re-initialize the terminal considering that the TERM/TERMCAP variable + has changed. */ +int +rl_reset_terminal (terminal_name) + char *terminal_name; +{ + _rl_init_terminal_io (terminal_name); + return 0; +} + /* A function for the use of tputs () */ int _rl_output_character_function (c) @@ -536,7 +526,7 @@ outchar (c) return putc (c, rl_outstream); } -int +void _rl_enable_meta_key () { if (term_has_meta && term_mm) diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c index 69f5768..1d38d9d 100644 --- a/lib/readline/tilde.c +++ b/lib/readline/tilde.c @@ -23,6 +23,10 @@ # include <config.h> #endif +#if defined (HAVE_UNISTD_H) +# include <unistd.h> +#endif + #if defined (HAVE_STRING_H) # include <string.h> #else /* !HAVE_STRING_H */ @@ -40,6 +44,10 @@ #include "tilde.h" +#ifdef SHELL +#include "shell.h" +#endif + #if !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid (), *getpwnam (); #endif /* !HAVE_GETPW_DECLS */ @@ -78,6 +86,12 @@ static char *default_prefixes[] = static char *default_suffixes[] = { " ", "\n", (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; + /* 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 @@ -108,7 +122,7 @@ tilde_find_prefix (string, len) string_len = strlen (string); *len = 0; - if (!*string || *string == '~') + if (*string == '\0' || *string == '~') return (0); if (prefixes) @@ -135,13 +149,14 @@ tilde_find_suffix (string) char *string; { register int i, j, string_len; - register char **suffixes = tilde_additional_suffixes; + register char **suffixes; + suffixes = tilde_additional_suffixes; string_len = strlen (string); for (i = 0; i < string_len; i++) { - if (string[i] == '/' || !string[i]) + if (string[i] == '/' /* || !string[i] */) break; for (j = 0; suffixes && suffixes[j]; j++) @@ -153,16 +168,28 @@ tilde_find_suffix (string) return (i); } +#if !defined (SHELL) +static char * +get_string_value (varname) + char *varname; +{ + return ((char *)getenv (varname)); +} +#endif + /* Return a new string which is the result of tilde expanding STRING. */ char * tilde_expand (string) char *string; { - char *result, *tilde_expand_word (); + char *result; int result_size, result_index; - result_size = result_index = 0; - result = (char *)NULL; + result_index = result_size = 0; + if (result = strchr (string, '~')) + result = xmalloc (result_size = (strlen (string) + 16)); + else + result = xmalloc (result_size = strlen (string)); /* Scan through STRING expanding tildes as we come to them. */ while (1) @@ -215,97 +242,143 @@ tilde_expand (string) return (result); } +/* Take FNAME and return the tilde prefix we want expanded. If LENP is + non-null, the index of the end of the prefix into FNAME is returned in + the location it points to. */ +static char * +isolate_tilde_prefix (fname, lenp) + char *fname; + int *lenp; +{ + char *ret; + int i; + + ret = xmalloc (strlen (fname)); + for (i = 1; fname[i] && fname[i] != '/'; i++) + ret[i - 1] = fname[i]; + ret[i - 1] = '\0'; + if (lenp) + *lenp = i; + return ret; +} + +/* Return a string that is PREFIX concatenated with SUFFIX starting at + SUFFIND. */ +static char * +glue_prefix_and_suffix (prefix, suffix, suffind) + char *prefix, *suffix; + int suffind; +{ + char *ret; + int plen, slen; + + plen = (prefix && *prefix) ? strlen (prefix) : 0; + slen = strlen (suffix + suffind); + ret = xmalloc (plen + slen + 1); + if (prefix && *prefix) + strcpy (ret, prefix); + strcpy (ret + plen, suffix + suffind); + return ret; +} + +static char * +get_home_dir () +{ + char *home_dir; + +#ifdef SHELL + home_dir = (char *)NULL; + if (current_user.home_dir == 0) + get_current_user_info (); + home_dir = current_user.home_dir; +#else + struct passwd *entry; + + home_dir = (char *)NULL; + entry = getpwuid (getuid ()); + if (entry) + home_dir = entry->pw_dir; +#endif + return (home_dir); +} + /* Do the work of tilde expansion on FILENAME. FILENAME starts with a - tilde. If there is no expansion, call tilde_expansion_failure_hook. */ + tilde. If there is no expansion, call tilde_expansion_failure_hook. + This always returns a newly-allocated string, never static storage. */ char * tilde_expand_word (filename) char *filename; { - char *dirname; - char *temp_name; + char *dirname, *expansion, *username; + int user_len; + struct passwd *user_entry; - if (filename == (char *)0) + if (filename == 0) return ((char *)NULL); - dirname = savestring (filename); - - if (*dirname != '~') - return (dirname); + if (*filename != '~') + return (savestring (filename)); - if (!dirname[1] || dirname[1] == '/') + /* A leading `~/' or a bare `~' is *always* translated to the value of + $HOME or the home directory of the current user, regardless of any + preexpansion hook. */ + if (filename[1] == '\0' || filename[1] == '/') { - /* Prepend $HOME to the rest of the string. */ - char *temp_home = (char *)getenv ("HOME"); - int home_len; + /* Prefix $HOME to the rest of the string. */ + expansion = get_string_value ("HOME"); /* If there is no HOME variable, look up the directory in the password database. */ - if (!temp_home) - { - struct passwd *entry; - - entry = getpwuid (getuid ()); - if (entry) - temp_home = entry->pw_dir; - } + if (expansion == 0) + expansion = get_home_dir (); - home_len = temp_home ? strlen (temp_home) : 0; - temp_name = xmalloc (1 + strlen (dirname + 1) + home_len); - - if (temp_home) - strcpy (temp_name, temp_home); - strcpy (temp_name + home_len, dirname + 1); - free (dirname); - dirname = temp_name; + return (glue_prefix_and_suffix (expansion, filename, 1)); } - else - { - char *username; - struct passwd *user_entry; - int i, len; - username = xmalloc (strlen (dirname)); - for (i = 1; dirname[i] && dirname[i] != '/'; i++) - username[i - 1] = dirname[i]; - username[i - 1] = '\0'; + username = isolate_tilde_prefix (filename, &user_len); - if ((user_entry = getpwnam (username)) == (struct passwd *)0) + if (tilde_expansion_preexpansion_hook) + { + expansion = (*tilde_expansion_preexpansion_hook) (username); + if (expansion) { - /* If the calling program has a special syntax for - expanding tildes, and we couldn't find a standard - expansion, then let them try. */ - if (tilde_expansion_failure_hook) - { - char *expansion; - - expansion = (*tilde_expansion_failure_hook) (username); - - if (expansion) - { - len = strlen (expansion); - temp_name = xmalloc (1 + len + strlen (dirname + i)); - strcpy (temp_name, expansion); - strcpy (temp_name + len, dirname + i); - free (expansion); - free (dirname); - dirname = temp_name; - } - } - /* We shouldn't report errors. */ + dirname = glue_prefix_and_suffix (expansion, filename, user_len); + free (username); + free (expansion); + return (dirname); } - else + } + + /* No preexpansion hook, or the preexpansion hook failed. Look in the + password database. */ + dirname = (char *)NULL; + user_entry = getpwnam (username); + if (user_entry == 0) + { + /* If the calling program has a special syntax for expanding tildes, + and we couldn't find a standard expansion, then let them try. */ + if (tilde_expansion_failure_hook) { - len = strlen (user_entry->pw_dir); - temp_name = xmalloc (1 + len + strlen (dirname + i)); - strcpy (temp_name, user_entry->pw_dir); - strcpy (temp_name + len, dirname + i); - free (dirname); - dirname = temp_name; + expansion = (*tilde_expansion_failure_hook) (username); + if (expansion) + { + dirname = glue_prefix_and_suffix (expansion, filename, user_len); + free (expansion); + } } - endpwent (); free (username); + /* If we don't have a failure hook, or if the failure hook did not + expand the tilde, return a copy of what we were passed. */ + if (dirname == 0) + dirname = savestring (filename); + } + else + { + free (username); + dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); } + endpwent (); return (dirname); } diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h index 6f0898c..634b954 100644 --- a/lib/readline/tilde.h +++ b/lib/readline/tilde.h @@ -33,6 +33,12 @@ typedef char *CPFunction (); typedef char **CPPFunction (); #endif /* _FUNCTION_DEF */ +/* 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. */ +extern CPFunction *tilde_expansion_preexpansion_hook; + /* 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 diff --git a/lib/readline/undo.c b/lib/readline/undo.c index af7ccc3..28ebcc8 100644 --- a/lib/readline/undo.c +++ b/lib/readline/undo.c @@ -38,7 +38,6 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ -#include <setjmp.h> #include <stdio.h> /* System-specific feature definitions and include files. */ diff --git a/lib/readline/util.c b/lib/readline/util.c index f63293a..d96b29e 100644 --- a/lib/readline/util.c +++ b/lib/readline/util.c @@ -25,11 +25,9 @@ # include <config.h> #endif -#include <stdio.h> #include <sys/types.h> #include <fcntl.h> -#include <setjmp.h> -#include <ctype.h> +#include "posixjmp.h" #if defined (HAVE_UNISTD_H) # include <unistd.h> /* for _POSIX_VERSION */ @@ -41,6 +39,9 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ +#include <stdio.h> +#include <ctype.h> + /* System-specific feature definitions and include files. */ #include "rldefs.h" @@ -55,7 +56,7 @@ /* Pseudo-globals imported from readline.c */ extern int readline_echoing_p; -extern jmp_buf readline_top_level; +extern procenv_t readline_top_level; extern int rl_line_buffer_len; extern Function *rl_last_func; @@ -243,20 +244,6 @@ _rl_qsort_string_compare (s1, s2) #endif } -#if !defined (SHELL) -#ifdef savestring -#undef savestring -#endif -/* Backwards compatibility, now that savestring has been removed from - all `public' readline header files. */ -char * -savestring (s) - char *s; -{ - return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); -} -#endif /* !SHELL */ - /* Function equivalents for the macros defined in chartypes.h. */ #undef _rl_uppercase_p int |