Bash-4.0 patchlevel 38

This commit is contained in:
Chet Ramey 2011-11-21 20:49:12 -05:00
commit 89a92869e5
27 changed files with 490 additions and 164 deletions

View file

@ -356,7 +356,7 @@ finddirs (pat, sdir, flags, ep, np)
*np = 0;
if (ep)
*ep = 0;
if (r)
if (r && r != &glob_error_return)
free (r);
return (struct globval *)0;
}
@ -665,7 +665,9 @@ glob_vector (pat, dir, flags)
(void) closedir (d);
}
/* compat: if GX_ALLDIRS, add the passed directory also */
/* compat: if GX_ADDCURDIR, add the passed directory also. Add an empty
directory name as a placeholder if GX_NULLDIR (in which case the passed
directory name is "."). */
if (add_current)
{
sdlen = strlen (dir);
@ -917,11 +919,14 @@ glob_filename (pathname, flags)
{
char **temp_results;
/* XXX -- we've recursively scanned any directories resulting from
a `**', so turn off the flag. We turn it on again below if
filename is `**' */
/* Scan directory even on a NULL filename. That way, `*h/'
returns only directories ending in `h', instead of all
files ending in `h' with a `/' appended. */
dname = directories[i];
dflags = flags & ~GX_MARKDIRS;
dflags = flags & ~(GX_MARKDIRS|GX_ALLDIRS|GX_ADDCURDIR);
if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
dflags |= GX_ALLDIRS|GX_ADDCURDIR;
if (dname[0] == '\0' && filename[0])
@ -942,7 +947,12 @@ glob_filename (pathname, flags)
char **array;
register unsigned int l;
array = glob_dir_to_array (directories[i], temp_results, flags);
/* If we're expanding **, we don't need to glue the directory
name to the results; we've already done it in glob_vector */
if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
array = temp_results;
else
array = glob_dir_to_array (directories[i], temp_results, flags);
l = 0;
while (array[l] != NULL)
++l;
@ -959,7 +969,8 @@ glob_filename (pathname, flags)
result[result_size - 1] = NULL;
/* Note that the elements of ARRAY are not freed. */
free ((char *) array);
if (array != temp_results)
free ((char *) array);
}
}
/* Free the directories. */
@ -1003,11 +1014,24 @@ glob_filename (pathname, flags)
/* Just return what glob_vector () returns appended to the
directory name. */
/* If flags & GX_ALLDIRS, we're called recursively */
dflags = flags & ~GX_MARKDIRS;
if (directory_len == 0)
dflags |= GX_NULLDIR;
if ((flags & GX_GLOBSTAR) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
dflags |= GX_ALLDIRS|GX_ADDCURDIR;
{
dflags |= GX_ALLDIRS|GX_ADDCURDIR;
#if 0
/* If we want all directories (dflags & GX_ALLDIRS) and we're not
being called recursively as something like `echo **/*.o'
((flags & GX_ALLDIRS) == 0), we want to prevent glob_vector from
adding a null directory name to the front of the temp_results
array. We turn off ADDCURDIR if not called recursively and
dlen == 0 */
#endif
if (directory_len == 0 && (flags & GX_ALLDIRS) == 0)
dflags &= ~GX_ADDCURDIR;
}
temp_results = glob_vector (filename,
(directory_len == 0 ? "." : directory_name),
dflags);

View file

@ -2208,7 +2208,7 @@ rl_old_menu_complete (count, invoking_key)
/* The first time through, we generate the list of matches and set things
up to insert them. */
if (rl_last_func != rl_menu_complete)
if (rl_last_func != rl_old_menu_complete)
{
/* Clean up from previous call, if any. */
FREE (orig_text);
@ -2220,6 +2220,8 @@ rl_old_menu_complete (count, invoking_key)
rl_completion_invoking_key = invoking_key;
RL_SETSTATE(RL_STATE_COMPLETING);
/* Only the completion entry function can change these. */
set_completion_defaults ('%');
@ -2259,9 +2261,12 @@ rl_old_menu_complete (count, invoking_key)
FREE (orig_text);
orig_text = (char *)0;
completion_changed_buffer = 0;
RL_UNSETSTATE(RL_STATE_COMPLETING);
return (0);
}
RL_UNSETSTATE(RL_STATE_COMPLETING);
for (match_list_size = 0; matches[match_list_size]; match_list_size++)
;
/* matches[0] is lcd if match_list_size > 1, but the circular buffer
@ -2337,6 +2342,8 @@ rl_menu_complete (count, ignore)
full_completion = 0;
RL_SETSTATE(RL_STATE_COMPLETING);
/* Only the completion entry function can change these. */
set_completion_defaults ('%');
@ -2378,9 +2385,12 @@ rl_menu_complete (count, ignore)
FREE (orig_text);
orig_text = (char *)0;
completion_changed_buffer = 0;
RL_UNSETSTATE(RL_STATE_COMPLETING);
return (0);
}
RL_UNSETSTATE(RL_STATE_COMPLETING);
for (match_list_size = 0; matches[match_list_size]; match_list_size++)
;

