Update of /cvsroot/winbash/winbash/lib/readline
In directory usw-pr-cvs1:/tmp/cvs-serv14844/lib/readline
Modified Files:
complete.c display.c history.c keymaps.c readline.c rltty.c
search.c tilde.c
Log Message:
Applied 1.14.3 diffs from GNU bash
Index: complete.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/complete.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- complete.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ complete.c 9 Mar 2002 16:05:43 -0000 1.2
@@ -21,6 +21,10 @@
675 Mass Ave, Cambridge, MA 02139, USA. */
#define READLINE_LIBRARY
+#if defined (HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
@@ -592,8 +596,12 @@
/* Sort the items. */
/* It is safe to sort this array, because the lowest common
denominator found in matches[0] will remain in place. */
- //for (i = 1; matches[i]; i++);
- //qsort (matches, i, sizeof (char *), compare_strings);
+ for (i = 0; matches[i]; i++)
+ ;
+ /* Try sorting the array without matches[0], since we need it to
+ stay in place no matter what. */
+ if (i)
+ qsort (matches+1, i-1, sizeof (char *), compare_strings);
/* Remember the lowest common denominator for it may be unique. */
lowest_common = savestring (matches[0]);
@@ -898,19 +906,18 @@
count = (len + (limit - 1)) / limit;
/* Watch out for special case. If LEN is less than LIMIT, then
- just do the inner printing loop. */
- if (len < limit)
- count = 1;
+ just do the inner printing loop.
+ 0 < len <= limit implies count = 1. */
/* Sort the items if they are not already sorted. */
if (!rl_ignore_completion_duplicates)
- qsort (matches, len, sizeof (char *), compare_strings);
+ qsort (matches + 1, len - 1, sizeof (char *), compare_strings);
/* Print the sorted items, up-and-down alphabetically, like
ls might. */
crlf ();
- for (i = 1; i < count + 1; i++)
+ for (i = 1; i <= count; i++)
{
for (j = 0, l = i; j < limit; j++)
{
@@ -1054,8 +1061,11 @@
while (entry = getpwent ())
{
- if ((username[0] == entry->pw_name[0]) &&
- (strncmp (username, entry->pw_name, namelen) == 0))
+ /* Null usernames should result in all users as possible completions. */
+ if (namelen == 0)
+ break;
+ else if ((username[0] == entry->pw_name[0]) &&
+ (strncmp (username, entry->pw_name, namelen) == 0))
break;
}
Index: display.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- display.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ display.c 9 Mar 2002 16:05:43 -0000 1.2
@@ -21,6 +21,10 @@
675 Mass Ave, Cambridge, MA 02139, USA. */
#define READLINE_LIBRARY
+#if defined (HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
#include <stdio.h>
#include <sys/types.h>
@@ -471,7 +475,8 @@
(_rl_last_c_pos < visible_first_line_len))
{
nleft = screenwidth + wrap_offset - _rl_last_c_pos;
- clear_to_eol (nleft);
+ if (nleft)
+ clear_to_eol (nleft);
}
/* Since the new first line is now visible, save its length. */
@@ -497,7 +502,7 @@
/* Move the cursor where it should be. */
/* Which line? */
- nleft = c_pos - wrap_offset - term_xn + 1;
+ nleft = c_pos - wrap_offset + term_xn - 1;
cursor_linenum = (nleft > 0) ? nleft / screenwidth : 0;
/* CHANGED_SCREEN_LINE is set to 1 if we have moved to a
Index: history.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/history.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- history.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ history.c 9 Mar 2002 16:05:43 -0000 1.2
@@ -1540,9 +1540,9 @@
j += sl; \
if (j >= result_len) \
{ \
- while (j >= result_len) \
- result_len += 128; \
- result = xrealloc (result, result_len); \
+ while (j >= result_len) \
+ result_len += 128; \
+ result = xrealloc (result, result_len); \
} \
strcpy (result + j - sl, s); \
} \
@@ -1910,13 +1910,14 @@
last++;
- if (first > len || last > len || first < 0 || last < 0)
+ if (first >= len || last > len || first < 0 || last < 0 || first > last)
result = ((char *)NULL);
else
{
for (size = 0, i = first; i < last; i++)
size += strlen (list[i]) + 1;
result = xmalloc (size + 1);
+ result[0] = '\0';
for (i = first; i < last; i++)
{
Index: keymaps.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/keymaps.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- keymaps.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ keymaps.c 9 Mar 2002 16:05:43 -0000 1.2
@@ -20,6 +20,10 @@
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define READLINE_LIBRARY
+#if defined (HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
@@ -101,7 +105,7 @@
newmap = rl_make_bare_keymap ();
/* All ASCII printing characters are self-inserting. */
- for (i = ' '; i < 126; i++)
+ for (i = ' '; i < 127; i++)
newmap[i].function = rl_insert;
newmap[TAB].function = rl_insert;
Index: readline.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/readline.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- readline.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ readline.c 9 Mar 2002 16:05:43 -0000 1.2
@@ -624,13 +624,13 @@
Keymap map;
{
int r = 0;
- if (defining_kbd_macro)
- add_macro_char (key);
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
{
if (map[ESC].type == ISKMAP)
{
+ if (defining_kbd_macro)
+ add_macro_char (ESC);
map = FUNCTION_TO_KEYMAP (map, ESC);
key = UNMETA (key);
rl_key_sequence_length += 2;
@@ -643,10 +643,7 @@
if (defining_kbd_macro)
add_macro_char (key);
-
- if (defining_kbd_macro)
- add_macro_char (key);
-
+
switch (map[key].type)
{
case ISFUNC:
@@ -927,8 +924,6 @@
/* Initliaze readline (and terminal if not already). */
rl_initialize ()
{
- char *t;
-
/* If we have never been called before, initialize the
terminal and data structures. */
if (!rl_initialized)
@@ -945,16 +940,6 @@
/* We aren't done yet. We haven't even gotten started yet! */
rl_done = 0;
- /* Check for LC_CTYPE and use its value to decide the defaults for
- 8-bit character input and output. */
- t = getenv ("LC_CTYPE");
- if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0))
- {
- _rl_meta_flag = 1;
- _rl_convert_meta_chars_to_ascii = 0;
- _rl_output_meta_chars = 1;
- }
-
/* Tell the history routines what is going on. */
start_using_history ();
@@ -1006,6 +991,16 @@
/* Initialize the function names. */
rl_initialize_funmap ();
+ /* Check for LC_CTYPE and use its value to decide the defaults for
+ 8-bit character input and output. */
+ t = getenv ("LC_CTYPE");
+ if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0))
+ {
+ _rl_meta_flag = 1;
+ _rl_convert_meta_chars_to_ascii = 0;
+ _rl_output_meta_chars = 1;
+ }
+
/* Read in the init file. */
rl_read_init_file ((char *)NULL);
@@ -1760,6 +1755,10 @@
from = to;
to = t;
}
+
+ if (to > rl_end)
+ to = rl_end;
+
text = rl_copy_text (from, to);
/* Some versions of strncpy() can't handle overlapping arguments. */
@@ -2313,14 +2312,20 @@
else
{
int orig_point = rl_point;
-
- while (rl_point && whitespace (the_line[rl_point - 1]))
- rl_point--;
-
- while (rl_point && !whitespace (the_line[rl_point - 1]))
- rl_point--;
-
+ if (count <= 0)
+ count = 1;
+
+ while (count--)
+ {
+ while (rl_point && whitespace (the_line[rl_point - 1]))
+ rl_point--;
+
+ while (rl_point && !whitespace (the_line[rl_point - 1]))
+ rl_point--;
+ }
+
rl_kill_text (orig_point, rl_point);
+
}
return 0;
}
@@ -2439,7 +2444,7 @@
break;
default:
- abort ();
+ ding ();
return -1;
}
}
Index: rltty.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/rltty.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- rltty.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ rltty.c 9 Mar 2002 16:05:44 -0000 1.2
@@ -22,6 +22,10 @@
675 Mass Ave, Cambridge, MA 02139, USA. */
#define READLINE_LIBRARY
+#if defined (HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
@@ -149,6 +153,7 @@
#endif
}
+#if 0
static void
control_keypad (on)
int on;
@@ -160,6 +165,7 @@
tputs (term_ke, 1, outchar);
#endif
}
+#endif
/* **************************************************************** */
/* */
@@ -414,6 +420,7 @@
int tty;
TIOTYPE *tiop;
{
+ int ioctl_ret;
#if !defined (SHELL) && defined (TIOCGWINSZ)
struct winsize w;
@@ -423,12 +430,12 @@
/* Keep looping if output is being flushed after a ^O (or whatever
the flush character is). */
- while (GETATTR (tty, tiop) < 0 || OUTPUT_BEING_FLUSHED (tiop))
+ while ((ioctl_ret = GETATTR (tty, tiop)) < 0 || OUTPUT_BEING_FLUSHED (tiop))
{
+ if (ioctl_ret < 0 && errno != EINTR)
+ return -1;
if (OUTPUT_BEING_FLUSHED (tiop))
continue;
- if (errno != EINTR)
- return -1;
errno = 0;
}
return 0;
@@ -564,7 +571,9 @@
}
control_meta_key (1);
+#if 0
control_keypad (1);
+#endif
fflush (rl_outstream);
terminal_prepped = 1;
@@ -586,7 +595,9 @@
block_sigint ();
control_meta_key (0);
+#if 0
control_keypad (0);
+#endif
fflush (rl_outstream);
if (set_tty_settings (tty, &otio) < 0)
Index: search.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/search.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- search.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ search.c 9 Mar 2002 16:05:44 -0000 1.2
@@ -29,7 +29,6 @@
# include <unistd.h>
#endif
-#include "memalloc.h"
#include "rldefs.h"
#include "readline.h"
#include "history.h"
@@ -44,6 +43,7 @@
/* Variables imported from readline.c */
extern int rl_point, rl_end, rl_line_buffer_len;
extern Keymap _rl_keymap;
+extern int rl_editing_mode;
extern char *rl_prompt;
extern char *rl_line_buffer;
extern HIST_ENTRY *saved_line_for_history;
@@ -94,7 +94,7 @@
int oldpos, pos;
HIST_ENTRY *entry;
- if (string == 0 || *string == 0 || noninc_history_pos < 0)
+ if (string == 0 || *string == '\0' || noninc_history_pos < 0)
{
ding ();
return;
@@ -116,6 +116,9 @@
oldpos = where_history ();
history_set_pos (noninc_history_pos);
entry = current_history ();
+#if defined (VI_MODE)
+ if (rl_editing_mode != vi_mode)
+#endif
history_set_pos (oldpos);
{
Index: tilde.c
===================================================================
RCS file: /cvsroot/winbash/winbash/lib/readline/tilde.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- tilde.c 9 Mar 2002 03:39:13 -0000 1.1.1.1
+++ tilde.c 9 Mar 2002 16:05:44 -0000 1.2
@@ -19,8 +19,6 @@
along with Readline; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include "memalloc.h"
-
#if defined (HAVE_STRING_H)
# include <string.h>
#else /* !HAVE_STRING_H */
@@ -34,6 +32,7 @@
#endif /* HAVE_STDLIB_H */
#include "tilde.h"
+#include <sys/types.h>
#include <pwd.h>
#if defined (USG) && !defined (HAVE_GETPW_DECLS)
@@ -251,22 +250,16 @@
}
else
{
- char u_name[257];
- struct passwd *user_entry;
char *username;
- int i, c;
+ struct passwd *user_entry;
+ int i;
- username = u_name;
- for (i = 1; c = dirname[i]; i++)
- {
- if (c == '/')
- break;
- else
- username[i - 1] = c;
- }
+ username = xmalloc (strlen (dirname));
+ for (i = 1; dirname[i] && dirname[i] != '/'; i++)
+ username[i - 1] = dirname[i];
username[i - 1] = '\0';
- if (!(user_entry = getpwnam (username)))
+ if ((user_entry = getpwnam (username)) == 0)
{
/* If the calling program has a special syntax for
expanding tildes, and we couldn't find a standard
@@ -299,7 +292,8 @@
free (dirname);
dirname = temp_name;
}
- endpwent ();
+ endpwent ();
+ free (username);
}
}
return (dirname);
|