From ead5fc05b9835be798994dfae32172fde03e9d74 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 28 Mar 2006 08:29:34 +0000 Subject: [PATCH 1/2] Remove unneded files from the vendor branch too Pointed by: ru --- contrib/libreadline/examples/rlfe.c | 1042 ------------------------- contrib/libreadline/support/wcwidth.c | 236 ------ 2 files changed, 1278 deletions(-) delete mode 100644 contrib/libreadline/examples/rlfe.c delete mode 100644 contrib/libreadline/support/wcwidth.c diff --git a/contrib/libreadline/examples/rlfe.c b/contrib/libreadline/examples/rlfe.c deleted file mode 100644 index d634d7ce878b..000000000000 --- a/contrib/libreadline/examples/rlfe.c +++ /dev/null @@ -1,1042 +0,0 @@ -/* A front-end using readline to "cook" input lines for Kawa. - * - * Copyright (C) 1999 Per Bothner - * - * This front-end program 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, or (at your option) - * any later version. - * - * Some code from Johnson & Troan: "Linux Application Development" - * (Addison-Wesley, 1998) was used directly or for inspiration. - */ - -/* PROBLEMS/TODO: - * - * Only tested under Linux; needs to be ported. - * - * When running mc -c under the Linux console, mc does not recognize - * mouse clicks, which mc does when not running under fep. - * - * Pasting selected text containing tabs is like hitting the tab character, - * which invokes readline completion. We don't want this. I don't know - * if this is fixable without integrating fep into a terminal emulator. - * - * Echo suppression is a kludge, but can only be avoided with better kernel - * support: We need a tty mode to disable "real" echoing, while still - * letting the inferior think its tty driver to doing echoing. - * Stevens's book claims SCR$ and BSD4.3+ have TIOCREMOTE. - * - * The latest readline may have some hooks we can use to avoid having - * to back up the prompt. - * - * Desirable readline feature: When in cooked no-echo mode (e.g. password), - * echo characters are they are types with '*', but remove them when done. - * - * A synchronous output while we're editing an input line should be - * inserted in the output view *before* the input line, so that the - * lines being edited (with the prompt) float at the end of the input. - * - * A "page mode" option to emulate more/less behavior: At each page of - * output, pause for a user command. This required parsing the output - * to keep track of line lengths. It also requires remembering the - * output, if we want an option to scroll back, which suggests that - * this should be integrated with a terminal emulator like xterm. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef READLINE_LIBRARY -# include "readline.h" -# include "history.h" -#else -# include -# include -#endif - -#ifndef COMMAND -#define COMMAND "/bin/sh" -#endif -#ifndef COMMAND_ARGS -#define COMMAND_ARGS COMMAND -#endif - -#ifndef HAVE_MEMMOVE -#ifndef memmove -# if __GNUC__ > 1 -# define memmove(d, s, n) __builtin_memcpy(d, s, n) -# else -# define memmove(d, s, n) memcpy(d, s, n) -# endif -#else -# define memmove(d, s, n) memcpy(d, s, n) -#endif -#endif - -#define APPLICATION_NAME "Rlfe" - -#ifndef errno -extern int errno; -#endif - -extern int optind; -extern char *optarg; - -static char *progname; -static char *progversion; - -static int in_from_inferior_fd; -static int out_to_inferior_fd; - -/* Unfortunately, we cannot safely display echo from the inferior process. - The reason is that the echo bit in the pty is "owned" by the inferior, - and if we try to turn it off, we could confuse the inferior. - Thus, when echoing, we get echo twice: First readline echoes while - we're actually editing. Then we send the line to the inferior, and the - terminal driver send back an extra echo. - The work-around is to remember the input lines, and when we see that - line come back, we supress the output. - A better solution (supposedly available on SVR4) would be a smarter - terminal driver, with more flags ... */ -#define ECHO_SUPPRESS_MAX 1024 -char echo_suppress_buffer[ECHO_SUPPRESS_MAX]; -int echo_suppress_start = 0; -int echo_suppress_limit = 0; - -/* #define DEBUG */ - -static FILE *logfile = NULL; - -#ifdef DEBUG -FILE *debugfile = NULL; -#define DPRINT0(FMT) (fprintf(debugfile, FMT), fflush(debugfile)) -#define DPRINT1(FMT, V1) (fprintf(debugfile, FMT, V1), fflush(debugfile)) -#define DPRINT2(FMT, V1, V2) (fprintf(debugfile, FMT, V1, V2), fflush(debugfile)) -#else -#define DPRINT0(FMT) /* Do nothing */ -#define DPRINT1(FMT, V1) /* Do nothing */ -#define DPRINT2(FMT, V1, V2) /* Do nothing */ -#endif - -struct termios orig_term; - -static int rlfe_directory_completion_hook __P((char **)); -static int rlfe_directory_rewrite_hook __P((char **)); -static char *rlfe_filename_completion_function __P((const char *, int)); - -/* Pid of child process. */ -static pid_t child = -1; - -static void -sig_child (int signo) -{ - int status; - wait (&status); - DPRINT0 ("(Child process died.)\n"); - tcsetattr(STDIN_FILENO, TCSANOW, &orig_term); - exit (0); -} - -volatile int propagate_sigwinch = 0; - -/* sigwinch_handler - * propagate window size changes from input file descriptor to - * master side of pty. - */ -void sigwinch_handler(int signal) { - propagate_sigwinch = 1; -} - -/* get_master_pty() takes a double-indirect character pointer in which - * to put a slave name, and returns an integer file descriptor. - * If it returns < 0, an error has occurred. - * Otherwise, it has returned the master pty file descriptor, and fills - * in *name with the name of the corresponding slave pty. - * Once the slave pty has been opened, you are responsible to free *name. - */ - -int get_master_pty(char **name) { - int i, j; - /* default to returning error */ - int master = -1; - - /* create a dummy name to fill in */ - *name = strdup("/dev/ptyXX"); - - /* search for an unused pty */ - for (i=0; i<16 && master <= 0; i++) { - for (j=0; j<16 && master <= 0; j++) { - (*name)[5] = 'p'; - (*name)[8] = "pqrstuvwxyzPQRST"[i]; - (*name)[9] = "0123456789abcdef"[j]; - /* open the master pty */ - if ((master = open(*name, O_RDWR)) < 0) { - if (errno == ENOENT) { - /* we are out of pty devices */ - free (*name); - return (master); - } - } - else { - /* By substituting a letter, we change the master pty - * name into the slave pty name. - */ - (*name)[5] = 't'; - if (access(*name, R_OK|W_OK) != 0) - { - close(master); - master = -1; - } - } - } - } - if ((master < 0) && (i == 16) && (j == 16)) { - /* must have tried every pty unsuccessfully */ - free (*name); - return (master); - } - - (*name)[5] = 't'; - - return (master); -} - -/* get_slave_pty() returns an integer file descriptor. - * If it returns < 0, an error has occurred. - * Otherwise, it has returned the slave file descriptor. - */ - -int get_slave_pty(char *name) { - struct group *gptr; - gid_t gid; - int slave = -1; - - /* chown/chmod the corresponding pty, if possible. - * This will only work if the process has root permissions. - * Alternatively, write and exec a small setuid program that - * does just this. - */ - if ((gptr = getgrnam("tty")) != 0) { - gid = gptr->gr_gid; - } else { - /* if the tty group does not exist, don't change the - * group on the slave pty, only the owner - */ - gid = -1; - } - - /* Note that we do not check for errors here. If this is code - * where these actions are critical, check for errors! - */ - chown(name, getuid(), gid); - /* This code only makes the slave read/writeable for the user. - * If this is for an interactive shell that will want to - * receive "write" and "wall" messages, OR S_IWGRP into the - * second argument below. - */ - chmod(name, S_IRUSR|S_IWUSR); - - /* open the corresponding slave pty */ - slave = open(name, O_RDWR); - return (slave); -} - -/* Certain special characters, such as ctrl/C, we want to pass directly - to the inferior, rather than letting readline handle them. */ - -static char special_chars[20]; -static int special_chars_count; - -static void -add_special_char(int ch) -{ - if (ch != 0) - special_chars[special_chars_count++] = ch; -} - -static int eof_char; - -static int -is_special_char(int ch) -{ - int i; -#if 0 - if (ch == eof_char && rl_point == rl_end) - return 1; -#endif - for (i = special_chars_count; --i >= 0; ) - if (special_chars[i] == ch) - return 1; - return 0; -} - -static char buf[1024]; -/* buf[0 .. buf_count-1] is the what has been emitted on the current line. - It is used as the readline prompt. */ -static int buf_count = 0; - -int num_keys = 0; - -static void -null_prep_terminal (int meta) -{ -} - -static void -null_deprep_terminal () -{ -} - -char pending_special_char; - -static void -line_handler (char *line) -{ - if (line == NULL) - { - char buf[1]; - DPRINT0("saw eof!\n"); - buf[0] = '\004'; /* ctrl/d */ - write (out_to_inferior_fd, buf, 1); - } - else - { - static char enter[] = "\r"; - /* Send line to inferior: */ - int length = strlen (line); - if (length > ECHO_SUPPRESS_MAX-2) - { - echo_suppress_start = 0; - echo_suppress_limit = 0; - } - else - { - if (echo_suppress_limit + length > ECHO_SUPPRESS_MAX - 2) - { - if (echo_suppress_limit - echo_suppress_start + length - <= ECHO_SUPPRESS_MAX - 2) - { - memmove (echo_suppress_buffer, - echo_suppress_buffer + echo_suppress_start, - echo_suppress_limit - echo_suppress_start); - echo_suppress_limit -= echo_suppress_start; - echo_suppress_start = 0; - } - else - { - echo_suppress_limit = 0; - } - echo_suppress_start = 0; - } - memcpy (echo_suppress_buffer + echo_suppress_limit, - line, length); - echo_suppress_limit += length; - echo_suppress_buffer[echo_suppress_limit++] = '\r'; - echo_suppress_buffer[echo_suppress_limit++] = '\n'; - } - write (out_to_inferior_fd, line, length); - if (pending_special_char == 0) - { - write (out_to_inferior_fd, enter, sizeof(enter)-1); - if (*line) - add_history (line); - } - free (line); - } - rl_callback_handler_remove (); - buf_count = 0; - num_keys = 0; - if (pending_special_char != 0) - { - write (out_to_inferior_fd, &pending_special_char, 1); - pending_special_char = 0; - } -} - -/* Value of rl_getc_function. - Use this because readline should read from stdin, not rl_instream, - points to the pty (so readline has monitor its terminal modes). */ - -int -my_rl_getc (FILE *dummy) -{ - int ch = rl_getc (stdin); - if (is_special_char (ch)) - { - pending_special_char = ch; - return '\r'; - } - return ch; -} - -static void -usage() -{ - fprintf (stderr, "%s: usage: %s [-l filename] [-a] [-n appname] [-hv] [command [arguments...]]\n", - progname, progname); -} - -int -main(int argc, char** argv) -{ - char *path; - int i, append; - int master; - char *name, *logfname, *appname; - int in_from_tty_fd; - struct sigaction act; - struct winsize ws; - struct termios t; - int maxfd; - fd_set in_set; - static char empty_string[1] = ""; - char *prompt = empty_string; - int ioctl_err = 0; - - if ((progname = strrchr (argv[0], '/')) == 0) - progname = argv[0]; - else - progname++; - progversion = RL_LIBRARY_VERSION; - - append = 0; - appname = APPLICATION_NAME; - logfname = (char *)NULL; - - while ((i = getopt (argc, argv, "ahl:n:v")) != EOF) - { - switch (i) - { - case 'l': - logfname = optarg; - break; - case 'n': - appname = optarg; - break; - case 'a': - append = 1; - break; - case 'h': - usage (); - exit (0); - case 'v': - fprintf (stderr, "%s version %s\n", progname, progversion); - exit (0); - default: - usage (); - exit (2); - } - } - - argc -= optind; - argv += optind; - - if (logfname) - { - logfile = fopen (logfname, append ? "a" : "w"); - if (logfile == 0) - fprintf (stderr, "%s: warning: could not open log file %s: %s\n", - progname, logfname, strerror (errno)); - } - - rl_readline_name = appname; - -#ifdef DEBUG - debugfile = fopen("LOG", "w"); -#endif - - if ((master = get_master_pty(&name)) < 0) - { - perror("ptypair: could not open master pty"); - exit(1); - } - - DPRINT1("pty name: '%s'\n", name); - - /* set up SIGWINCH handler */ - act.sa_handler = sigwinch_handler; - sigemptyset(&(act.sa_mask)); - act.sa_flags = 0; - if (sigaction(SIGWINCH, &act, NULL) < 0) - { - perror("ptypair: could not handle SIGWINCH "); - exit(1); - } - - if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) < 0) - { - perror("ptypair: could not get window size"); - exit(1); - } - - if ((child = fork()) < 0) - { - perror("cannot fork"); - exit(1); - } - - if (child == 0) - { - int slave; /* file descriptor for slave pty */ - - /* We are in the child process */ - close(master); - -#ifdef TIOCSCTTY - if ((slave = get_slave_pty(name)) < 0) - { - perror("ptypair: could not open slave pty"); - exit(1); - } - free(name); -#endif - - /* We need to make this process a session group leader, because - * it is on a new PTY, and things like job control simply will - * not work correctly unless there is a session group leader - * and process group leader (which a session group leader - * automatically is). This also disassociates us from our old - * controlling tty. - */ - if (setsid() < 0) - { - perror("could not set session leader"); - } - - /* Tie us to our new controlling tty. */ -#ifdef TIOCSCTTY - if (ioctl(slave, TIOCSCTTY, NULL)) - { - perror("could not set new controlling tty"); - } -#else - if ((slave = get_slave_pty(name)) < 0) - { - perror("ptypair: could not open slave pty"); - exit(1); - } - free(name); -#endif - - /* make slave pty be standard in, out, and error */ - dup2(slave, STDIN_FILENO); - dup2(slave, STDOUT_FILENO); - dup2(slave, STDERR_FILENO); - - /* at this point the slave pty should be standard input */ - if (slave > 2) - { - close(slave); - } - - /* Try to restore window size; failure isn't critical */ - if (ioctl(STDOUT_FILENO, TIOCSWINSZ, &ws) < 0) - { - perror("could not restore window size"); - } - - /* now start the shell */ - { - static char* command_args[] = { COMMAND_ARGS, NULL }; - if (argc < 1) - execvp(COMMAND, command_args); - else - execvp(argv[0], &argv[0]); - } - - /* should never be reached */ - exit(1); - } - - /* parent */ - signal (SIGCHLD, sig_child); - free(name); - - /* Note that we only set termios settings for standard input; - * the master side of a pty is NOT a tty. - */ - tcgetattr(STDIN_FILENO, &orig_term); - - t = orig_term; - eof_char = t.c_cc[VEOF]; - /* add_special_char(t.c_cc[VEOF]);*/ - add_special_char(t.c_cc[VINTR]); - add_special_char(t.c_cc[VQUIT]); - add_special_char(t.c_cc[VSUSP]); -#if defined (VDISCARD) - add_special_char(t.c_cc[VDISCARD]); -#endif - -#if 0 - t.c_lflag |= (ICANON | ISIG | ECHO | ECHOCTL | ECHOE | \ - ECHOK | ECHOKE | ECHONL | ECHOPRT ); -#else - t.c_lflag &= ~(ICANON | ISIG | ECHO | ECHOCTL | ECHOE | \ - ECHOK | ECHOKE | ECHONL | ECHOPRT ); -#endif - t.c_iflag |= IGNBRK; - t.c_cc[VMIN] = 1; - t.c_cc[VTIME] = 0; - tcsetattr(STDIN_FILENO, TCSANOW, &t); - in_from_inferior_fd = master; - out_to_inferior_fd = master; - rl_instream = fdopen (master, "r"); - rl_getc_function = my_rl_getc; - - rl_prep_term_function = null_prep_terminal; - rl_deprep_term_function = null_deprep_terminal; - rl_callback_handler_install (prompt, line_handler); - -#if 1 - rl_directory_completion_hook = rlfe_directory_completion_hook; - rl_completion_entry_function = rlfe_filename_completion_function; -#else - rl_directory_rewrite_hook = rlfe_directory_rewrite_hook; -#endif - - in_from_tty_fd = STDIN_FILENO; - FD_ZERO (&in_set); - maxfd = in_from_inferior_fd > in_from_tty_fd ? in_from_inferior_fd - : in_from_tty_fd; - for (;;) - { - int num; - FD_SET (in_from_inferior_fd, &in_set); - FD_SET (in_from_tty_fd, &in_set); - - num = select(maxfd+1, &in_set, NULL, NULL, NULL); - - if (propagate_sigwinch) - { - struct winsize ws; - if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) >= 0) - { - ioctl (master, TIOCSWINSZ, &ws); - } - propagate_sigwinch = 0; - continue; - } - - if (num <= 0) - { - perror ("select"); - exit (-1); - } - if (FD_ISSET (in_from_tty_fd, &in_set)) - { - extern int readline_echoing_p; - struct termios term_master; - int do_canon = 1; - int ioctl_ret; - - DPRINT1("[tty avail num_keys:%d]\n", num_keys); - - /* If we can't get tty modes for the master side of the pty, we - can't handle non-canonical-mode programs. Always assume the - master is in canonical echo mode if we can't tell. */ - ioctl_ret = tcgetattr(master, &term_master); - - if (ioctl_ret >= 0) - { - DPRINT2 ("echo:%d, canon:%d\n", - (term_master.c_lflag & ECHO) != 0, - (term_master.c_lflag & ICANON) != 0); - do_canon = (term_master.c_lflag & ICANON) != 0; - readline_echoing_p = (term_master.c_lflag & ECHO) != 0; - } - else - { - if (ioctl_err == 0) - DPRINT1("tcgetattr on master fd failed: errno = %d\n", errno); - ioctl_err = 1; - } - - if (do_canon == 0 && num_keys == 0) - { - char ch[10]; - int count = read (STDIN_FILENO, ch, sizeof(ch)); - write (out_to_inferior_fd, ch, count); - } - else - { - if (num_keys == 0) - { - int i; - /* Re-install callback handler for new prompt. */ - if (prompt != empty_string) - free (prompt); - prompt = malloc (buf_count + 1); - if (prompt == NULL) - prompt = empty_string; - else - { - memcpy (prompt, buf, buf_count); - prompt[buf_count] = '\0'; - DPRINT1("New prompt '%s'\n", prompt); -#if 0 /* ifdef HAVE_RL_ALREADY_PROMPTED -- doesn't work */ - rl_already_prompted = buf_count > 0; -#else - if (buf_count > 0) - write (1, "\r", 1); -#endif - } - rl_callback_handler_install (prompt, line_handler); - } - num_keys++; - rl_callback_read_char (); - } - } - else /* input from inferior. */ - { - int i; - int count; - int old_count; - if (buf_count > (sizeof(buf) >> 2)) - buf_count = 0; - count = read (in_from_inferior_fd, buf+buf_count, - sizeof(buf) - buf_count); - if (count <= 0) - { - DPRINT0 ("(Connection closed by foreign host.)\n"); - tcsetattr(STDIN_FILENO, TCSANOW, &orig_term); - exit (0); - } - old_count = buf_count; - - /* Do some minimal carriage return translation and backspace - processing before logging the input line. */ - if (logfile) - { -#ifndef __GNUC__ - char *b; -#else - char b[count + 1]; -#endif - int i, j; - -#ifndef __GNUC__ - b = malloc (count + 1); - if (b) { -#endif - for (i = 0; i < count; i++) - b[i] = buf[buf_count + i]; - b[i] = '\0'; - for (i = j = 0; i <= count; i++) - { - if (b[i] == '\r') - { - if (b[i+1] != '\n') - b[j++] = '\n'; - } - else if (b[i] == '\b') - { - if (i) - j--; - } - else - b[j++] = b[i]; - } - fprintf (logfile, "%s", b); - -#ifndef __GNUC__ - free (b); - } -#endif - } - - /* Look for any pending echo that we need to suppress. */ - while (echo_suppress_start < echo_suppress_limit - && count > 0 - && buf[buf_count] == echo_suppress_buffer[echo_suppress_start]) - { - count--; - buf_count++; - echo_suppress_start++; - } - - /* Write to the terminal anything that was not suppressed. */ - if (count > 0) - write (1, buf + buf_count, count); - - /* Finally, look for a prompt candidate. - * When we get around to going input (from the keyboard), - * we will consider the prompt to be anything since the last - * line terminator. So we need to save that text in the - * initial part of buf. However, anything before the - * most recent end-of-line is not interesting. */ - buf_count += count; -#if 1 - for (i = buf_count; --i >= old_count; ) -#else - for (i = buf_count - 1; i-- >= buf_count - count; ) -#endif - { - if (buf[i] == '\n' || buf[i] == '\r') - { - i++; - memmove (buf, buf+i, buf_count - i); - buf_count -= i; - break; - } - } - DPRINT2("-> i: %d, buf_count: %d\n", i, buf_count); - } - } -} - -/* - * - * FILENAME COMPLETION FOR RLFE - * - */ - -#ifndef PATH_MAX -# define PATH_MAX 1024 -#endif - -#define DIRSEP '/' -#define ISDIRSEP(x) ((x) == '/') -#define PATHSEP(x) (ISDIRSEP(x) || (x) == 0) - -#define DOT_OR_DOTDOT(x) \ - ((x)[0] == '.' && (PATHSEP((x)[1]) || \ - ((x)[1] == '.' && PATHSEP((x)[2])))) - -#define FREE(x) if (x) free(x) - -#define STRDUP(s, x) do { \ - s = strdup (x);\ - if (s == 0) \ - return ((char *)NULL); \ - } while (0) - -static int -get_inferior_cwd (path, psize) - char *path; - size_t psize; -{ - int n; - static char procfsbuf[PATH_MAX] = { '\0' }; - - if (procfsbuf[0] == '\0') - sprintf (procfsbuf, "/proc/%d/cwd", (int)child); - n = readlink (procfsbuf, path, psize); - if (n < 0) - return n; - if (n > psize) - return -1; - path[n] = '\0'; - return n; -} - -static int -rlfe_directory_rewrite_hook (dirnamep) - char **dirnamep; -{ - char *ldirname, cwd[PATH_MAX], *retdir, *ld; - int n, ldlen; - - ldirname = *dirnamep; - - if (*ldirname == '/') - return 0; - - n = get_inferior_cwd (cwd, sizeof(cwd) - 1); - if (n < 0) - return 0; - if (n == 0) /* current directory */ - { - cwd[0] = '.'; - cwd[1] = '\0'; - n = 1; - } - - /* Minimally canonicalize ldirname by removing leading `./' */ - for (ld = ldirname; *ld; ) - { - if (ISDIRSEP (ld[0])) - ld++; - else if (ld[0] == '.' && PATHSEP(ld[1])) - ld++; - else - break; - } - ldlen = (ld && *ld) ? strlen (ld) : 0; - - retdir = (char *)malloc (n + ldlen + 3); - if (retdir == 0) - return 0; - if (ldlen) - sprintf (retdir, "%s/%s", cwd, ld); - else - strcpy (retdir, cwd); - free (ldirname); - - *dirnamep = retdir; - - DPRINT1("rl_directory_rewrite_hook returns %s\n", retdir); - return 1; -} - -/* Translate *DIRNAMEP to be relative to the inferior's CWD. Leave a trailing - slash on the result. */ -static int -rlfe_directory_completion_hook (dirnamep) - char **dirnamep; -{ - char *ldirname, *retdir; - int n, ldlen; - - ldirname = *dirnamep; - - if (*ldirname == '/') - return 0; - - n = rlfe_directory_rewrite_hook (dirnamep); - if (n == 0) - return 0; - - ldirname = *dirnamep; - ldlen = (ldirname && *ldirname) ? strlen (ldirname) : 0; - - if (ldlen == 0 || ldirname[ldlen - 1] != '/') - { - retdir = (char *)malloc (ldlen + 3); - if (retdir == 0) - return 0; - if (ldlen) - strcpy (retdir, ldirname); - else - retdir[ldlen++] = '.'; - retdir[ldlen] = '/'; - retdir[ldlen+1] = '\0'; - free (ldirname); - - *dirnamep = retdir; - } - - DPRINT1("rl_directory_completion_hook returns %s\n", retdir); - return 1; -} - -static char * -rlfe_filename_completion_function (text, state) - const char *text; - int state; -{ - static DIR *directory; - static char *filename = (char *)NULL; - static char *dirname = (char *)NULL, *ud = (char *)NULL; - static int flen, udlen; - char *temp; - struct dirent *dentry; - - if (state == 0) - { - if (directory) - { - closedir (directory); - directory = 0; - } - FREE (dirname); - FREE (filename); - FREE (ud); - - if (text && *text) - STRDUP (filename, text); - else - { - filename = malloc(1); - if (filename == 0) - return ((char *)NULL); - filename[0] = '\0'; - } - dirname = (text && *text) ? strdup (text) : strdup ("."); - if (dirname == 0) - return ((char *)NULL); - - temp = strrchr (dirname, '/'); - if (temp) - { - strcpy (filename, ++temp); - *temp = '\0'; - } - else - { - dirname[0] = '.'; - dirname[1] = '\0'; - } - - STRDUP (ud, dirname); - udlen = strlen (ud); - - rlfe_directory_completion_hook (&dirname); - - directory = opendir (dirname); - flen = strlen (filename); - - rl_filename_completion_desired = 1; - } - - dentry = 0; - while (directory && (dentry = readdir (directory))) - { - if (flen == 0) - { - if (DOT_OR_DOTDOT(dentry->d_name) == 0) - break; - } - else - { - if ((dentry->d_name[0] == filename[0]) && - (strlen (dentry->d_name) >= flen) && - (strncmp (filename, dentry->d_name, flen) == 0)) - break; - } - } - - if (dentry == 0) - { - if (directory) - { - closedir (directory); - directory = 0; - } - FREE (dirname); - FREE (filename); - FREE (ud); - dirname = filename = ud = 0; - return ((char *)NULL); - } - - if (ud == 0 || (ud[0] == '.' && ud[1] == '\0')) - temp = strdup (dentry->d_name); - else - { - temp = malloc (1 + udlen + strlen (dentry->d_name)); - strcpy (temp, ud); - strcpy (temp + udlen, dentry->d_name); - } - return (temp); -} diff --git a/contrib/libreadline/support/wcwidth.c b/contrib/libreadline/support/wcwidth.c deleted file mode 100644 index ace9a3ab92c0..000000000000 --- a/contrib/libreadline/support/wcwidth.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * This is an implementation of wcwidth() and wcswidth() as defined in - * "The Single UNIX Specification, Version 2, The Open Group, 1997" - * - * - * Markus Kuhn -- 2001-09-08 -- public domain - */ - -#include - -struct interval { - unsigned short first; - unsigned short last; -}; - -/* auxiliary function for binary search in interval table */ -static int bisearch(wchar_t ucs, const struct interval *table, int max) { - int min = 0; - int mid; - - if (ucs < table[0].first || ucs > table[max].last) - return 0; - while (max >= min) { - mid = (min + max) / 2; - if (ucs > table[mid].last) - min = mid + 1; - else if (ucs < table[mid].first) - max = mid - 1; - else - return 1; - } - - return 0; -} - - -/* The following functions define the column width of an ISO 10646 - * character as follows: - * - * - The null character (U+0000) has a column width of 0. - * - * - Other C0/C1 control characters and DEL will lead to a return - * value of -1. - * - * - Non-spacing and enclosing combining characters (general - * category code Mn or Me in the Unicode database) have a - * column width of 0. - * - * - Other format characters (general category code Cf in the Unicode - * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. - * - * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) - * have a column width of 0. - * - * - Spacing characters in the East Asian Wide (W) or East Asian - * FullWidth (F) category as defined in Unicode Technical - * Report #11 have a column width of 2. - * - * - All remaining characters (including all printable - * ISO 8859-1 and WGL4 characters, Unicode control characters, - * etc.) have a column width of 1. - * - * This implementation assumes that wchar_t characters are encoded - * in ISO 10646. - */ - -int wcwidth(wchar_t ucs) -{ - /* sorted list of non-overlapping intervals of non-spacing characters */ - static const struct interval combining[] = { - { 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 }, - { 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 }, - { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, - { 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 }, - { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, - { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, - { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C }, - { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 }, - { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, - { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, - { 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 }, - { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 }, - { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, - { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 }, - { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, - { 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, - { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, - { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, - { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, - { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, - { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, - { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, - { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, - { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, - { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, - { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, - { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, - { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, - { 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, - { 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 }, - { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F }, - { 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A }, - { 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, - { 0xFFF9, 0xFFFB } - }; - - /* test for 8-bit control characters */ - if (ucs == 0) - return 0; - if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) - return -1; - - /* binary search in table of non-spacing characters */ - if (bisearch(ucs, combining, - sizeof(combining) / sizeof(struct interval) - 1)) - return 0; - - /* if we arrive here, ucs is not a combining or C0/C1 control character */ - - return 1 + - (ucs >= 0x1100 && - (ucs <= 0x115f || /* Hangul Jamo init. consonants */ - (ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a && - ucs != 0x303f) || /* CJK ... Yi */ - (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ - (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ - (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ - (ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */ - (ucs >= 0xffe0 && ucs <= 0xffe6) || - (ucs >= 0x20000 && ucs <= 0x2ffff))); -} - - -int wcswidth(const wchar_t *pwcs, size_t n) -{ - int w, width = 0; - - for (;*pwcs && n-- > 0; pwcs++) - if ((w = wcwidth(*pwcs)) < 0) - return -1; - else - width += w; - - return width; -} - - -/* - * The following function is the same as wcwidth(), except that - * spacing characters in the East Asian Ambiguous (A) category as - * defined in Unicode Technical Report #11 have a column width of 2. - * This experimental variant might be useful for users of CJK legacy - * encodings who want to migrate to UCS. It is not otherwise - * recommended for general use. - */ -static int wcwidth_cjk(wchar_t ucs) -{ - /* sorted list of non-overlapping intervals of East Asian Ambiguous - * characters */ - static const struct interval ambiguous[] = { - { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, - { 0x00AA, 0x00AA }, { 0x00AD, 0x00AE }, { 0x00B0, 0x00B4 }, - { 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 }, - { 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 }, - { 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED }, - { 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA }, - { 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 }, - { 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B }, - { 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 }, - { 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 }, - { 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 }, - { 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE }, - { 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 }, - { 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA }, - { 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 }, - { 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB }, - { 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB }, - { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0300, 0x034E }, - { 0x0360, 0x0362 }, { 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 }, - { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, { 0x0401, 0x0401 }, - { 0x0410, 0x044F }, { 0x0451, 0x0451 }, { 0x2010, 0x2010 }, - { 0x2013, 0x2016 }, { 0x2018, 0x2019 }, { 0x201C, 0x201D }, - { 0x2020, 0x2022 }, { 0x2024, 0x2027 }, { 0x2030, 0x2030 }, - { 0x2032, 0x2033 }, { 0x2035, 0x2035 }, { 0x203B, 0x203B }, - { 0x203E, 0x203E }, { 0x2074, 0x2074 }, { 0x207F, 0x207F }, - { 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, { 0x2103, 0x2103 }, - { 0x2105, 0x2105 }, { 0x2109, 0x2109 }, { 0x2113, 0x2113 }, - { 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 }, - { 0x212B, 0x212B }, { 0x2153, 0x2155 }, { 0x215B, 0x215E }, - { 0x2160, 0x216B }, { 0x2170, 0x2179 }, { 0x2190, 0x2199 }, - { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 }, - { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, { 0x2202, 0x2203 }, - { 0x2207, 0x2208 }, { 0x220B, 0x220B }, { 0x220F, 0x220F }, - { 0x2211, 0x2211 }, { 0x2215, 0x2215 }, { 0x221A, 0x221A }, - { 0x221D, 0x2220 }, { 0x2223, 0x2223 }, { 0x2225, 0x2225 }, - { 0x2227, 0x222C }, { 0x222E, 0x222E }, { 0x2234, 0x2237 }, - { 0x223C, 0x223D }, { 0x2248, 0x2248 }, { 0x224C, 0x224C }, - { 0x2252, 0x2252 }, { 0x2260, 0x2261 }, { 0x2264, 0x2267 }, - { 0x226A, 0x226B }, { 0x226E, 0x226F }, { 0x2282, 0x2283 }, - { 0x2286, 0x2287 }, { 0x2295, 0x2295 }, { 0x2299, 0x2299 }, - { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, { 0x2312, 0x2312 }, - { 0x2329, 0x232A }, { 0x2460, 0x24BF }, { 0x24D0, 0x24E9 }, - { 0x2500, 0x254B }, { 0x2550, 0x2574 }, { 0x2580, 0x258F }, - { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, - { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, - { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, - { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, - { 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F }, - { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 }, - { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 }, - { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F }, - { 0x273D, 0x273D }, { 0x3008, 0x300B }, { 0x3014, 0x3015 }, - { 0x3018, 0x301B }, { 0xFFFD, 0xFFFD } - }; - - /* binary search in table of non-spacing characters */ - if (bisearch(ucs, ambiguous, - sizeof(ambiguous) / sizeof(struct interval) - 1)) - return 2; - - return wcwidth(ucs); -} - - -int wcswidth_cjk(const wchar_t *pwcs, size_t n) -{ - int w, width = 0; - - for (;*pwcs && n-- > 0; pwcs++) - if ((w = wcwidth_cjk(*pwcs)) < 0) - return -1; - else - width += w; - - return width; -} From 0e6bca45b1aeb189311204a2b5d10ca61fdf4ae3 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 31 Dec 2006 09:06:30 +0000 Subject: [PATCH 2/2] Virgin import of GNU Readline 5.2 --- contrib/libreadline/CHANGELOG | 40 + contrib/libreadline/CHANGES | 74 ++ contrib/libreadline/FREEBSD-upgrade | 12 +- contrib/libreadline/INSTALL | 2 +- contrib/libreadline/NEWS | 35 +- contrib/libreadline/README | 4 +- contrib/libreadline/aclocal.m4 | 84 +- contrib/libreadline/bind.c | 94 ++- contrib/libreadline/callback.c | 122 ++- contrib/libreadline/complete.c | 38 +- contrib/libreadline/config.h.in | 36 +- contrib/libreadline/configure | 728 ++++++++++++++---- contrib/libreadline/configure.in | 7 +- contrib/libreadline/display.c | 210 +++-- contrib/libreadline/doc/history.texi | 4 +- contrib/libreadline/doc/hstech.texi | 2 +- contrib/libreadline/doc/hsuser.texi | 2 +- contrib/libreadline/doc/readline.3 | 8 +- contrib/libreadline/doc/rlman.texi | 4 +- contrib/libreadline/doc/rltech.texi | 11 +- contrib/libreadline/doc/rluser.texi | 14 +- contrib/libreadline/doc/rluserman.texi | 4 +- contrib/libreadline/doc/version.texi | 12 +- contrib/libreadline/examples/excallback.c | 3 + contrib/libreadline/examples/rlfe/Makefile.in | 2 +- contrib/libreadline/histexpand.c | 12 +- contrib/libreadline/histfile.c | 6 +- contrib/libreadline/history.c | 87 ++- contrib/libreadline/input.c | 27 +- contrib/libreadline/isearch.c | 4 +- contrib/libreadline/kill.c | 1 + contrib/libreadline/macro.c | 2 +- contrib/libreadline/misc.c | 2 + contrib/libreadline/readline.c | 19 + contrib/libreadline/readline.h | 8 +- contrib/libreadline/rlconf.h | 5 +- contrib/libreadline/rlmbutil.h | 13 +- contrib/libreadline/rlprivate.h | 5 + contrib/libreadline/rltty.c | 1 - contrib/libreadline/search.c | 3 +- contrib/libreadline/signals.c | 42 +- contrib/libreadline/support/shlib-install | 3 +- contrib/libreadline/support/shobj-conf | 17 + contrib/libreadline/terminal.c | 50 +- contrib/libreadline/text.c | 30 +- contrib/libreadline/tilde.c | 10 +- contrib/libreadline/undo.c | 74 +- contrib/libreadline/vi_mode.c | 61 +- 48 files changed, 1524 insertions(+), 510 deletions(-) diff --git a/contrib/libreadline/CHANGELOG b/contrib/libreadline/CHANGELOG index b6499c3b7162..c64d959376a8 100644 --- a/contrib/libreadline/CHANGELOG +++ b/contrib/libreadline/CHANGELOG @@ -918,3 +918,43 @@ configure.in - changed release status to `release' [readline-5.1 frozen] + + 12/9 + ---- +[readline-5.1 released] + + 12/14 + ----- +examples/rlfe/Makefile.in + - add @LIBS@ to LIBS assignment to pick up extra libraries from + configure + + 1/3/2006 + -------- +support/shlib-install + - Install shared libraries with execute bit set on Linux + + 6/9 + --- +[readline-5.2-alpha frozen] + + 6/26 + ---- +configure.in + - set CROSS_COMPILE to the empty string by default, so we don't inherit + a random value from the environment + + 7/8 + --- +[readline-5.2-alpha released] + + +[readline-5.2-beta released] + + 9/12 + ---- +config.h.in + - add defines for wcscoll, iswctype, iswupper, iswlower, towupper, + towlower functions + - replace define for wctomb with one for wcrtomb + - add defines for wchar_t, wint_t, wctype_t types diff --git a/contrib/libreadline/CHANGES b/contrib/libreadline/CHANGES index 1ba0c1256df4..87e01e14091d 100644 --- a/contrib/libreadline/CHANGES +++ b/contrib/libreadline/CHANGES @@ -1,3 +1,77 @@ +This document details the changes between this version, readline-5.2, +and the previous version, readline-5.1. + +1. Changes to Readline + +a. Fixed a problem that caused segmentation faults when using readline in + callback mode and typing consecutive DEL characters on an empty line. + +b. Fixed several redisplay problems with multibyte characters, all having to + do with the different code paths and variable meanings between single-byte + and multibyte character redisplay. + +c. Fixed a problem with key sequence translation when presented with the + sequence \M-\C-x. + +d. Fixed a problem that prevented the `a' command in vi mode from being + undone and redone properly. + +e. Fixed a problem that prevented empty inserts in vi mode from being undone + properly. + +f. Fixed a problem that caused readline to initialize with an incorrect idea + of whether or not the terminal can autowrap. + +g. Fixed output of key bindings (like bash `bind -p') to honor the setting of + convert-meta and use \e where appropriate. + +h. Changed the default filename completion function to call the filename + dequoting function if the directory completion hook isn't set. This means + that any directory completion hooks need to dequote the directory name, + since application-specific hooks need to know how the word was quoted, + even if no other changes are made. + +i. Fixed a bug with creating the prompt for a non-interactive search string + when there are non-printing characters in the primary prompt. + +j. Fixed a bug that caused prompts with invisible characters to be redrawn + multiple times in a multibyte locale. + +k. Fixed a bug that could cause the key sequence scanning code to return the + wrong function. + +l. Fixed a problem with the callback interface that caused it to fail when + using multi-character keyboard macros. + +m. Fixed a bug that could cause a core dump when an edited history entry was + re-executed under certain conditions. + +n. Fixed a bug that caused readline to reference freed memory when attmpting + to display a portion of the prompt. + +o. Fixed a bug with prompt redisplay in a multi-byte locale to avoid redrawing + the prompt and input line multiple times. + +p. Fixed history expansion to not be confused by here-string redirection. + +q. Readline no longer treats read errors by converting them to newlines, as + it does with EOF. This caused partial lines to be returned from readline(). + +r. Fixed a redisplay bug that occurred in multibyte-capable locales when the + prompt was one character longer than the screen width. + +2. New Features in Readline + +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. + +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. + +c. The history file reading functions now allow windows-like \r\n line + terminators. + +------------------------------------------------------------------------------- This document details the changes between this version, readline-5.1, and the previous version, readline-5.0. diff --git a/contrib/libreadline/FREEBSD-upgrade b/contrib/libreadline/FREEBSD-upgrade index a90085e5dc3a..83721183a043 100644 --- a/contrib/libreadline/FREEBSD-upgrade +++ b/contrib/libreadline/FREEBSD-upgrade @@ -1,3 +1,9 @@ -mv doc/readline.3 . -rm doc/*.dvi doc/*.html doc/*.ps doc/*.0 doc/*.info doc/*.tex doc/texi2* -rm savestring.c +# $FreeBSD$ +# + +rm doc/*.dvi doc/*.html doc/*.ps doc/*.0 doc/*.info doc/*.tex doc/texi2* doc/*.pdf +rm savestring.c support/wcwidth.c + +cvs import \ + -m "Virgin import of GNU Readline 5.2" \ + src/contrib/libreadline FSF v5_2 diff --git a/contrib/libreadline/INSTALL b/contrib/libreadline/INSTALL index 1a73c779000d..f360b9e7907a 100644 --- a/contrib/libreadline/INSTALL +++ b/contrib/libreadline/INSTALL @@ -1,7 +1,7 @@ Basic Installation ================== -These are installation instructions for Readline-5.1. +These are installation instructions for Readline-5.2. The simplest way to compile readline is: diff --git a/contrib/libreadline/NEWS b/contrib/libreadline/NEWS index c5e67dc793fa..96711a00264c 100644 --- a/contrib/libreadline/NEWS +++ b/contrib/libreadline/NEWS @@ -1,32 +1,13 @@ -This is a terse description of the new features added to readline-5.1 since -the release of readline-5.0. +This is a terse description of the new features added to readline-5.2 since +the release of readline-5.1. 1. New Features in Readline -a. The key sequence sent by the keypad `delete' key is now automatically - bound to delete-char. +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. -b. A negative argument to menu-complete now cycles backward through the - completion list. +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. -c. A new bindable readline variable: bind-tty-special-chars. If non-zero, - readline will bind the terminal special characters to their readline - equivalents when it's called (on by default). - -d. New bindable command: vi-rubout. Saves deleted text for possible - reinsertion, as with any vi-mode `text modification' command; `X' is bound - to this in vi command mode. - -e. If the rl_completion_query_items is set to a value < 0, readline never - asks the user whether or not to view the possible completions. - -f. New application-callable auxiliary function, rl_variable_value, returns - a string corresponding to a readline variable's value. - -g. When parsing inputrc files and variable binding commands, the parser - strips trailing whitespace from values assigned to boolean variables - before checking them. - -h. A new external application-controllable variable that allows the LINES - and COLUMNS environment variables to set the window size regardless of - what the kernel returns. +c. The history file reading functions now allow windows-like \r\n line + terminators. diff --git a/contrib/libreadline/README b/contrib/libreadline/README index 8dd09cc5373c..8da99626aa1a 100644 --- a/contrib/libreadline/README +++ b/contrib/libreadline/README @@ -1,7 +1,7 @@ Introduction ============ -This is the Gnu Readline library, version 5.1. +This is the Gnu Readline library, version 5.2. The Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both @@ -183,4 +183,4 @@ list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains Readline bug reports and fixes. Chet Ramey -chet@po.cwru.edu +chet.ramey@case.edu diff --git a/contrib/libreadline/aclocal.m4 b/contrib/libreadline/aclocal.m4 index 8a700845d5fa..eda151c03008 100644 --- a/contrib/libreadline/aclocal.m4 +++ b/contrib/libreadline/aclocal.m4 @@ -933,7 +933,7 @@ AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS) fi ]) -AC_DEFUN(BASH_CHECK_LIB_TERMCAP, +AC_DEFUN([BASH_CHECK_LIB_TERMCAP], [ if test "X$bash_cv_termcap_lib" = "X"; then _bash_needmsg=yes @@ -1540,20 +1540,24 @@ fi AC_DEFUN(BASH_CHECK_DEV_FD, [AC_MSG_CHECKING(whether /dev/fd is available) AC_CACHE_VAL(bash_cv_dev_fd, -[if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then +[bash_cv_dev_fd="" +if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then # check for systems like FreeBSD 5 that only provide /dev/fd/[012] - exec 3<&0 + exec 3], [ - mbstate_t ps; - mbstate_t *psp; - psp = (mbstate_t *)0; -], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)]) -if test $bash_cv_have_mbstate_t = yes; then +AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB)) +AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL)) +AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP)) +AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH)) +AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE)) + +dnl checks for both mbrtowc and mbstate_t +AC_FUNC_MBRTOWC +if test $ac_cv_func_mbrtowc = yes; then AC_DEFINE(HAVE_MBSTATE_T) fi +AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype) + AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset, [AC_TRY_LINK( [#include ], @@ -1700,6 +1705,43 @@ if test $bash_cv_langinfo_codeset = yes; then AC_DEFINE(HAVE_LANGINFO_CODESET) fi +dnl check for wchar_t in +AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t, +[AC_TRY_COMPILE( +[#include +], +[ + wchar_t foo; + foo = 0; +], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)]) +if test $bash_cv_type_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here]) +fi + +dnl check for wctype_t in +AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t, +[AC_TRY_COMPILE( +[#include ], +[ + wctype_t foo; + foo = 0; +], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)]) +if test $bash_cv_type_wctype_t = yes; then + AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]) +fi + +dnl check for wint_t in +AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t, +[AC_TRY_COMPILE( +[#include ], +[ + wint_t foo; + foo = 0; +], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)]) +if test $bash_cv_type_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]) +fi + ]) dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB @@ -1707,7 +1749,7 @@ dnl require: dnl AC_PROG_CC dnl BASH_CHECK_LIB_TERMCAP -AC_DEFUN(RL_LIB_READLINE_VERSION, +AC_DEFUN([RL_LIB_READLINE_VERSION], [ AC_REQUIRE([BASH_CHECK_LIB_TERMCAP]) diff --git a/contrib/libreadline/bind.c b/contrib/libreadline/bind.c index 7559d32f6b36..08c906bfcc33 100644 --- a/contrib/libreadline/bind.c +++ b/contrib/libreadline/bind.c @@ -1,6 +1,6 @@ /* bind.c -- key binding and startup file support for the readline library. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2006 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. @@ -370,7 +370,10 @@ rl_generic_bind (type, keyseq, data, map) ic = uc; if (ic < 0 || ic >= KEYMAP_SIZE) - return -1; + { + free (keys); + return -1; + } if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) { @@ -462,12 +465,21 @@ rl_translate_keyseq (seq, array, len) } else if (c == 'M') { - i++; - /* XXX - should obey convert-meta setting? */ + i++; /* seq[i] == '-' */ + /* XXX - obey convert-meta setting */ if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP) array[l++] = ESC; /* ESC is meta-prefix */ + else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-') + { + i += 4; + temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i])); + array[l++] = META (temp); + } else { + /* This doesn't yet handle things like \M-\a, which may + or may not have any reasonable meaning. You're + probably better off using straight octal or hex. */ i++; array[l++] = META (seq[i]); } @@ -565,6 +577,11 @@ rl_untranslate_keyseq (seq) kseq[i++] = '-'; c = UNMETA (c); } + else if (c == ESC) + { + kseq[i++] = '\\'; + c = 'e'; + } else if (CTRL_CHAR (c)) { kseq[i++] = '\\'; @@ -613,7 +630,12 @@ _rl_untranslate_macro_value (seq) *r++ = '-'; c = UNMETA (c); } - else if (CTRL_CHAR (c) && c != ESC) + else if (c == ESC) + { + *r++ = '\\'; + c = 'e'; + } + else if (CTRL_CHAR (c)) { *r++ = '\\'; *r++ = 'C'; @@ -672,7 +694,7 @@ rl_function_of_keyseq (keyseq, map, type) { register int i; - if (!map) + if (map == 0) map = _rl_keymap; for (i = 0; keyseq && keyseq[i]; i++) @@ -681,25 +703,27 @@ rl_function_of_keyseq (keyseq, map, type) if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) { - if (map[ESC].type != ISKMAP) + if (map[ESC].type == ISKMAP) + { + map = FUNCTION_TO_KEYMAP (map, ESC); + ic = UNMETA (ic); + } + /* XXX - should we just return NULL here, since this obviously + doesn't match? */ + else { if (type) *type = map[ESC].type; return (map[ESC].function); } - else - { - map = FUNCTION_TO_KEYMAP (map, ESC); - ic = UNMETA (ic); - } } if (map[ic].type == ISKMAP) { /* If this is the last key in the key sequence, return the map. */ - if (!keyseq[i + 1]) + if (keyseq[i + 1] == '\0') { if (type) *type = ISKMAP; @@ -709,7 +733,12 @@ rl_function_of_keyseq (keyseq, map, type) else map = FUNCTION_TO_KEYMAP (map, ic); } - else + /* If we're not at the end of the key sequence, and the current key + is bound to something other than a keymap, then the entire key + sequence is not bound. */ + else if (map[ic].type != ISKMAP && keyseq[i+1]) + return ((rl_command_func_t *)NULL); + else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */ { if (type) *type = map[ic].type; @@ -791,6 +820,7 @@ rl_re_read_init_file (count, ignore) 1. the filename used for the previous call 2. the value of the shell variable `INPUTRC' 3. ~/.inputrc + 4. /etc/inputrc If the file existed and could be opened and read, 0 is returned, otherwise errno is returned. */ int @@ -799,17 +829,18 @@ rl_read_init_file (filename) { /* Default the filename. */ if (filename == 0) + filename = last_readline_init_file; + if (filename == 0) + filename = sh_get_env_value ("INPUTRC"); + if (filename == 0 || *filename == 0) { - filename = last_readline_init_file; - if (filename == 0) - filename = sh_get_env_value ("INPUTRC"); - if (filename == 0) - filename = DEFAULT_INPUTRC; + filename = DEFAULT_INPUTRC; + /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */ + if (_rl_read_init_file (filename, 0) == 0) + return 0; + filename = SYS_INPUTRC; } - if (*filename == 0) - filename = DEFAULT_INPUTRC; - #if defined (__MSDOS__) if (_rl_read_init_file (filename, 0) == 0) return 0; @@ -1506,8 +1537,6 @@ rl_variable_value (name) const char *name; { register int i; - int v; - char *ret; /* Check for simple variables first. */ i = find_boolean_var (name); @@ -1948,12 +1977,16 @@ rl_invoking_keyseqs_in_map (function, map) char *keyname = (char *)xmalloc (6 + strlen (seqs[i])); if (key == ESC) -#if 0 - sprintf (keyname, "\\e"); -#else - /* XXX - experimental */ - sprintf (keyname, "\\M-"); -#endif + { + /* If ESC is the meta prefix and we're converting chars + with the eighth bit set to ESC-prefixed sequences, then + we can use \M-. Otherwise we need to use the sequence + for ESC. */ + if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP) + sprintf (keyname, "\\M-"); + else + sprintf (keyname, "\\e"); + } else if (CTRL_CHAR (key)) sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key))); else if (key == RUBOUT) @@ -2170,7 +2203,6 @@ _rl_get_string_variable_value (name) { static char numbuf[32]; char *ret; - int n; if (_rl_stricmp (name, "bell-style") == 0) { diff --git a/contrib/libreadline/callback.c b/contrib/libreadline/callback.c index 9120969ca238..ada04d8593bf 100644 --- a/contrib/libreadline/callback.c +++ b/contrib/libreadline/callback.c @@ -43,6 +43,7 @@ #include "rldefs.h" #include "readline.h" #include "rlprivate.h" +#include "xmalloc.h" /* Private data for callback registration functions. See comments in rl_callback_read_char for more details. */ @@ -124,73 +125,73 @@ rl_callback_read_char () return; } - if (RL_ISSTATE (RL_STATE_ISEARCH)) + do { - eof = _rl_isearch_callback (_rl_iscxt); - if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) - rl_callback_read_char (); - - return; - } - else if (RL_ISSTATE (RL_STATE_NSEARCH)) - { - eof = _rl_nsearch_callback (_rl_nscxt); - return; - } - else if (RL_ISSTATE (RL_STATE_NUMERICARG)) - { - eof = _rl_arg_callback (_rl_argcxt); - if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) - rl_callback_read_char (); - /* XXX - this should handle _rl_last_command_was_kill better */ - else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) - _rl_internal_char_cleanup (); - - return; - } - else if (RL_ISSTATE (RL_STATE_MULTIKEY)) - { - eof = _rl_dispatch_callback (_rl_kscxt); /* For now */ - while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED)) - eof = _rl_dispatch_callback (_rl_kscxt); - if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0) + if (RL_ISSTATE (RL_STATE_ISEARCH)) { - _rl_internal_char_cleanup (); - _rl_want_redisplay = 1; + eof = _rl_isearch_callback (_rl_iscxt); + if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) + rl_callback_read_char (); + + return; } - } - else if (_rl_callback_func) - { - /* This allows functions that simply need to read an additional character - (like quoted-insert) to register a function to be called when input is - available. _rl_callback_data is simply a pointer to a struct that has - the argument count originally passed to the registering function and - space for any additional parameters. */ - eof = (*_rl_callback_func) (_rl_callback_data); - /* If the function `deregisters' itself, make sure the data is cleaned - up. */ - if (_rl_callback_func == 0) + else if (RL_ISSTATE (RL_STATE_NSEARCH)) { - if (_rl_callback_data) + eof = _rl_nsearch_callback (_rl_nscxt); + return; + } + else if (RL_ISSTATE (RL_STATE_NUMERICARG)) + { + eof = _rl_arg_callback (_rl_argcxt); + if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) + rl_callback_read_char (); + /* XXX - this should handle _rl_last_command_was_kill better */ + else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) + _rl_internal_char_cleanup (); + + return; + } + else if (RL_ISSTATE (RL_STATE_MULTIKEY)) + { + eof = _rl_dispatch_callback (_rl_kscxt); /* For now */ + while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED)) + eof = _rl_dispatch_callback (_rl_kscxt); + if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0) { - _rl_callback_data_dispose (_rl_callback_data); - _rl_callback_data = 0; + _rl_internal_char_cleanup (); + _rl_want_redisplay = 1; } - _rl_internal_char_cleanup (); } - } - else - eof = readline_internal_char (); + else if (_rl_callback_func) + { + /* This allows functions that simply need to read an additional + character (like quoted-insert) to register a function to be + called when input is available. _rl_callback_data is simply a + pointer to a struct that has the argument count originally + passed to the registering function and space for any additional + parameters. */ + eof = (*_rl_callback_func) (_rl_callback_data); + /* If the function `deregisters' itself, make sure the data is + cleaned up. */ + if (_rl_callback_func == 0) + { + if (_rl_callback_data) + { + _rl_callback_data_dispose (_rl_callback_data); + _rl_callback_data = 0; + } + _rl_internal_char_cleanup (); + } + } + else + eof = readline_internal_char (); - if (rl_done == 0 && _rl_want_redisplay) - { - (*rl_redisplay_function) (); - _rl_want_redisplay = 0; - } + if (rl_done == 0 && _rl_want_redisplay) + { + (*rl_redisplay_function) (); + _rl_want_redisplay = 0; + } - /* We loop in case some function has pushed input back with rl_execute_next. */ - for (;;) - { if (rl_done) { line = readline_internal_teardown (eof); @@ -212,11 +213,8 @@ rl_callback_read_char () if (in_handler == 0 && rl_linefunc) _rl_callback_newline (); } - if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT)) - eof = readline_internal_char (); - else - break; } + while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT)); } /* Remove the handler, and make sure the terminal is in its normal state. */ diff --git a/contrib/libreadline/complete.c b/contrib/libreadline/complete.c index d93c15ae55d2..73f834a68a79 100644 --- a/contrib/libreadline/complete.c +++ b/contrib/libreadline/complete.c @@ -950,7 +950,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) rl_compentry_func_t *our_func; int found_quote, quote_char; { - char **matches, *temp; + char **matches; rl_completion_found_quote = found_quote; rl_completion_quote_character = quote_char; @@ -969,21 +969,9 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) } } - /* Beware -- we're stripping the quotes here. Do this only if we know - we are doing filename completion and the application has defined a - filename dequoting function. */ - temp = (char *)NULL; - - if (found_quote && our_func == rl_filename_completion_function && - rl_filename_dequoting_function) - { - /* delete single and double quotes */ - temp = (*rl_filename_dequoting_function) (text, quote_char); - text = temp; /* not freeing text is not a memory leak */ - } + /* XXX -- filename dequoting moved into rl_filename_completion_function */ matches = rl_completion_matches (text, our_func); - FREE (temp); return matches; } @@ -1116,7 +1104,8 @@ compute_lcd_of_matches (match_list, matches, text) #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - mbstate_t ps_back = ps1; + mbstate_t ps_back; + 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) @@ -1974,13 +1963,30 @@ rl_filename_completion_function (text, state) if (rl_directory_rewrite_hook) (*rl_directory_rewrite_hook) (&dirname); + /* The directory completion hook should perform any necessary + dequoting. */ if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname)) { free (users_dirname); users_dirname = savestring (dirname); } - + else if (rl_completion_found_quote && rl_filename_dequoting_function) + { + /* delete single and double quotes */ + temp = (*rl_filename_dequoting_function) (users_dirname, rl_completion_quote_character); + free (users_dirname); + users_dirname = temp; + } directory = opendir (dirname); + + /* Now dequote a non-null filename. */ + if (filename && *filename && rl_completion_found_quote && rl_filename_dequoting_function) + { + /* delete single and double quotes */ + temp = (*rl_filename_dequoting_function) (filename, rl_completion_quote_character); + free (filename); + filename = temp; + } filename_len = strlen (filename); rl_filename_completion_desired = 1; diff --git a/contrib/libreadline/config.h.in b/contrib/libreadline/config.h.in index b4aae982a7b3..03178a442aa4 100644 --- a/contrib/libreadline/config.h.in +++ b/contrib/libreadline/config.h.in @@ -41,6 +41,15 @@ /* Define if you have the isascii function. */ #undef HAVE_ISASCII +/* Define if you have the iswctype function. */ +#undef HAVE_ISWCTYPE + +/* Define if you have the iswlower function. */ +#undef HAVE_ISWLOWER + +/* Define if you have the iswupper function. */ +#undef HAVE_ISWUPPER + /* Define if you have the isxdigit function. */ #undef HAVE_ISXDIGIT @@ -88,11 +97,23 @@ /* Define if you have the tcgetattr function. */ #undef HAVE_TCGETATTR +/* Define if you have the towlower function. */ +#undef HAVE_TOWLOWER + +/* Define if you have the towupper function. */ +#undef HAVE_TOWUPPER + /* Define if you have the vsnprintf function. */ #undef HAVE_VSNPRINTF -/* Define if you have the wctomb function. */ -#undef HAVE_WCTOMB +/* Define if you have the wcrtomb function. */ +#undef HAVE_WCRTOMB + +/* Define if you have the wcscoll function. */ +#undef HAVE_WCSCOLL + +/* Define if you have the wctype function. */ +#undef HAVE_WCTYPE /* Define if you have the wcwidth function. */ #undef HAVE_WCWIDTH @@ -174,11 +195,20 @@ /* Define if you have the header file. */ #undef HAVE_WCHAR_H -/* Define if you have the header file. */ +/* Define if you have the header file. */ #undef HAVE_WCTYPE_H #undef HAVE_MBSTATE_T +/* Define if you have wchar_t in . */ +#undef HAVE_WCHAR_T + +/* Define if you have wctype_t in . */ +#undef HAVE_WCTYPE_T + +/* Define if you have wint_t in . */ +#undef HAVE_WINT_T + /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET diff --git a/contrib/libreadline/configure b/contrib/libreadline/configure index 17a9eeb10a46..5706839e5b16 100755 --- a/contrib/libreadline/configure +++ b/contrib/libreadline/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in for Readline 5.1, version 2.58. +# From configure.in for Readline 5.2, version 2.61. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for readline 5.1-beta1. +# Generated by GNU Autoconf 2.59 for readline 5.2. # # Report bugs to . # @@ -270,8 +270,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='readline' PACKAGE_TARNAME='readline' -PACKAGE_VERSION='5.1-beta1' -PACKAGE_STRING='readline 5.1-beta1' +PACKAGE_VERSION='5.2' +PACKAGE_STRING='readline 5.2' PACKAGE_BUGREPORT='bug-readline@gnu.org' ac_unique_file="readline.h" @@ -781,7 +781,7 @@ 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 <<_ACEOF -\`configure' configures readline 5.1-beta1 to adapt to many kinds of systems. +\`configure' configures readline 5.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -842,7 +842,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of readline 5.1-beta1:";; + short | recursive ) echo "Configuration of readline 5.2:";; esac cat <<\_ACEOF @@ -968,7 +968,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -readline configure 5.1-beta1 +readline configure 5.2 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -982,7 +982,7 @@ cat >&5 <<_ACEOF 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 5.1-beta1, which was +It was created by readline $as_me 5.2, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1350,7 +1350,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. ac_config_headers="$ac_config_headers config.h" -LIBVERSION=5.1 +LIBVERSION=5.2 # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || @@ -1462,6 +1462,7 @@ fi +CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) @@ -7403,103 +7404,6 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for mbrtowc" >&5 -echo $ECHO_N "checking for mbrtowc... $ECHO_C" >&6 -if test "${ac_cv_func_mbrtowc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define mbrtowc to an innocuous variant, in case declares mbrtowc. - For example, HP-UX 11i declares gettimeofday. */ -#define mbrtowc innocuous_mbrtowc - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char mbrtowc (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef mbrtowc - -/* 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 mbrtowc (); -/* 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_mbrtowc) || defined (__stub___mbrtowc) -choke me -#else -char (*f) () = mbrtowc; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != mbrtowc; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_mbrtowc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_mbrtowc=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5 -echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6 -if test $ac_cv_func_mbrtowc = yes; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_MBRTOWC 1 -_ACEOF - -fi - echo "$as_me:$LINENO: checking for mbrlen" >&5 echo $ECHO_N "checking for mbrlen... $ECHO_C" >&6 if test "${ac_cv_func_mbrlen+set}" = set; then @@ -7597,9 +7501,10 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for wctomb" >&5 -echo $ECHO_N "checking for wctomb... $ECHO_C" >&6 -if test "${ac_cv_func_wctomb+set}" = set; then + +echo "$as_me:$LINENO: checking for wcrtomb" >&5 +echo $ECHO_N "checking for wcrtomb... $ECHO_C" >&6 +if test "${ac_cv_func_wcrtomb+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7608,12 +7513,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define wctomb to an innocuous variant, in case declares wctomb. +/* Define wcrtomb to an innocuous variant, in case declares wcrtomb. For example, HP-UX 11i declares gettimeofday. */ -#define wctomb innocuous_wctomb +#define wcrtomb innocuous_wcrtomb /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char wctomb (); below. + which can conflict with char wcrtomb (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7623,7 +7528,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef wctomb +#undef wcrtomb /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7632,14 +7537,14 @@ 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 wctomb (); +char wcrtomb (); /* 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_wctomb) || defined (__stub___wctomb) +#if defined (__stub_wcrtomb) || defined (__stub___wcrtomb) choke me #else -char (*f) () = wctomb; +char (*f) () = wcrtomb; #endif #ifdef __cplusplus } @@ -7648,7 +7553,7 @@ char (*f) () = wctomb; int main () { -return f != wctomb; +return f != wcrtomb; ; return 0; } @@ -7675,28 +7580,28 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_wctomb=yes + ac_cv_func_wcrtomb=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_wctomb=no +ac_cv_func_wcrtomb=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_wctomb" >&5 -echo "${ECHO_T}$ac_cv_func_wctomb" >&6 -if test $ac_cv_func_wctomb = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_wcrtomb" >&5 +echo "${ECHO_T}$ac_cv_func_wcrtomb" >&6 +if test $ac_cv_func_wcrtomb = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_WCTOMB 1 +#define HAVE_WCRTOMB 1 _ACEOF fi -echo "$as_me:$LINENO: checking for wcwidth" >&5 -echo $ECHO_N "checking for wcwidth... $ECHO_C" >&6 -if test "${ac_cv_func_wcwidth+set}" = set; then +echo "$as_me:$LINENO: checking for wcscoll" >&5 +echo $ECHO_N "checking for wcscoll... $ECHO_C" >&6 +if test "${ac_cv_func_wcscoll+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7705,12 +7610,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define wcwidth to an innocuous variant, in case declares wcwidth. +/* Define wcscoll to an innocuous variant, in case declares wcscoll. For example, HP-UX 11i declares gettimeofday. */ -#define wcwidth innocuous_wcwidth +#define wcscoll innocuous_wcscoll /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char wcwidth (); below. + which can conflict with char wcscoll (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7720,7 +7625,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef wcwidth +#undef wcscoll /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7729,14 +7634,14 @@ 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 wcscoll (); /* 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) +#if defined (__stub_wcscoll) || defined (__stub___wcscoll) choke me #else -char (*f) () = wcwidth; +char (*f) () = wcscoll; #endif #ifdef __cplusplus } @@ -7745,7 +7650,7 @@ char (*f) () = wcwidth; int main () { -return f != wcwidth; +return f != wcscoll; ; return 0; } @@ -7772,21 +7677,21 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_wcwidth=yes + ac_cv_func_wcscoll=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_wcwidth=no +ac_cv_func_wcscoll=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_wcwidth" >&5 -echo "${ECHO_T}$ac_cv_func_wcwidth" >&6 -if test $ac_cv_func_wcwidth = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_wcscoll" >&5 +echo "${ECHO_T}$ac_cv_func_wcscoll" >&6 +if test $ac_cv_func_wcscoll = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_WCWIDTH 1 +#define HAVE_WCSCOLL 1 _ACEOF fi @@ -7888,10 +7793,9 @@ _ACEOF fi - -echo "$as_me:$LINENO: 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 "$as_me:$LINENO: 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 @@ -7900,23 +7804,54 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +/* Define wcwidth to an innocuous variant, in case declares wcwidth. + For example, HP-UX 11i declares gettimeofday. */ +#define wcwidth innocuous_wcwidth + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char wcwidth (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef wcwidth + +/* 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 (); +/* 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 +char (*f) () = wcwidth; +#endif +#ifdef __cplusplus +} +#endif -#include int main () { - - mbstate_t ps; - mbstate_t *psp; - psp = (mbstate_t *)0; - +return f != wcwidth; ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -7930,30 +7865,306 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - bash_cv_have_mbstate_t=yes + ac_cv_func_wcwidth=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -bash_cv_have_mbstate_t=no +ac_cv_func_wcwidth=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: 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 +echo "$as_me:$LINENO: 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 <<\_ACEOF +#define HAVE_WCWIDTH 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wctype" >&5 +echo $ECHO_N "checking for wctype... $ECHO_C" >&6 +if test "${ac_cv_func_wctype+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define wctype to an innocuous variant, in case declares wctype. + For example, HP-UX 11i declares gettimeofday. */ +#define wctype innocuous_wctype + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char wctype (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef wctype + +/* 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 wctype (); +/* 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_wctype) || defined (__stub___wctype) +choke me +#else +char (*f) () = wctype; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != wctype; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_wctype=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_wctype=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_wctype" >&5 +echo "${ECHO_T}$ac_cv_func_wctype" >&6 +if test $ac_cv_func_wctype = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_WCTYPE 1 +_ACEOF + +fi + + + + echo "$as_me:$LINENO: checking whether mbrtowc and mbstate_t are properly declared" >&5 +echo $ECHO_N "checking whether mbrtowc and mbstate_t are properly declared... $ECHO_C" >&6 +if test "${ac_cv_func_mbrtowc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +mbstate_t state; return ! (sizeof state && mbrtowc); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_mbrtowc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_mbrtowc=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5 +echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6 + if test $ac_cv_func_mbrtowc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MBRTOWC 1 +_ACEOF + + fi + +if test $ac_cv_func_mbrtowc = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MBSTATE_T 1 _ACEOF fi + + + + + +for ac_func in iswlower iswupper towlower towupper iswctype +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: 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 <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + echo "$as_me:$LINENO: 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 @@ -8015,6 +8226,199 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for wchar_t in wchar.h" >&5 +echo $ECHO_N "checking for wchar_t in wchar.h... $ECHO_C" >&6 +if test "${bash_cv_type_wchar_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ + + wchar_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wchar_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wchar_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wchar_t" >&5 +echo "${ECHO_T}$bash_cv_type_wchar_t" >&6 +if test $bash_cv_type_wchar_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WCHAR_T 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wctype_t in wctype.h" >&5 +echo $ECHO_N "checking for wctype_t in wctype.h... $ECHO_C" >&6 +if test "${bash_cv_type_wctype_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + wctype_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wctype_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wctype_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wctype_t" >&5 +echo "${ECHO_T}$bash_cv_type_wctype_t" >&6 +if test $bash_cv_type_wctype_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WCTYPE_T 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wint_t in wctype.h" >&5 +echo $ECHO_N "checking for wint_t in wctype.h... $ECHO_C" >&6 +if test "${bash_cv_type_wint_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + wint_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wint_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wint_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wint_t" >&5 +echo "${ECHO_T}$bash_cv_type_wint_t" >&6 +if test $bash_cv_type_wint_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WINT_T 1 +_ACEOF + +fi + case "$host_cpu" in @@ -8479,7 +8883,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by readline $as_me 5.1-beta1, which was +This file was extended by readline $as_me 5.2, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8542,7 +8946,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -readline config.status 5.1-beta1 +readline config.status 5.2 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/contrib/libreadline/configure.in b/contrib/libreadline/configure.in index a7863986d8eb..868773be6969 100644 --- a/contrib/libreadline/configure.in +++ b/contrib/libreadline/configure.in @@ -22,9 +22,9 @@ dnl Process this file with autoconf to produce a configure script. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. -AC_REVISION([for Readline 5.1, version 2.59]) +AC_REVISION([for Readline 5.2, version 2.61]) -AC_INIT(readline, 5.1-release, bug-readline@gnu.org) +AC_INIT(readline, 5.2, bug-readline@gnu.org) dnl make sure we are using a recent autoconf version AC_PREREQ(2.50) @@ -34,7 +34,7 @@ AC_CONFIG_AUX_DIR(./support) AC_CONFIG_HEADERS(config.h) dnl update the value of RL_READLINE_VERSION in readline.h when this changes -LIBVERSION=5.1 +LIBVERSION=5.2 AC_CANONICAL_HOST @@ -75,6 +75,7 @@ dnl files as necessary dnl Note that host and target machine are the same, and different than the dnl build machine. +CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) diff --git a/contrib/libreadline/display.c b/contrib/libreadline/display.c index 0d3ae6e5da90..47ff06159747 100644 --- a/contrib/libreadline/display.c +++ b/contrib/libreadline/display.c @@ -1,6 +1,6 @@ /* display.c -- readline redisplay facility. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2006 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. @@ -59,10 +59,6 @@ extern char *strchr (), *strrchr (); #endif /* !strchr && !__STDC__ */ -#if defined (HACK_TERMCAP_MOTION) -extern char *_rl_term_forward_char; -#endif - static void update_line PARAMS((char *, char *, int, int, int, int)); static void space_to_eol PARAMS((int)); static void delete_chars PARAMS((int)); @@ -80,9 +76,18 @@ static int *inv_lbreaks, *vis_lbreaks; static int inv_lbsize, vis_lbsize; /* Heuristic used to decide whether it is faster to move from CUR to NEW - by backing up or outputting a carriage return and moving forward. */ + by backing up or outputting a carriage return and moving forward. CUR + and NEW are either both buffer positions or absolute screen positions. */ #define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new))) +/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a + buffer index in others. This macro is used when deciding whether the + current cursor position is in the middle of a prompt string containing + invisible characters. */ +#define PROMPT_ENDING_INDEX \ + ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1) + + /* **************************************************************** */ /* */ /* Display stuff */ @@ -135,6 +140,7 @@ int _rl_last_c_pos = 0; int _rl_last_v_pos = 0; static int cpos_adjusted; +static int cpos_buffer_position; /* Number of lines currently on screen minus 1. */ int _rl_vis_botlin = 0; @@ -162,6 +168,7 @@ static int line_size = 1024; include invisible characters. */ static char *local_prompt, *local_prompt_prefix; +static int local_prompt_len; static int prompt_visible_length, prompt_prefix_length; /* The number of invisible characters in the line currently being @@ -197,6 +204,7 @@ static char *saved_local_prefix; static int saved_last_invisible; static int saved_visible_length; static int saved_prefix_length; +static int saved_local_length; static int saved_invis_chars_first_line; static int saved_physical_chars; @@ -220,7 +228,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp) char *pmt; int *lp, *lip, *niflp, *vlp; { - char *r, *ret, *p; + char *r, *ret, *p, *igstart; int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; /* Short-circuit if we can. */ @@ -244,19 +252,21 @@ expand_prompt (pmt, lp, lip, niflp, vlp) invfl = 0; /* invisible chars in first line of prompt */ invflset = 0; /* we only want to set invfl once */ + igstart = 0; for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++) { /* This code strips the invisible character string markers RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ - if (*p == RL_PROMPT_START_IGNORE) + if (ignoring == 0 && *p == RL_PROMPT_START_IGNORE) /* XXX - check ignoring? */ { - ignoring++; + ignoring = 1; + igstart = p; continue; } else if (ignoring && *p == RL_PROMPT_END_IGNORE) { ignoring = 0; - if (p[-1] != RL_PROMPT_START_IGNORE) + if (p != (igstart + 1)) last = r - ret - 1; continue; } @@ -356,6 +366,7 @@ rl_expand_prompt (prompt) FREE (local_prompt_prefix); local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; prompt_last_invisible = prompt_invis_chars_first_line = 0; prompt_visible_length = prompt_physical_chars = 0; @@ -371,6 +382,7 @@ rl_expand_prompt (prompt) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)0; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; return (prompt_visible_length); } else @@ -389,6 +401,7 @@ rl_expand_prompt (prompt) &prompt_invis_chars_first_line, (int *)NULL); *t = c; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; return (prompt_prefix_length); } } @@ -445,7 +458,7 @@ rl_redisplay () { register int in, out, c, linenum, cursor_linenum; register char *line; - int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos; + int inv_botlin, lb_botlin, lb_linenum, o_cpos; int newlines, lpos, temp, modmark, n0, num; char *prompt_this_line; #if defined (HANDLE_MULTIBYTE) @@ -469,7 +482,7 @@ rl_redisplay () } /* Draw the line into the buffer. */ - c_pos = -1; + cpos_buffer_position = -1; line = invisible_line; out = inv_botlin = 0; @@ -496,24 +509,23 @@ rl_redisplay () number of non-visible characters in the prompt string. */ if (rl_display_prompt == rl_prompt || local_prompt) { - int local_len = local_prompt ? strlen (local_prompt) : 0; if (local_prompt_prefix && forced_display) _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix)); - if (local_len > 0) + if (local_prompt_len > 0) { - temp = local_len + out + 2; + temp = local_prompt_len + out + 2; if (temp >= line_size) { line_size = (temp + 1024) - (temp % 1024); 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; + strncpy (line + out, local_prompt, local_prompt_len); + out += local_prompt_len; } line[out] = '\0'; - wrap_offset = local_len - prompt_visible_length; + wrap_offset = local_prompt_len - prompt_visible_length; } else { @@ -614,6 +626,7 @@ rl_redisplay () contents of the command line? */ while (lpos >= _rl_screenwidth) { + int z; /* fix from Darin Johnson 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 @@ -622,37 +635,46 @@ rl_redisplay () prompts that exceed two physical lines? Additional logic fix from Edward Catmur */ #if defined (HANDLE_MULTIBYTE) - n0 = num; - temp = local_prompt ? strlen (local_prompt) : 0; - while (num < temp) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth) + n0 = num; + temp = local_prompt_len; + while (num < temp) { - num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); - break; + z = _rl_col_width (local_prompt, n0, num); + if (z > _rl_screenwidth) + { + num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); + break; + } + else if (z == _rl_screenwidth) + break; + num++; } - num++; + temp = num; } - temp = num + -#else - temp = ((newlines + 1) * _rl_screenwidth) + + else #endif /* !HANDLE_MULTIBYTE */ - ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line - : ((newlines == 1) ? wrap_offset : 0)) - : ((newlines == 0) ? wrap_offset :0)); + temp = ((newlines + 1) * _rl_screenwidth); + + /* Now account for invisible characters in the current line. */ + temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line + : ((newlines == 1) ? wrap_offset : 0)) + : ((newlines == 0) ? wrap_offset :0)); inv_lbreaks[++newlines] = temp; #if defined (HANDLE_MULTIBYTE) - lpos -= _rl_col_width (local_prompt, n0, num); -#else - lpos -= _rl_screenwidth; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + lpos -= _rl_col_width (local_prompt, n0, num); + else #endif + 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 + track of where the cursor is (cpos_buffer_position), 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. */ @@ -705,7 +727,7 @@ rl_redisplay () if (in == rl_point) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } @@ -799,7 +821,7 @@ rl_redisplay () } if (in == rl_point) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } for (i = in; i < in+wc_bytes; i++) @@ -830,9 +852,9 @@ rl_redisplay () } line[out] = '\0'; - if (c_pos < 0) + if (cpos_buffer_position < 0) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } @@ -841,7 +863,7 @@ rl_redisplay () inv_lbreaks[newlines+1] = out; cursor_linenum = lb_linenum; - /* C_POS == position in buffer where cursor should be placed. + /* CPOS_BUFFER_POSITION == 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 @@ -886,6 +908,8 @@ rl_redisplay () /* For each line in the buffer, do the updating display. */ for (linenum = 0; linenum <= inv_botlin; linenum++) { + /* This can lead us astray if we execute a program that changes + the locale from a non-multibyte to a multibyte one. */ o_cpos = _rl_last_c_pos; cpos_adjusted = 0; update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum, @@ -898,7 +922,11 @@ rl_redisplay () change update_line itself. There is one case in which update_line adjusts _rl_last_c_pos itself (so it can pass _rl_move_cursor_relative accurate values); it communicates - this back by setting cpos_adjusted */ + this back by setting cpos_adjusted. If we assume that + _rl_last_c_pos is correct (an absolute cursor position) each + time update_line is called, then we can assume in our + calculations that o_cpos does not need to be adjusted by + wrap_offset. */ if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && cpos_adjusted == 0 && _rl_last_c_pos != o_cpos && @@ -967,7 +995,11 @@ rl_redisplay () invisible character in the prompt string. */ nleft = prompt_visible_length + wrap_offset; if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && - _rl_last_c_pos <= prompt_last_invisible && local_prompt) +#if 0 + _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt) +#else + _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt) +#endif { #if defined (__MSDOS__) putc ('\r', rl_outstream); @@ -986,8 +1018,8 @@ rl_redisplay () in the buffer? */ pos = inv_lbreaks[cursor_linenum]; /* nleft == number of characters in the line buffer between the - start of the line and the cursor position. */ - nleft = c_pos - pos; + start of the line and the desired cursor position. */ + nleft = cpos_buffer_position - pos; /* NLEFT is now a number of characters in a buffer. When in a multibyte locale, however, _rl_last_c_pos is an absolute cursor @@ -999,6 +1031,7 @@ rl_redisplay () those characters here and call _rl_backspace() directly. */ if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos) { + /* TX == new physical cursor position in multibyte locale. */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset; else @@ -1032,11 +1065,11 @@ rl_redisplay () will be LMARGIN. */ /* The number of characters that will be displayed before the cursor. */ - ndisp = c_pos - wrap_offset; + ndisp = cpos_buffer_position - 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); + phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset); t = _rl_screenwidth / 3; /* If the number of characters had already exceeded the screenwidth, @@ -1047,7 +1080,7 @@ rl_redisplay () two-thirds of the way across the screen. */ if (phys_c_pos > _rl_screenwidth - 2) { - lmargin = c_pos - (2 * t); + lmargin = cpos_buffer_position - (2 * t); if (lmargin < 0) lmargin = 0; /* If the left margin would be in the middle of a prompt with @@ -1061,7 +1094,7 @@ rl_redisplay () { /* If we are moving back towards the beginning of the line and the last margin is no longer correct, compute a new one. */ - lmargin = ((c_pos - 1) / t) * t; /* XXX */ + lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */ if (wrap_offset && lmargin > 0 && lmargin < nleft) lmargin = nleft; } @@ -1106,7 +1139,7 @@ rl_redisplay () if (visible_first_line_len > _rl_screenwidth) visible_first_line_len = _rl_screenwidth; - _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); + _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]); last_lmargin = lmargin; } } @@ -1164,7 +1197,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) int col_lendiff, col_temp; #if defined (HANDLE_MULTIBYTE) mbstate_t ps_new, ps_old; - int new_offset, old_offset, tmp; + int new_offset, old_offset; #endif /* If we're at the right edge of a terminal that supports xn, we're @@ -1397,11 +1430,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) sequences (like drawing the `unbold' sequence without a corresponding `bold') that manifests itself on certain terminals. */ - lendiff = local_prompt ? strlen (local_prompt) : 0; + lendiff = local_prompt_len; od = ofd - old; /* index of first difference in visible line */ if (current_line == 0 && !_rl_horizontal_scroll_mode && _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 && - od >= lendiff && _rl_last_c_pos <= prompt_last_invisible) + od >= lendiff && _rl_last_c_pos < PROMPT_ENDING_INDEX) { #if defined (__MSDOS__) putc ('\r', rl_outstream); @@ -1420,7 +1453,19 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) _rl_last_c_pos = lendiff; } + /* When this function returns, _rl_last_c_pos is correct, and an absolute + cursor postion in multibyte mode, but a buffer index when not in a + multibyte locale. */ _rl_move_cursor_relative (od, old); +#if 1 +#if defined (HANDLE_MULTIBYTE) + /* We need to indicate that the cursor position is correct in the presence of + invisible characters in the prompt string. Let's see if setting this when + we make sure we're at the end of the drawn prompt string works. */ + if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars) + cpos_adjusted = 1; +#endif +#endif /* if (len (new) > len (old)) lendiff == difference in buffer @@ -1648,10 +1693,11 @@ rl_on_new_line_with_prompt () int rl_forced_update_display () { + register char *temp; + if (visible_line) { - register char *temp = visible_line; - + temp = visible_line; while (*temp) *temp++ = '\0'; } @@ -1686,8 +1732,14 @@ _rl_move_cursor_relative (new, data) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { dpos = _rl_col_width (data, 0, new); - if (dpos > woff) - dpos -= woff; + if (dpos > prompt_last_invisible) /* XXX - don't use woff here */ + { + dpos -= woff; + /* Since this will be assigned to _rl_last_c_pos at the end (more + precisely, _rl_last_c_pos == dpos when this function returns), + let the caller know. */ + cpos_adjusted = 1; + } } else #endif @@ -1706,7 +1758,7 @@ _rl_move_cursor_relative (new, data) else #endif i = _rl_last_c_pos - woff; - if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || + if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) || (_rl_term_autowrap && i == _rl_screenwidth)) { #if defined (__MSDOS__) @@ -1728,19 +1780,27 @@ _rl_move_cursor_relative (new, data) sequence telling the terminal to move forward one character. That kind of control is for people who don't know what the data is underneath the cursor. */ -#if defined (HACK_TERMCAP_MOTION) - if (_rl_term_forward_char) - { - for (i = cpos; i < dpos; i++) - tputs (_rl_term_forward_char, 1, _rl_output_character_function); - } - else -#endif /* HACK_TERMCAP_MOTION */ + + /* However, we need a handle on where the current display position is + in the buffer for the immediately preceding comment to be true. + In multibyte locales, we don't currently have that info available. + Without it, we don't know where the data we have to display begins + in the buffer and we have to go back to the beginning of the screen + line. In this case, we can use the terminal sequence to move forward + if it's available. */ 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); + if (_rl_term_forward_char) + { + for (i = cpos; i < dpos; i++) + tputs (_rl_term_forward_char, 1, _rl_output_character_function); + } + else + { + tputs (_rl_term_cr, 1, _rl_output_character_function); + for (i = 0; i < new; i++) + putc (data[i], rl_outstream); + } } else for (i = cpos; i < new; i++) @@ -1889,6 +1949,7 @@ rl_message (va_alist) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; (*rl_redisplay_function) (); return 0; @@ -1912,6 +1973,7 @@ rl_message (format, arg1, arg2) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; (*rl_redisplay_function) (); return 0; @@ -1948,12 +2010,14 @@ rl_save_prompt () saved_local_prompt = local_prompt; saved_local_prefix = local_prompt_prefix; saved_prefix_length = prompt_prefix_length; + saved_local_length = local_prompt_len; saved_last_invisible = prompt_last_invisible; saved_visible_length = prompt_visible_length; saved_invis_chars_first_line = prompt_invis_chars_first_line; saved_physical_chars = prompt_physical_chars; local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0; prompt_invis_chars_first_line = prompt_physical_chars = 0; } @@ -1966,6 +2030,7 @@ rl_restore_prompt () local_prompt = saved_local_prompt; local_prompt_prefix = saved_local_prefix; + local_prompt_len = saved_local_length; prompt_prefix_length = saved_prefix_length; prompt_last_invisible = saved_last_invisible; prompt_visible_length = saved_visible_length; @@ -1974,6 +2039,7 @@ rl_restore_prompt () /* can test saved_local_prompt to see if prompt info has been saved. */ saved_local_prompt = saved_local_prefix = (char *)0; + saved_local_length = 0; saved_last_invisible = saved_visible_length = saved_prefix_length = 0; saved_invis_chars_first_line = saved_physical_chars = 0; } @@ -2162,7 +2228,8 @@ _rl_update_final () char *last_line; last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; - _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); + cpos_buffer_position = -1; /* don't know where we are in buffer */ + _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); /* XXX */ _rl_clear_to_eol (0); putc (last_line[_rl_screenwidth - 1], rl_outstream); } @@ -2205,6 +2272,7 @@ redraw_prompt (t) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; rl_forced_update_display (); @@ -2307,12 +2375,14 @@ _rl_col_width (str, start, end) int start, end; { wchar_t wc; - mbstate_t ps = {0}; + mbstate_t ps; int tmp, point, width, max; if (end <= start) return 0; + memset (&ps, 0, sizeof (mbstate_t)); + point = 0; max = end; diff --git a/contrib/libreadline/doc/history.texi b/contrib/libreadline/doc/history.texi index f6a3d205167c..1af40c73de73 100644 --- a/contrib/libreadline/doc/history.texi +++ b/contrib/libreadline/doc/history.texi @@ -14,7 +14,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 @copyright{} 1988-2004 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,7 +22,7 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or +under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the license is diff --git a/contrib/libreadline/doc/hstech.texi b/contrib/libreadline/doc/hstech.texi index 4fdda5f1c9e5..47ba8a550c62 100644 --- a/contrib/libreadline/doc/hstech.texi +++ b/contrib/libreadline/doc/hstech.texi @@ -1,7 +1,7 @@ @ignore This file documents the user interface to the GNU History library. -Copyright (C) 1988-2002 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. Permission is granted to make and distribute verbatim copies of this manual diff --git a/contrib/libreadline/doc/hsuser.texi b/contrib/libreadline/doc/hsuser.texi index 6c8918331868..f98983b69ed3 100644 --- a/contrib/libreadline/doc/hsuser.texi +++ b/contrib/libreadline/doc/hsuser.texi @@ -1,7 +1,7 @@ @ignore This file documents the user interface to the GNU History library. -Copyright (C) 1988-2002 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. Permission is granted to make and distribute verbatim copies of this manual diff --git a/contrib/libreadline/doc/readline.3 b/contrib/libreadline/doc/readline.3 index 90cd9971e8e9..2c45ed2c88e2 100644 --- a/contrib/libreadline/doc/readline.3 +++ b/contrib/libreadline/doc/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet@ins.CWRU.Edu .\" -.\" Last Change: Tue Sep 13 12:07:26 EDT 2005 +.\" Last Change: Thu Feb 9 09:49:51 EST 2006 .\" -.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-beta1" +.TH READLINE 3 "2006 Apr 26" "GNU Readline 5.2" .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -116,6 +116,8 @@ The name of this file is taken from the value of the .B INPUTRC environment variable. If that variable is unset, the default is .IR ~/.inputrc . +If that file does not exist or cannot be read, the ultimate default is +.IR /etc/inputrc . When a program which uses the readline library starts up, the init file is read, and the key bindings and variables are set. There are only a few basic constructs allowed in the @@ -168,6 +170,8 @@ 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. +The name and key sequence are separated by a colon. There can be no +whitespace between the name and the colon. .PP When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP, .I keyname diff --git a/contrib/libreadline/doc/rlman.texi b/contrib/libreadline/doc/rlman.texi index f834b5826537..e14c655f754c 100644 --- a/contrib/libreadline/doc/rlman.texi +++ b/contrib/libreadline/doc/rlman.texi @@ -14,7 +14,7 @@ This manual describes the GNU Readline Library consistency of user interface across discrete programs which provide a command line interface. -Copyright @copyright{} 1988-2004 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,7 +22,7 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or +under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the license is diff --git a/contrib/libreadline/doc/rltech.texi b/contrib/libreadline/doc/rltech.texi index 6f2e2ee2d345..ecff10608271 100644 --- a/contrib/libreadline/doc/rltech.texi +++ b/contrib/libreadline/doc/rltech.texi @@ -8,7 +8,7 @@ This document describes the GNU Readline Library, a utility for aiding in the consistency of user interface across discrete programs that need to provide a command line interface. -Copyright (C) 1988-2005 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -1033,8 +1033,10 @@ pending input has not already been read with @code{rl_read_key()}. @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. +assigned to @code{rl_event_hook}. @var{u} must be greater than or equal +to zero (a zero-length timeout is equivalent to a poll). +The default waiting period is one-tenth of a second. +Returns the old timeout value. @end deftypefun @node Terminal Management @@ -1668,6 +1670,9 @@ 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. +At the least, even if no other expansion is performed, this function should +remove any quote characters from the directory name, because its result will +be passed directly to @code{opendir()}. @end deftypevar @deftypevar {rl_compdisp_func_t *} rl_completion_display_matches_hook diff --git a/contrib/libreadline/doc/rluser.texi b/contrib/libreadline/doc/rluser.texi index 478b41fac3c7..5c6467a9aa69 100644 --- a/contrib/libreadline/doc/rluser.texi +++ b/contrib/libreadline/doc/rluser.texi @@ -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-2005 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. Authored by Brian Fox and Chet Ramey. @@ -336,7 +336,9 @@ file is taken from the value of the shell variable @env{INPUTRC}. If @ifclear BashFeatures file is taken from the value of the environment variable @env{INPUTRC}. If @end ifclear -that variable is unset, the default is @file{~/.inputrc}. +that variable is unset, the default is @file{~/.inputrc}. If that +file does not exist or cannot be read, the ultimate default is +@file{/etc/inputrc}. When a program which uses the Readline library starts up, the init file is read, and the key bindings are set. @@ -593,9 +595,11 @@ the command does. 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. The name of the key -can be expressed in different ways, depending on what you find most -comfortable. +command. +There can be no space between the key name and the colon -- that will be +interpreted as part of the key name. +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}). diff --git a/contrib/libreadline/doc/rluserman.texi b/contrib/libreadline/doc/rluserman.texi index db80b312611c..086aa83852fc 100644 --- a/contrib/libreadline/doc/rluserman.texi +++ b/contrib/libreadline/doc/rluserman.texi @@ -14,7 +14,7 @@ This manual describes the end user interface of the GNU Readline Library consistency of user interface across discrete programs which provide a command line interface. -Copyright @copyright{} 1988-2005 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2006 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -22,7 +22,7 @@ are preserved on all copies. @quotation Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or +under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the license is diff --git a/contrib/libreadline/doc/version.texi b/contrib/libreadline/doc/version.texi index 99816bf6807e..654e83777d50 100644 --- a/contrib/libreadline/doc/version.texi +++ b/contrib/libreadline/doc/version.texi @@ -1,10 +1,10 @@ @ignore -Copyright (C) 1988-2005 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. @end ignore -@set EDITION 5.1-beta1 -@set VERSION 5.1-beta1 -@set UPDATED 11 November 2005 -@set UPDATED-MONTH November 2005 +@set EDITION 5.2 +@set VERSION 5.2 +@set UPDATED 26 April 2006 +@set UPDATED-MONTH April 2006 -@set LASTCHANGE Fri Nov 11 19:50:51 EST 2005 +@set LASTCHANGE Wed Apr 26 09:22:57 EDT 2006 diff --git a/contrib/libreadline/examples/excallback.c b/contrib/libreadline/examples/excallback.c index 3d4bb189c691..385492b1b702 100644 --- a/contrib/libreadline/examples/excallback.c +++ b/contrib/libreadline/examples/excallback.c @@ -32,6 +32,9 @@ Let me know what you think. Jeff */ +/* +Copyright (C) 1999 Jeff Solomon +*/ #if defined (HAVE_CONFIG_H) #include diff --git a/contrib/libreadline/examples/rlfe/Makefile.in b/contrib/libreadline/examples/rlfe/Makefile.in index 4653dec4e9bd..70aa6b3175ee 100644 --- a/contrib/libreadline/examples/rlfe/Makefile.in +++ b/contrib/libreadline/examples/rlfe/Makefile.in @@ -25,7 +25,7 @@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ #LDFLAGS = -L$(READLINE_DIR) LDFLAGS = @LDFLAGS@ -LIBS = -lreadline -lhistory -lncurses +LIBS = -lreadline -lhistory -lncurses @LIBS@ CPP=@CPP@ CPP_DEPEND=$(CC) -MM diff --git a/contrib/libreadline/histexpand.c b/contrib/libreadline/histexpand.c index 684701469022..f46c0b2a45d8 100644 --- a/contrib/libreadline/histexpand.c +++ b/contrib/libreadline/histexpand.c @@ -56,8 +56,6 @@ 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; @@ -564,12 +562,12 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line) #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - int c, l; + int ch, l; l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY); - c = string[l]; + ch = string[l]; /* XXX - original patch had i - 1 ??? If i == 0 it would fail. */ - if (i && (c == '\'' || c == '"')) - quoted_search_delimiter = c; + if (i && (ch == '\'' || ch == '"')) + quoted_search_delimiter = ch; } else #endif /* HANDLE_MULTIBYTE */ @@ -1430,6 +1428,8 @@ history_tokenize_word (string, ind) { if (peek == '<' && string[i + 2] == '-') i++; + else if (peek == '<' && string[i + 2] == '<') + i++; i += 2; return i; } diff --git a/contrib/libreadline/histfile.c b/contrib/libreadline/histfile.c index 717bbee6fd73..2f051a325631 100644 --- a/contrib/libreadline/histfile.c +++ b/contrib/libreadline/histfile.c @@ -256,7 +256,11 @@ read_history_range (filename, from, to) for (line_end = line_start; line_end < bufend; line_end++) if (*line_end == '\n') { - *line_end = '\0'; + /* Change to allow Windows-like \r\n end of line delimiter. */ + if (line_end > line_start && line_end[-1] == '\r') + line_end[-1] = '\0'; + else + *line_end = '\0'; if (*line_start) { diff --git a/contrib/libreadline/history.c b/contrib/libreadline/history.c index a538f91c0d7b..1ccf4db786c6 100644 --- a/contrib/libreadline/history.c +++ b/contrib/libreadline/history.c @@ -209,6 +209,22 @@ history_get (offset) : the_history[local_index]; } +HIST_ENTRY * +alloc_history_entry (string, ts) + char *string; + char *ts; +{ + HIST_ENTRY *temp; + + temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); + + temp->line = string ? savestring (string) : string; + temp->data = (char *)NULL; + temp->timestamp = ts; + + return temp; +} + time_t history_get_time (hist) HIST_ENTRY *hist; @@ -290,11 +306,7 @@ add_history (string) } } - temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); - temp->line = savestring (string); - temp->data = (char *)NULL; - - temp->timestamp = hist_inittime (); + temp = alloc_history_entry (string, hist_inittime ()); the_history[history_length] = (HIST_ENTRY *)NULL; the_history[history_length - 1] = temp; @@ -328,6 +340,26 @@ free_history_entry (hist) free (hist); return (x); } + +HIST_ENTRY * +copy_history_entry (hist) + HIST_ENTRY *hist; +{ + HIST_ENTRY *ret; + char *ts; + + if (hist == 0) + return hist; + + ret = alloc_history_entry (hist->line, (char *)NULL); + + ts = hist->timestamp ? savestring (hist->timestamp) : hist->timestamp; + ret->timestamp = ts; + + ret->data = hist->data; + + return ret; +} /* Make the history entry at WHICH have LINE and DATA. This returns the old entry so you can dispose of the data. In the case of an @@ -354,6 +386,51 @@ replace_history_entry (which, line, data) return (old_value); } +/* Replace the DATA in the specified history entries, replacing OLD with + NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace + all of the history entries where entry->data == OLD; WHICH == -2 means + to replace the `newest' history entry where entry->data == OLD; and + WHICH >= 0 means to replace that particular history entry's data, as + long as it matches OLD. */ +void +replace_history_data (which,old, new) + int which; + histdata_t *old, *new; +{ + HIST_ENTRY *entry; + register int i, last; + + if (which < -2 || which >= history_length || history_length == 0 || the_history == 0) + return; + + if (which >= 0) + { + entry = the_history[which]; + if (entry && entry->data == old) + entry->data = new; + return; + } + + last = -1; + for (i = 0; i < history_length; i++) + { + entry = the_history[i]; + if (entry == 0) + continue; + if (entry->data == old) + { + last = i; + if (which == -1) + entry->data = new; + } + } + if (which == -2 && last >= 0) + { + entry = the_history[last]; + entry->data = new; /* XXX - we don't check entry->old */ + } +} + /* Remove history element WHICH from the history. The removed element is returned to you so you can free the line, data, and containing structure. */ diff --git a/contrib/libreadline/input.c b/contrib/libreadline/input.c index 0ec507ec27c5..da5d771c4818 100644 --- a/contrib/libreadline/input.c +++ b/contrib/libreadline/input.c @@ -179,6 +179,7 @@ rl_gather_tyi () struct timeval timeout; #endif + chars_avail = 0; tty = fileno (rl_instream); #if defined (HAVE_SELECT) @@ -220,6 +221,13 @@ rl_gather_tyi () } #endif /* O_NDELAY */ +#if defined (__MINGW32__) + /* Use getch/_kbhit to check for available console input, in the same way + that we read it normally. */ + chars_avail = isatty (tty) ? _kbhit () : 0; + result = 0; +#endif + /* If there's nothing available, don't waste time trying to read something. */ if (chars_avail <= 0) @@ -263,7 +271,7 @@ rl_set_keyboard_input_timeout (u) int o; o = _keyboard_input_timeout; - if (u > 0) + if (u >= 0) _keyboard_input_timeout = u; return (o); } @@ -303,6 +311,11 @@ _rl_input_available () return (chars_avail); #endif +#endif + +#if defined (__MINGW32__) + if (isatty (tty)) + return (_kbhit ()); #endif return 0; @@ -489,7 +502,7 @@ rl_getc (stream) this is simply an interrupted system call to read (). Otherwise, some error ocurred, also signifying EOF. */ if (errno != EINTR) - return (EOF); + return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF); } } @@ -537,21 +550,21 @@ _rl_read_mbchar (mbchar, size) } /* Read a multibyte-character string whose first character is FIRST into - the buffer MB of length MBLEN. Returns the last character read, which + the buffer MB of length MLEN. Returns the last character read, which may be FIRST. Used by the search functions, among others. Very similar to _rl_read_mbchar. */ int -_rl_read_mbstring (first, mb, mblen) +_rl_read_mbstring (first, mb, mlen) int first; char *mb; - int mblen; + int mlen; { int i, c; mbstate_t ps; c = first; - memset (mb, 0, mblen); - for (i = 0; i < mblen; i++) + memset (mb, 0, mlen); + for (i = 0; i < mlen; i++) { mb[i] = (char)c; memset (&ps, 0, sizeof (mbstate_t)); diff --git a/contrib/libreadline/isearch.c b/contrib/libreadline/isearch.c index d7d8520ed859..9f67bfc08018 100644 --- a/contrib/libreadline/isearch.c +++ b/contrib/libreadline/isearch.c @@ -68,8 +68,8 @@ static void _rl_isearch_fini PARAMS((_rl_search_cxt *)); static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, 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; + identical lines many times in a row. Now part of isearch context. */ +/* static char *prev_line_found; */ /* Last search string and its length. */ static char *last_isearch_string; diff --git a/contrib/libreadline/kill.c b/contrib/libreadline/kill.c index 1d3254c3275d..031ddf47c5ba 100644 --- a/contrib/libreadline/kill.c +++ b/contrib/libreadline/kill.c @@ -582,6 +582,7 @@ rl_yank_nth_arg_internal (count, ignore, history_skip) if (!arg || !*arg) { rl_ding (); + FREE (arg); return -1; } diff --git a/contrib/libreadline/macro.c b/contrib/libreadline/macro.c index 2975bf1f74fa..00cd58d628c0 100644 --- a/contrib/libreadline/macro.c +++ b/contrib/libreadline/macro.c @@ -113,7 +113,7 @@ _rl_next_macro_key () #if defined (READLINE_CALLBACKS) c = rl_executing_macro[executing_macro_index++]; - if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD) && rl_executing_macro[executing_macro_index] == 0) + if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD|RL_STATE_MOREINPUT) && rl_executing_macro[executing_macro_index] == 0) _rl_pop_executing_macro (); return c; #else diff --git a/contrib/libreadline/misc.c b/contrib/libreadline/misc.c index d4558321dec5..94ecb25900a0 100644 --- a/contrib/libreadline/misc.c +++ b/contrib/libreadline/misc.c @@ -212,6 +212,8 @@ rl_digit_loop () if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)) break; } + + return r; } /* Create a default argument. */ diff --git a/contrib/libreadline/readline.c b/contrib/libreadline/readline.c index 5eaaf47435e6..c2b74006b050 100644 --- a/contrib/libreadline/readline.c +++ b/contrib/libreadline/readline.c @@ -49,6 +49,11 @@ #include #include "posixjmp.h" +#include + +#if !defined (errno) +extern int errno; +#endif /* !errno */ /* System-specific feature definitions and include files. */ #include "rldefs.h" @@ -479,6 +484,20 @@ readline_internal_charloop () c = rl_read_key (); RL_UNSETSTATE(RL_STATE_READCMD); + /* look at input.c:rl_getc() for the circumstances under which this will + be returned; punt immediately on read error without converting it to + a newline. */ + if (c == READERR) + { +#if defined (READLINE_CALLBACKS) + RL_SETSTATE(RL_STATE_DONE); + return (rl_done = 1); +#else + eof_found = 1; + break; +#endif + } + /* EOF typed to a non-blank line is a . */ if (c == EOF && rl_end) c = NEWLINE; diff --git a/contrib/libreadline/readline.h b/contrib/libreadline/readline.h index fade6d41d2f9..b71bf98d204d 100644 --- a/contrib/libreadline/readline.h +++ b/contrib/libreadline/readline.h @@ -40,9 +40,9 @@ extern "C" { #endif /* Hex-encoded Readline version number. */ -#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */ +#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */ #define RL_VERSION_MAJOR 5 -#define RL_VERSION_MINOR 1 +#define RL_VERSION_MINOR 2 /* Readline data structures. */ @@ -757,6 +757,10 @@ extern int rl_ignore_completion_duplicates; completion character will be inserted as any other. */ extern int rl_inhibit_completion; +/* Input error; can be returned by (*rl_getc_function) if readline is reading + a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */ +#define READERR (-2) + /* Definitions available for use by readline clients. */ #define RL_PROMPT_START_IGNORE '\001' #define RL_PROMPT_END_IGNORE '\002' diff --git a/contrib/libreadline/rlconf.h b/contrib/libreadline/rlconf.h index c651fd8b41f6..ff3929e0bf55 100644 --- a/contrib/libreadline/rlconf.h +++ b/contrib/libreadline/rlconf.h @@ -37,9 +37,12 @@ /* Ugly but working hack for binding prefix meta. */ #define PREFIX_META_HACK -/* The final, last-ditch effort file name for an init file. */ +/* The next-to-last-ditch effort file name for a user-specific init file. */ #define DEFAULT_INPUTRC "~/.inputrc" +/* The ultimate last-ditch filenname for an init file -- system-wide. */ +#define SYS_INPUTRC "/etc/inputrc" + /* If defined, expand tabs to spaces. */ #define DISPLAY_TABS diff --git a/contrib/libreadline/rlmbutil.h b/contrib/libreadline/rlmbutil.h index 11adacb45ead..dd317e2a090c 100644 --- a/contrib/libreadline/rlmbutil.h +++ b/contrib/libreadline/rlmbutil.h @@ -32,10 +32,19 @@ /* For platforms which support the ISO C amendement 1 functionality we support user defined character classes. */ /* Solaris 2.5 has a bug: must be included before . */ -#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) +#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H) # include # include -# if defined (HAVE_MBSRTOWCS) && defined (HAVE_MBRTOWC) && defined (HAVE_MBRLEN) && defined (HAVE_WCWIDTH) +# if defined (HAVE_ISWCTYPE) && \ + defined (HAVE_ISWLOWER) && \ + defined (HAVE_ISWUPPER) && \ + defined (HAVE_MBSRTOWCS) && \ + defined (HAVE_MBRTOWC) && \ + defined (HAVE_MBRLEN) && \ + defined (HAVE_TOWLOWER) && \ + defined (HAVE_TOWUPPER) && \ + defined (HAVE_WCHAR_T) && \ + defined (HAVE_WCWIDTH) /* system is supposed to support XPG5 */ # define HANDLE_MULTIBYTE 1 # endif diff --git a/contrib/libreadline/rlprivate.h b/contrib/libreadline/rlprivate.h index 1c216ead14f7..64aa7bdd3fa4 100644 --- a/contrib/libreadline/rlprivate.h +++ b/contrib/libreadline/rlprivate.h @@ -309,6 +309,10 @@ extern int _rl_char_search_internal PARAMS((int, int, int)); #endif extern int _rl_set_mark_at_pos PARAMS((int)); +/* undo.c */ +extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *)); +extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *)); + /* util.c */ extern int _rl_abort_internal PARAMS((void)); extern char *_rl_strindex PARAMS((const char *, const char *)); @@ -404,6 +408,7 @@ extern char *_rl_term_up; extern char *_rl_term_dc; extern char *_rl_term_cr; extern char *_rl_term_IC; +extern char *_rl_term_forward_char; extern int _rl_screenheight; extern int _rl_screenwidth; extern int _rl_screenchars; diff --git a/contrib/libreadline/rltty.c b/contrib/libreadline/rltty.c index 9a0326ed2095..0a570f85840c 100644 --- a/contrib/libreadline/rltty.c +++ b/contrib/libreadline/rltty.c @@ -933,7 +933,6 @@ rltty_set_default_bindings (kmap) #if !defined (NO_TTY_DRIVER) TIOTYPE ttybuff; int tty; - static int called = 0; tty = fileno (rl_instream); diff --git a/contrib/libreadline/search.c b/contrib/libreadline/search.c index 8013916c20ea..33cc4fc1e736 100644 --- a/contrib/libreadline/search.c +++ b/contrib/libreadline/search.c @@ -70,7 +70,6 @@ static int rl_history_search_pos; static char *history_search_string; static int history_string_size; -static UNDO_LIST *noninc_saved_undo_list; static void make_history_line_current PARAMS((HIST_ENTRY *)); static int noninc_search_from_pos PARAMS((char *, int, int)); static int noninc_dosearch PARAMS((char *, int)); @@ -212,7 +211,7 @@ _rl_nsearch_init (dir, pchar) rl_end = rl_point = 0; p = _rl_make_prompt_for_search (pchar ? pchar : ':'); - rl_message (p, 0, 0); + rl_message ("%s", p, 0); free (p); RL_SETSTATE(RL_STATE_NSEARCH); diff --git a/contrib/libreadline/signals.c b/contrib/libreadline/signals.c index f344ed834975..54f2a642846d 100644 --- a/contrib/libreadline/signals.c +++ b/contrib/libreadline/signals.c @@ -160,6 +160,7 @@ rl_signal_handler (sig) rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) + sigemptyset (&set); sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set); sigdelset (&set, sig); #else /* !HAVE_POSIX_SIGNALS */ @@ -288,9 +289,44 @@ rl_set_signals () { sighandler_cxt dummy; SigHandler *oh; +#if defined (HAVE_POSIX_SIGNALS) + static int sigmask_set = 0; + static sigset_t bset, oset; +#endif + +#if defined (HAVE_POSIX_SIGNALS) + if (rl_catch_signals && sigmask_set == 0) + { + sigemptyset (&bset); + + sigaddset (&bset, SIGINT); + sigaddset (&bset, SIGINT); +#if defined (SIGQUIT) + sigaddset (&bset, SIGQUIT); +#endif +#if defined (SIGALRM) + sigaddset (&bset, SIGALRM); +#endif +#if defined (SIGTSTP) + sigaddset (&bset, SIGTSTP); +#endif +#if defined (SIGTTIN) + sigaddset (&bset, SIGTTIN); +#endif +#if defined (SIGTTOU) + sigaddset (&bset, SIGTTOU); +#endif + sigmask_set = 1; + } +#endif /* HAVE_POSIX_SIGNALS */ if (rl_catch_signals && signals_set_flag == 0) { +#if defined (HAVE_POSIX_SIGNALS) + sigemptyset (&oset); + sigprocmask (SIG_BLOCK, &bset, &oset); +#endif + rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int); rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term); #if defined (SIGQUIT) @@ -324,6 +360,10 @@ rl_set_signals () #endif /* SIGTTIN */ signals_set_flag = 1; + +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); +#endif } #if defined (SIGWINCH) @@ -390,8 +430,8 @@ rl_cleanup_after_signal () _rl_clean_up_for_exit (); if (rl_deprep_term_function) (*rl_deprep_term_function) (); - rl_clear_signals (); rl_clear_pending_input (); + rl_clear_signals (); } /* Reset the terminal and readline state after a signal handler returns. */ diff --git a/contrib/libreadline/support/shlib-install b/contrib/libreadline/support/shlib-install index 2cd252a36580..790f53e6c23e 100755 --- a/contrib/libreadline/support/shlib-install +++ b/contrib/libreadline/support/shlib-install @@ -65,10 +65,11 @@ fi # post-install/uninstall # HP-UX and Darwin/MacOS X require that a shared library have execute permission +# Linux does, too, and ldd warns about it # Cygwin installs both a dll (which must go in $BINDIR) and an implicit # link library (in $libdir) case "$host_os" in -hpux*|darwin*|macosx*) +hpux*|darwin*|macosx*|linux*) if [ -z "$uninstall" ]; then chmod 555 ${INSTALLDIR}/${LIBNAME} fi ;; diff --git a/contrib/libreadline/support/shobj-conf b/contrib/libreadline/support/shobj-conf index 0e306bc1a721..ef7863a3bc40 100755 --- a/contrib/libreadline/support/shobj-conf +++ b/contrib/libreadline/support/shobj-conf @@ -142,6 +142,23 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*) ;; # Darwin/MacOS X +darwin8*) + SHOBJ_STATUS=supported + SHLIB_STATUS=supported + + SHOBJ_CFLAGS='-fno-common' + + SHOBJ_LD='MACOSX_DEPLOYMENT_TARGET=10.3 ${CC}' + + SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)' + SHLIB_LIBSUFF='dylib' + + SHOBJ_LDFLAGS='-undefined dynamic_lookup' + SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' + + SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1 + ;; + darwin*|macosx*) SHOBJ_STATUS=unsupported SHLIB_STATUS=supported diff --git a/contrib/libreadline/terminal.c b/contrib/libreadline/terminal.c index eb72c19ca019..547f6f5dfe5f 100644 --- a/contrib/libreadline/terminal.c +++ b/contrib/libreadline/terminal.c @@ -1,6 +1,6 @@ /* terminal.c -- controlling the terminal with termcap. */ -/* Copyright (C) 1996-2005 Free Software Foundation, Inc. +/* Copyright (C) 1996-2006 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. @@ -66,10 +66,24 @@ #include "rlshell.h" #include "xmalloc.h" +#if defined (__MINGW32__) +# include +# include + +static void _win_get_screensize PARAMS((int *, int *)); +#endif + +#if defined (__EMX__) +static void _emx_get_screensize PARAMS((int *, int *)); +#endif + #define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) #define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) -int rl_prefer_env_winsize; +/* If the calling application sets this to a non-zero value, readline will + use the $LINES and $COLUMNS environment variables to set its idea of the + window size before interrogating the kernel. */ +int rl_prefer_env_winsize = 0; /* **************************************************************** */ /* */ @@ -111,9 +125,7 @@ char *_rl_term_IC; char *_rl_term_dc; char *_rl_term_DC; -#if defined (HACK_TERMCAP_MOTION) char *_rl_term_forward_char; -#endif /* HACK_TERMCAP_MOTION */ /* How to go up a line. */ char *_rl_term_up; @@ -184,6 +196,26 @@ _emx_get_screensize (swp, shp) } #endif +#if defined (__MINGW32__) +static void +_win_get_screensize (swp, shp) + int *swp, *shp; +{ + HANDLE hConOut; + CONSOLE_SCREEN_BUFFER_INFO scr; + + hConOut = GetStdHandle (STD_OUTPUT_HANDLE); + if (hConOut != INVALID_HANDLE_VALUE) + { + if (GetConsoleScreenBufferInfo (hConOut, &scr)) + { + *swp = scr.dwSize.X; + *shp = scr.srWindow.Bottom - scr.srWindow.Top + 1; + } + } +} +#endif + /* 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 @@ -208,7 +240,9 @@ _rl_get_screen_size (tty, ignore_env) #endif /* TIOCGWINSZ */ #if defined (__EMX__) - _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight); + _emx_get_screensize (&wc, &wr); +#elif defined (__MINGW32__) + _win_get_screensize (&wc, &wr); #endif if (ignore_env || rl_prefer_env_winsize == 0) @@ -358,9 +392,7 @@ static struct _tc_string tc_strings[] = { "le", &_rl_term_backspace }, { "mm", &_rl_term_mm }, { "mo", &_rl_term_mo }, -#if defined (HACK_TERMCAP_MOTION) { "nd", &_rl_term_forward_char }, -#endif { "pc", &_rl_term_pc }, { "up", &_rl_term_up }, { "vb", &_rl_visible_bell }, @@ -457,9 +489,7 @@ _rl_init_terminal_io (terminal_name) _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 + _rl_term_forward_char = (char *)NULL; _rl_terminal_can_insert = term_has_meta = 0; /* Reasonable defaults for tgoto(). Readline currently only uses diff --git a/contrib/libreadline/text.c b/contrib/libreadline/text.c index bb87604aa6d4..399a48c5f1e7 100644 --- a/contrib/libreadline/text.c +++ b/contrib/libreadline/text.c @@ -1071,6 +1071,8 @@ int rl_delete (count, key) int count, key; { + int xpoint; + if (count < 0) return (_rl_rubout_char (-count, key)); @@ -1082,21 +1084,19 @@ rl_delete (count, key) if (count > 1 || rl_explicit_arg) { - int orig_point = rl_point; + xpoint = rl_point; if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) rl_forward_char (count, key); else rl_forward_byte (count, key); - rl_kill_text (orig_point, rl_point); - rl_point = orig_point; + rl_kill_text (xpoint, rl_point); + rl_point = xpoint; } else { - int new_point; - - new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); - rl_delete_text (rl_point, new_point); + xpoint = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); + rl_delete_text (rl_point, xpoint); } return 0; } @@ -1237,8 +1237,8 @@ rl_change_case (count, op) #if defined (HANDLE_MULTIBYTE) wchar_t wc, nwc; char mb[MB_LEN_MAX+1]; - int mblen, p; - mbstate_t ps; + int mlen; + mbstate_t mps; #endif start = rl_point; @@ -1255,7 +1255,7 @@ rl_change_case (count, op) SWAP (start, end); #if defined (HANDLE_MULTIBYTE) - memset (&ps, 0, sizeof (mbstate_t)); + memset (&mps, 0, sizeof (mbstate_t)); #endif /* We are going to modify some text, so let's prepare to undo it. */ @@ -1290,15 +1290,15 @@ rl_change_case (count, op) #if defined (HANDLE_MULTIBYTE) else { - mbrtowc (&wc, rl_line_buffer + start, end - start, &ps); + mbrtowc (&wc, rl_line_buffer + start, end - start, &mps); nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc); if (nwc != wc) /* just skip unchanged characters */ { - mblen = wcrtomb (mb, nwc, &ps); - if (mblen > 0) - mb[mblen] = '\0'; + mlen = wcrtomb (mb, nwc, &mps); + if (mlen > 0) + mb[mlen] = '\0'; /* Assume the same width */ - strncpy (rl_line_buffer + start, mb, mblen); + strncpy (rl_line_buffer + start, mb, mlen); } } #endif diff --git a/contrib/libreadline/tilde.c b/contrib/libreadline/tilde.c index d757f7a9d70e..1b76c9f24047 100644 --- a/contrib/libreadline/tilde.c +++ b/contrib/libreadline/tilde.c @@ -404,17 +404,17 @@ tilde_expand_word (filename) free (expansion); } } - 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); } +#if defined (HAVE_GETPWENT) else - { - free (username); - dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); - } + dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); +#endif + + free (username); #if defined (HAVE_GETPWENT) endpwent (); #endif diff --git a/contrib/libreadline/undo.c b/contrib/libreadline/undo.c index fedfa121fc0d..9d9bd25ba8f6 100644 --- a/contrib/libreadline/undo.c +++ b/contrib/libreadline/undo.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, 1989, 1992, 2006 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. @@ -50,6 +50,8 @@ #include "rlprivate.h" #include "xmalloc.h" +extern void replace_history_data PARAMS((int, histdata_t *, histdata_t *)); + /* Non-zero tells rl_delete_text and rl_insert_text to not add to the undo list. */ int _rl_doing_an_undo = 0; @@ -66,6 +68,24 @@ UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL; /* */ /* **************************************************************** */ +static UNDO_LIST * +alloc_undo_entry (what, start, end, text) + enum undo_code what; + int start, end; + char *text; +{ + UNDO_LIST *temp; + + temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST)); + temp->what = what; + temp->start = start; + temp->end = end; + temp->text = text; + + temp->next = (UNDO_LIST *)NULL; + return temp; +} + /* Remember how to undo something. Concatenate some undos if that seems right. */ void @@ -74,11 +94,9 @@ rl_add_undo (what, start, end, text) int start, end; char *text; { - UNDO_LIST *temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST)); - temp->what = what; - temp->start = start; - temp->end = end; - temp->text = text; + UNDO_LIST *temp; + + temp = alloc_undo_entry (what, start, end, text); temp->next = rl_undo_list; rl_undo_list = temp; } @@ -87,9 +105,12 @@ rl_add_undo (what, start, end, text) void rl_free_undo_list () { + UNDO_LIST *release, *orig_list; + + orig_list = rl_undo_list; while (rl_undo_list) { - UNDO_LIST *release = rl_undo_list; + release = rl_undo_list; rl_undo_list = rl_undo_list->next; if (release->what == UNDO_DELETE) @@ -98,6 +119,43 @@ rl_free_undo_list () free (release); } rl_undo_list = (UNDO_LIST *)NULL; + replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL); +} + +UNDO_LIST * +_rl_copy_undo_entry (entry) + UNDO_LIST *entry; +{ + UNDO_LIST *new; + + new = alloc_undo_entry (entry->what, entry->start, entry->end, (char *)NULL); + new->text = entry->text ? savestring (entry->text) : 0; + return new; +} + +UNDO_LIST * +_rl_copy_undo_list (head) + UNDO_LIST *head; +{ + UNDO_LIST *list, *new, *roving, *c; + + list = head; + new = 0; + while (list) + { + c = _rl_copy_undo_entry (list); + if (new == 0) + roving = new = c; + else + { + roving->next = c; + roving = roving->next; + } + list = list->next; + } + + roving->next = 0; + return new; } /* Undo the next thing in the list. Return 0 if there @@ -161,6 +219,8 @@ rl_do_undo () release = rl_undo_list; rl_undo_list = rl_undo_list->next; + replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list); + free (release); } while (waiting_for_begin); diff --git a/contrib/libreadline/vi_mode.c b/contrib/libreadline/vi_mode.c index ac5fd7446dcf..d0b7e330adc4 100644 --- a/contrib/libreadline/vi_mode.c +++ b/contrib/libreadline/vi_mode.c @@ -109,12 +109,16 @@ static int vi_mark_chars['z' - 'a' + 1]; static void _rl_vi_stuff_insert PARAMS((int)); static void _rl_vi_save_insert PARAMS((UNDO_LIST *)); +static void _rl_vi_backup PARAMS((void)); + static int _rl_vi_arg_dispatch PARAMS((int)); static int rl_digit_loop1 PARAMS((void)); static int _rl_vi_set_mark PARAMS((void)); static int _rl_vi_goto_mark PARAMS((void)); +static void _rl_vi_append_forward PARAMS((int)); + static int _rl_vi_callback_getchar PARAMS((char *, int)); #if defined (READLINE_CALLBACKS) @@ -205,7 +209,16 @@ rl_vi_redo (count, c) _rl_vi_stuff_insert (count); /* And back up point over the last character inserted. */ if (rl_point > 0) - rl_point--; + _rl_vi_backup (); + } + /* Ditto for redoing an insert with `a', but move forward a character first + like the `a' command does. */ + else if (_rl_vi_last_command == 'a' && vi_insert_buffer && *vi_insert_buffer) + { + _rl_vi_append_forward ('a'); + _rl_vi_stuff_insert (count); + if (rl_point > 0) + _rl_vi_backup (); } else r = _rl_dispatch (_rl_vi_last_command, _rl_keymap); @@ -575,23 +588,32 @@ rl_vi_insert_beg (count, key) return (0); } -int -rl_vi_append_mode (count, key) - int count, key; +static void +_rl_vi_append_forward (key) + int key; { + int point; + if (rl_point < rl_end) { if (MB_CUR_MAX == 1 || rl_byte_oriented) rl_point++; else { - int point = rl_point; + point = rl_point; rl_forward_char (1, key); if (point == rl_point) rl_point = rl_end; } } - rl_vi_insertion_mode (1, key); +} + +int +rl_vi_append_mode (count, key) + int count, key; +{ + _rl_vi_append_forward (key); + rl_vi_start_inserting (key, 1, rl_arg_sign); return (0); } @@ -631,7 +653,7 @@ _rl_vi_save_insert (up) { int len, start, end; - if (up == 0) + if (up == 0 || up->what != UNDO_INSERT) { if (vi_insert_buffer_size >= 1) vi_insert_buffer[0] = '\0'; @@ -716,7 +738,7 @@ _rl_vi_change_mbchar_case (count) { wchar_t wc; char mb[MB_LEN_MAX+1]; - int mblen, p; + int mlen, p; mbstate_t ps; memset (&ps, 0, sizeof (mbstate_t)); @@ -740,9 +762,9 @@ _rl_vi_change_mbchar_case (count) if (wc) { p = rl_point; - mblen = wcrtomb (mb, wc, &ps); - if (mblen >= 0) - mb[mblen] = '\0'; + mlen = wcrtomb (mb, wc, &ps); + if (mlen >= 0) + mb[mlen] = '\0'; rl_begin_undo_group (); rl_vi_delete (1, 0); if (rl_point < p) /* Did we retreat at EOL? */ @@ -820,6 +842,15 @@ rl_vi_put (count, key) return (0); } +static void +_rl_vi_backup () +{ + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); + else + rl_point--; +} + int rl_vi_check () { @@ -1111,7 +1142,7 @@ int rl_vi_rubout (count, key) int count, key; { - int p, opoint; + int opoint; if (count < 0) return (rl_vi_delete (-count, key)); @@ -1426,9 +1457,9 @@ _rl_vi_change_char (count, c, mb) } static int -_rl_vi_callback_getchar (mb, mblen) +_rl_vi_callback_getchar (mb, mlen) char *mb; - int mblen; + int mlen; { int c; @@ -1438,7 +1469,7 @@ _rl_vi_callback_getchar (mb, mblen) #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - c = _rl_read_mbstring (c, mb, mblen); + c = _rl_read_mbstring (c, mb, mlen); #endif return c;