View file

@ -512,6 +512,7 @@ rl_redisplay ()
/* Block keyboard interrupts because this function manipulates global
data structures. */
_rl_block_sigint ();
RL_SETSTATE (RL_STATE_REDISPLAYING);
if (!rl_display_prompt)
rl_display_prompt = "";
@ -1188,9 +1189,11 @@ rl_redisplay ()
if (t < out)
line[t - 1] = '>';
if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
{
forced_display = 0;
o_cpos = _rl_last_c_pos;
cpos_adjusted = 0;
update_line (&visible_line[last_lmargin],
&invisible_line[lmargin],
0,
@ -1198,6 +1201,13 @@ rl_redisplay ()
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > wrap_offset &&
o_cpos < prompt_last_invisible)
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
/* If the visible new line is shorter than the old, but the number
of invisible characters is greater, and we are at the end of
the new line, we need to clear to eol. */
@ -1236,6 +1246,7 @@ rl_redisplay ()
visible_wrap_offset = wrap_offset;
}
RL_UNSETSTATE (RL_STATE_REDISPLAYING);
_rl_release_sigint ();
}
@ -1772,7 +1783,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
space_to_eol will insert too many spaces. XXX - maybe we should
adjust col_lendiff based on the difference between _rl_last_c_pos
and _rl_screenwidth */
if (col_lendiff && (_rl_last_c_pos < _rl_screenwidth))
if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth)))
#endif
{
if (_rl_term_autowrap && current_line < inv_botlin)
@ -1892,6 +1903,10 @@ _rl_move_cursor_relative (new, data)
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
if (cpos == 0 && cpos == new)
return;
#if defined (HANDLE_MULTIBYTE)
/* If we have multibyte characters, NEW is indexed by the buffer point in
a multibyte string, but _rl_last_c_pos is the display position. In
@ -1905,9 +1920,9 @@ _rl_move_cursor_relative (new, data)
prompt string, since they're both buffer indices and DPOS is a
desired display position. */
if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
(prompt_physical_chars > _rl_screenwidth &&
(prompt_physical_chars >= _rl_screenwidth &&
_rl_last_v_pos == prompt_last_screen_line &&
wrap_offset >= woff &&
wrap_offset >= woff && dpos >= woff &&
new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))
/* XXX last comparison might need to be >= */
{

View file

@ -814,8 +814,9 @@ extern int rl_inhibit_completion;
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
#define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */
#define RL_STATE_DONE 0x800000 /* done; accepted line */
#define RL_STATE_DONE 0x1000000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))

View file

@ -355,7 +355,7 @@ rl_resize_terminal ()
_rl_get_screen_size (fileno (rl_instream), 1);
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
else
else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0)
_rl_redisplay_after_sigwinch ();
}
}

View file

@ -30,16 +30,29 @@
#include <sys/ioctl.h>
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
/* For struct winsize on SCO */
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
# include <termios.h>
#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
/* Not in either of the standard places, look around. */
#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif /* HAVE_SYS_STREAM_H */
# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
# include <sys/ptem.h>
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
# endif /* HAVE_SYS_PTEM_H */
# if defined (HAVE_SYS_PTE_H) /* ??? */
# include <sys/pte.h>
# endif /* HAVE_SYS_PTE_H */
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
#include <stdio.h>