commit bash-20111202 snapshot

This commit is contained in:
Chet Ramey
2012-01-09 08:34:19 -05:00
parent e67d0029f0
commit e3db237e68
26 changed files with 45558 additions and 8888 deletions
+63
View File
@@ -12739,3 +12739,66 @@ doc/bashref.texi
- start at a set of examples for the =~ regular expression matching
operator, touching on keeping the pattern in a shell variable and
quoting portions of the pattern to remove their special meaning
12/1
----
lib/glob/gmisc.c
- extglob_pattern: new function, returns 1 if pattern passed as an
argument looks like an extended globbing pattern
lib/glob/glob.c
- skipname: return 0 immediately if extglob_pattern returns non-zero,
let the extended globbing code do the right thing with skipping
names beginning with a `.'
- mbskipname: return 0 immediately if extglob_pattern returns non-zero,
let the extended globbing code do the right thing with skipping
names beginning with a `.'. Fixes bug reported by Yongzhi Pan
<panyongzhi@gmail.com>
12/2
----
lib/glob/smatch.c
- patscan, patscan_wc: no longer static so other parts of the glob
library can use them, renamed to glob_patscan, glob_patscan_wc
lib/glob/glob.c
- extern declarations for glob_patscan, glob_patscan_wc
- wchkname: new function, does skipname on wchar_t pattern and dname,
old body of mbskipname after converting to wide chars
- extglob_skipname: new function, checks all subpatterns in an extglob
pattern to determine whether or not a filename should be skipped.
Calls skipname for each subpattern. Dname is only skipped if all
subpatterns indicate it should be. Better fix for bug reported by
Yongzhi Pan <panyongzhi@gmail.com>
- wextglob_skipname: wide-char version of extglob_skipname, calls
wchkname instead of calling back into mbskipname for each
subpattern to avoid problems with char/wchar_t mismatch
- skipname: call extglob_skipname if extglob_pattern returns non-zero
- mbskipname: call wextglob_skipname if extglob_pattern returns non-zero
- mbskipname: short-circuit immediately if no multibyte chars in
pattern or filename
execute_cmd.c
- execute_cond_node: added parens to patmatch assignment statement to
make intent clearer
12/3
----
configure.in,config.h.in
- check for imaxdiv, define HAVE_IMAXDIV if present
expr.c
- expassign, exp2: use imaxdiv if available. Doesn't help with checks
for overflow from 10/25
12/6
----
lib/readline/complete.c
- compute_lcd_of_matches: if we're ignoring case in the matches, only
use what the user typed as the lcd if it matches the first match
(after sorting) up to the length of what was typed (if what the
user typed is longer than the shortest of the possible matches, use
the shortest common length of the matches instead). If it doesn't
match, use the first of the list of matches, as if case were not
being ignored. Fixes bug reported by Clark Wang
<dearvoid@gmail.com>
+62 -3
View File
@@ -12740,6 +12740,65 @@ doc/bashref.texi
operator, touching on keeping the pattern in a shell variable and
quoting portions of the pattern to remove their special meaning
variables.c
- sv_history_control: setting HISTCONTROL to the empty string or
unsetting it unsets the history_control variables
12/1
----
lib/glob/gmisc.c
- extglob_pattern: new function, returns 1 if pattern passed as an
argument looks like an extended globbing pattern
lib/glob/glob.c
- skipname: return 0 immediately if extglob_pattern returns non-zero,
let the extended globbing code do the right thing with skipping
names beginning with a `.'
- mbskipname: return 0 immediately if extglob_pattern returns non-zero,
let the extended globbing code do the right thing with skipping
names beginning with a `.'. Fixes bug reported by Yongzhi Pan
<panyongzhi@gmail.com>
12/2
----
lib/glob/smatch.c
- patscan, patscan_wc: no longer static so other parts of the glob
library can use them, renamed to glob_patscan, glob_patscan_wc
lib/glob/glob.c
- extern declarations for glob_patscan, glob_patscan_wc
- wchkname: new function, does skipname on wchar_t pattern and dname,
old body of mbskipname after converting to wide chars
- extglob_skipname: new function, checks all subpatterns in an extglob
pattern to determine whether or not a filename should be skipped.
Calls skipname for each subpattern. Dname is only skipped if all
subpatterns indicate it should be. Better fix for bug reported by
Yongzhi Pan <panyongzhi@gmail.com>
- wextglob_skipname: wide-char version of extglob_skipname, calls
wchkname instead of calling back into mbskipname for each
subpattern to avoid problems with char/wchar_t mismatch
- skipname: call extglob_skipname if extglob_pattern returns non-zero
- mbskipname: call wextglob_skipname if extglob_pattern returns non-zero
- mbskipname: short-circuit immediately if no multibyte chars in
pattern or filename
execute_cmd.c
- execute_cond_node: added parens to patmatch assignment statement to
make intent clearer
12/3
----
configure.in,config.h.in
- check for imaxdiv, define HAVE_IMAXDIV if present
expr.c
- expassign, exp2: use imaxdiv if available. Doesn't help with checks
for overflow from 10/25
12/6
----
lib/readline/complete.c
- compute_lcd_of_matches: if we're ignoring case in the matches, only
use what the user typed as the lcd if it matches the first match
(after sorting) up to the length of what was typed (if what the
user typed is longer than the shortest of the possible matches, use
the shortest common length of the matches instead).. If it doesn't
match, use the first of the list of matches, as if case were not
being ignored. Fixes bug reported by Clark Wang
<dearvoid@gmail.com>
+19746 -4020
View File
File diff suppressed because it is too large Load Diff
+35 -35
View File
@@ -15,55 +15,55 @@
'configure.in'
],
{
'_LT_AC_TAGCONFIG' => 1,
'AM_PROG_F77_C_O' => 1,
'AC_INIT' => 1,
'_LT_AC_TAGCONFIG' => 1,
'm4_pattern_forbid' => 1,
'_AM_COND_IF' => 1,
'AC_INIT' => 1,
'AC_CANONICAL_TARGET' => 1,
'AC_SUBST' => 1,
'_AM_COND_IF' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_FC_SRCEXT' => 1,
'AC_SUBST' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FC_SRCEXT' => 1,
'AC_PROG_LIBTOOL' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AM_PATH_GUILE' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_PATH_GUILE' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
'AC_CONFIG_LINKS' => 1,
'm4_sinclude' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
'LT_SUPPORTED_TAG' => 1,
'm4_sinclude' => 1,
'AM_MAINTAINER_MODE' => 1,
'AM_NLS' => 1,
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
'AM_MAKEFILE_INCLUDE' => 1,
'_m4_warn' => 1,
'AM_MAKEFILE_INCLUDE' => 1,
'AM_PROG_CXX_C_O' => 1,
'_AM_MAKEFILE_INCLUDE' => 1,
'_AM_COND_ENDIF' => 1,
'_AM_MAKEFILE_INCLUDE' => 1,
'AM_ENABLE_MULTILIB' => 1,
'AM_SILENT_RULES' => 1,
'AM_PROG_MOC' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'LT_INIT' => 1,
'AM_PROG_AR' => 1,
'include' => 1,
'AM_GNU_GETTEXT' => 1,
'AM_PROG_AR' => 1,
'AC_LIBSOURCE' => 1,
'AM_PROG_FC_C_O' => 1,
'AC_CANONICAL_BUILD' => 1,
'AM_PROG_FC_C_O' => 1,
'AC_FC_FREEFORM' => 1,
'AH_OUTPUT' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'sinclude' => 1,
'm4_pattern_allow' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AM_PROG_CC_C_O' => 1,
'AM_XGETTEXT_OPTION' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_XGETTEXT_OPTION' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AM_POT_TOOLS' => 1,
@@ -86,19 +86,19 @@
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_C_VOLATILE' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_HEADER_TIME' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_WAIT3' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRNLEN' => 1,
@@ -117,17 +117,17 @@
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'm4_pattern_allow' => 1,
'AC_PROG_MAKE_SET' => 1,
'sinclude' => 1,
'm4_pattern_allow' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_PROG_YACC' => 1,
'AC_INIT' => 1,
'AC_STRUCT_TIMEZONE' => 1,
@@ -149,33 +149,33 @@
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_PROG_CPP' => 1,
'AC_HEADER_STAT' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_LEX' => 1,
'AC_C_CONST' => 1,
'AC_PROG_CPP' => 1,
'AC_TYPE_PID_T' => 1,
'AC_C_CONST' => 1,
'AC_PROG_LEX' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_PROG_LN_S' => 1,
'm4_include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
+683 -775
View File
File diff suppressed because it is too large Load Diff
+36 -7
View File
@@ -136,7 +136,8 @@ brace_expand (text)
#endif /* !CSH_BRACE_COMPAT */
preamble = (char *)xmalloc (i + 1);
strncpy (preamble, text, i);
if (i > 0)
strncpy (preamble, text, i);
preamble[i] = '\0';
result = (char **)xmalloc (2 * sizeof (char *));
@@ -232,13 +233,18 @@ brace_expand (text)
add_tack:
result = array_concat (result, tack);
free (amble);
strvec_dispose (tack);
if (tack != result)
strvec_dispose (tack);
postamble = text + i + 1;
tack = brace_expand (postamble);
result = array_concat (result, tack);
strvec_dispose (tack);
if (postamble && *postamble)
{
tack = brace_expand (postamble);
result = array_concat (result, tack);
if (tack != result)
strvec_dispose (tack);
}
return (result);
}
@@ -600,6 +606,20 @@ comsub:
return (c);
}
/* Return 1 if ARR has any non-empty-string members. Used to short-circuit
in array_concat() below. */
static int
degenerate_array (arr)
char **arr;
{
register int i;
for (i = 0; arr[i]; i++)
if (arr[i][0] != '\0')
return 0;
return 1;
}
/* Return a new array of strings which is the result of appending each
string in ARR2 to each string in ARR1. The resultant array is
len (arr1) * len (arr2) long. For convenience, ARR1 (and its contents)
@@ -613,10 +633,19 @@ array_concat (arr1, arr2)
register char **result;
if (arr1 == 0)
return (strvec_copy (arr2));
return (arr2); /* XXX - see if we can get away without copying? */
if (arr2 == 0)
return (strvec_copy (arr1));
return (arr1); /* XXX - caller expects us to free arr1 */
if (degenerate_array (arr1))
{
strvec_dispose (arr1);
return (arr2); /* XXX - use flags to see if we can avoid copying here */
}
if (degenerate_array (arr2))
return (arr1); /* XXX - rather than copying and freeing it */
len1 = strvec_len (arr1);
len2 = strvec_len (arr2);
+1 -1
View File
@@ -593,7 +593,7 @@ read_builtin (list)
if ((unsigned char)c == delim)
break;
if (c == '\0')
if (c == '\0' && delim != '\0')
continue; /* skip NUL bytes in input */
if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL))
+3
View File
@@ -625,6 +625,9 @@
/* Define if you have the iconv function. */
#undef HAVE_ICONV
/* Define if you have the imaxdiv function. */
#undef HAVE_IMAXDIV
/* Define if you have the inet_aton function. */
#undef HAVE_INET_ATON
+1129
View File
File diff suppressed because it is too large Load Diff
Vendored
+19683 -3957
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 4.2, version 4.042])dnl
AC_REVISION([for Bash 4.2, version 4.043])dnl
define(bashvers, 4.2)
define(relstatus, maint)
@@ -744,7 +744,7 @@ AC_REPLACE_FUNCS(rename)
dnl checks for c library functions
AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \
getaddrinfo gethostbyname getservbyname getservent inet_aton \
memmove pathconf putenv raise regcomp regexec \
imaxdiv memmove pathconf putenv raise regcomp regexec \
setenv setlinebuf setlocale setvbuf siginterrupt strchr \
sysconf syslog tcgetattr times ttyname tzset unsetenv)
+1175
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -6458,7 +6458,7 @@ history list starting with
.IR string .
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command preceding the current postition in the
Refer to the most recent command preceding the current position in the
history list containing
.IR string .
The trailing \fB?\fP may be omitted if
+2 -2
View File
@@ -3497,8 +3497,8 @@ execute_cond_node (cond)
else if (cond->type == COND_BINARY)
{
rmatch = 0;
patmatch = ((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') &&
(cond->op->word[0] == '!' || cond->op->word[0] == '=') ||
patmatch = (((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') &&
(cond->op->word[0] == '!' || cond->op->word[0] == '=')) ||
(cond->op->word[0] == '=' && cond->op->word[1] == '\0'));
#if defined (COND_REGEXP)
rmatch = (cond->op->word[0] == '=' && cond->op->word[1] == '~' &&
+4 -4
View File
@@ -1700,12 +1700,12 @@ cpl_reap ()
}
}
nt->next = 0;
if (coproc_list.ncoproc == 0)
coproc_list.head = coproc_list.tail = 0;
else
{
if (nt)
nt->next = 0;
coproc_list.head = nh;
coproc_list.tail = nt;
if (coproc_list.ncoproc == 1)
@@ -3497,8 +3497,8 @@ execute_cond_node (cond)
else if (cond->type == COND_BINARY)
{
rmatch = 0;
patmatch = ((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') &&
(cond->op->word[0] == '!' || cond->op->word[0] == '=') ||
patmatch = (((cond->op->word[1] == '=') && (cond->op->word[2] == '\0') &&
(cond->op->word[0] == '!' || cond->op->word[0] == '=')) ||
(cond->op->word[0] == '=' && cond->op->word[1] == '\0'));
#if defined (COND_REGEXP)
rmatch = (cond->op->word[0] == '=' && cond->op->word[1] == '~' &&
+20 -11
View File
@@ -454,6 +454,9 @@ expassign ()
register intmax_t value;
char *lhs, *rhs;
arrayind_t lind;
#if defined (HAVE_IMAXDIV)
imaxdiv_t idiv;
#endif
value = expcond ();
if (curtok == EQ || curtok == OP_ASSIGN)
@@ -494,16 +497,16 @@ expassign ()
lvalue *= value;
break;
case DIV:
if (lvalue == INTMAX_MIN && value == -1)
value = 1;
else
lvalue /= value;
break;
case MOD:
if (lvalue == INTMAX_MIN && value == -1)
lvalue = 0;
value = (op == DIV) ? 1 : 0;
else
lvalue %= value;
#if HAVE_IMAXDIV
idiv = imaxdiv (lvalue, value);
lvalue = (op == DIV) ? idiv.quot : idiv.rem;
#else
lvalue = (op == DIV) ? lvalue / value : lvalue % value;
#endif
break;
case PLUS:
lvalue += value;
@@ -804,6 +807,9 @@ static intmax_t
exp2 ()
{
register intmax_t val1, val2;
#if defined (HAVE_IMAXDIV)
imaxdiv_t idiv;
#endif
val1 = exppower ();
@@ -835,10 +841,13 @@ exp2 ()
if (op == MUL)
val1 *= val2;
else if (op == DIV)
val1 /= val2;
else if (op == MOD)
val1 %= val2;
else if (op == DIV || op == MOD)
#if defined (HAVE_IMAXDIV)
idiv = imaxdiv (val1, val2);
val1 = (op == DIV) ? idiv.quot : idiv.rem;
#else
val1 = (op == DIV) ? val1 / val2 : val1 % val2;
#endif
}
return (val1);
}
+22 -12
View File
@@ -1,6 +1,6 @@
/* expr.c -- arithmetic expression evaluation. */
/* Copyright (C) 1990-2010 Free Software Foundation, Inc.
/* Copyright (C) 1990-2011 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -454,6 +454,9 @@ expassign ()
register intmax_t value;
char *lhs, *rhs;
arrayind_t lind;
#if defined (HAVE_IMAXDIV)
imaxdiv_t idiv;
#endif
value = expcond ();
if (curtok == EQ || curtok == OP_ASSIGN)
@@ -494,16 +497,16 @@ expassign ()
lvalue *= value;
break;
case DIV:
if (lvalue == INTMAX_MIN && value == -1)
value = 1;
else
lvalue /= value;
break;
case MOD:
if (lvalue == INTMAX_MIN && value == -1)
lvalue = 0;
value = (op == DIV) ? 1 : 0;
else
lvalue %= value;
#if HAVE_IMAXDIV
idiv = imaxdiv (lvalue, value);
lvalue = (op == DIV) ? idiv.quot : idiv.rem;
#else
lvalue = (op == DIV) ? lvalue / value : lvalue % value;
#endif
break;
case PLUS:
lvalue += value;
@@ -804,6 +807,9 @@ static intmax_t
exp2 ()
{
register intmax_t val1, val2;
#if defined (HAVE_IMAXDIV)
imaxdiv_t idiv;
#endif
val1 = exppower ();
@@ -825,6 +831,7 @@ exp2 ()
else
val2 = 1;
}
/* XXX - might not need if using imaxdiv */
else if (op == MOD && val1 == INTMAX_MIN && val2 == -1)
{
val1 = 0;
@@ -835,10 +842,13 @@ exp2 ()
if (op == MUL)
val1 *= val2;
else if (op == DIV)
val1 /= val2;
else if (op == MOD)
val1 %= val2;
else if (op == DIV || op == MOD)
#if defined (HAVE_IMAXDIV)
idiv = imaxdiv (val1, val2);
val1 = (op == DIV) ? idiv.quot : idiv.rem;
#else
val1 = (op == DIV) ? val1 / val2 : val1 % val2;
#endif
}
return (val1);
}
+129 -19
View File
@@ -115,6 +115,10 @@ static void dequote_pathname __P((char *));
static int glob_testdir __P((char *));
static char **glob_dir_to_array __P((char *, char **, int));
/* Make sure these names continue to agree with what's in smatch.c */
extern char *glob_patscan __P((char *, char *, int));
extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
/* Compile `glob_loop.c' for single-byte characters. */
#define CHAR unsigned char
#define INT int
@@ -162,15 +166,63 @@ glob_pattern_p (pattern)
#endif
}
#if EXTENDED_GLOB
/* Return 1 if all subpatterns in the extended globbing pattern PAT indicate
that the name should be skipped. XXX - doesn't handle pattern negation,
not sure if it should */
static int
extglob_skipname (pat, dname, flags)
char *pat, *dname;
int flags;
{
char *pp, *pe, *t;
int n, r;
pp = pat + 2;
pe = pp + strlen (pp) - 1; /*(*/
if (*pe != ')')
return 0;
if ((t = strchr (pp, '|')) == 0) /* easy case first */
{
*pe = '\0';
r = skipname (pp, dname, flags); /*(*/
*pe = ')';
return r;
}
while (t = glob_patscan (pp, pe, '|'))
{
n = t[-1];
t[-1] = '\0';
r = skipname (pp, dname, flags);
t[-1] = n;
if (r == 0) /* if any pattern says not skip, we don't skip */
return r;
pp = t;
} /*(*/
if (pp == pe) /* glob_patscan might find end of pattern */
return r;
*pe = '\0';
r = mbskipname (pp, dname, flags); /*(*/
*pe = ')';
return r;
}
#endif
/* Return 1 if DNAME should be skipped according to PAT. Mostly concerned
with matching leading `.'. */
static int
skipname (pat, dname, flags)
char *pat;
char *dname;
int flags;
{
#if EXTENDED_GLOB
if (extglob_pattern (pat)) /* XXX */
return (extglob_skipname (pat, dname, flags));
#endif
/* If a leading dot need not be explicitly matched, and the pattern
doesn't start with a `.', don't match `.' or `..' */
if (noglob_dot_filenames == 0 && pat[0] != '.' &&
@@ -188,18 +240,91 @@ skipname (pat, dname, flags)
}
#if HANDLE_MULTIBYTE
static int
wchkname (pat_wc, dn_wc)
wchar_t *pat_wc, *dn_wc;
{
/* If a leading dot need not be explicitly matched, and the
pattern doesn't start with a `.', don't match `.' or `..' */
if (noglob_dot_filenames == 0 && pat_wc[0] != L'.' &&
(pat_wc[0] != L'\\' || pat_wc[1] != L'.') &&
(dn_wc[0] == L'.' &&
(dn_wc[1] == L'\0' || (dn_wc[1] == L'.' && dn_wc[2] == L'\0'))))
return 1;
/* If a leading dot must be explicity matched, check to see if the
pattern and dirname both have one. */
else if (noglob_dot_filenames && dn_wc[0] == L'.' &&
pat_wc[0] != L'.' &&
(pat_wc[0] != L'\\' || pat_wc[1] != L'.'))
return 1;
return 0;
}
static int
wextglob_skipname (pat, dname, flags)
wchar_t *pat, *dname;
int flags;
{
#if EXTENDED_GLOB
wchar_t *pp, *pe, *t, n;
int r;
pp = pat + 2;
pe = pp + wcslen (pp) - 1; /*(*/
if (*pe != L')')
return 0;
if ((t = wcschr (pp, L'|')) == 0)
{
*pe = L'\0';
r = wchkname (pp, dname); /*(*/
*pe = L')';
return r;
}
while (t = glob_patscan_wc (pp, pe, '|'))
{
n = t[-1];
t[-1] = L'\0';
r = wchkname (pp, dname);
t[-1] = n;
if (r == 0)
return 0;
pp = t;
}
if (pp == pe) /* glob_patscan_wc might find end of pattern */
return r;
*pe = L'\0';
r = wchkname (pp, dname); /*(*/
*pe = L')';
return r;
#else
return (wchkname (pp, dname));
#endif
}
/* Return 1 if DNAME should be skipped according to PAT. Handles multibyte
characters in PAT and DNAME. Mostly concerned with matching leading `.'. */
static int
mbskipname (pat, dname, flags)
char *pat, *dname;
int flags;
{
int ret;
int ret, ext;
wchar_t *pat_wc, *dn_wc;
size_t pat_n, dn_n;
if (mbsmbchar (dname) == 0 && mbsmbchar (pat) == 0)
return (skipname (pat, dname, flags));
ext = 0;
#if EXTENDED_GLOB
ext = extglob_pattern (pat);
#endif
pat_wc = dn_wc = (wchar_t *)NULL;
pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
@@ -208,22 +333,7 @@ mbskipname (pat, dname, flags)
ret = 0;
if (pat_n != (size_t)-1 && dn_n !=(size_t)-1)
{
/* If a leading dot need not be explicitly matched, and the
pattern doesn't start with a `.', don't match `.' or `..' */
if (noglob_dot_filenames == 0 && pat_wc[0] != L'.' &&
(pat_wc[0] != L'\\' || pat_wc[1] != L'.') &&
(dn_wc[0] == L'.' &&
(dn_wc[1] == L'\0' || (dn_wc[1] == L'.' && dn_wc[2] == L'\0'))))
ret = 1;
/* If a leading dot must be explicity matched, check to see if the
pattern and dirname both have one. */
else if (noglob_dot_filenames && dn_wc[0] == L'.' &&
pat_wc[0] != L'.' &&
(pat_wc[0] != L'\\' || pat_wc[1] != L'.'))
ret = 1;
}
ret = ext ? wextglob_skipname (pat_wc, dn_wc, flags) : wchkname (pat_wc, dn_wc);
else
ret = skipname (pat, dname, flags);
+18
View File
@@ -200,6 +200,24 @@ bad_bracket:
}
#endif
int
extglob_pattern (pat)
char *pat;
{
switch (pat[0])
{
case '*':
case '+':
case '!':
case '@':
return (pat[1] == LPAREN);
default:
return 0;
}
return 0;
}
/* Return 1 of the first character of STRING could match the first
character of pattern PAT. Used to avoid n2 calls to strmatch(). */
int
+3 -2
View File
@@ -22,7 +22,8 @@ static int GMATCH __P((CHAR *, CHAR *, CHAR *, CHAR *, int));
static CHAR *PARSE_COLLSYM __P((CHAR *, INT *));
static CHAR *BRACKMATCH __P((CHAR *, U_CHAR, int));
static int EXTMATCH __P((INT, CHAR *, CHAR *, CHAR *, CHAR *, int));
static CHAR *PATSCAN __P((CHAR *, CHAR *, INT));
/*static*/ CHAR *PATSCAN __P((CHAR *, CHAR *, INT));
int
FCT (pattern, string, flags)
@@ -520,7 +521,7 @@ matched:
because we're scanning a `patlist'. Otherwise, we scan until we see
DELIM. In all cases, we never scan past END. The return value is the
first character after the matching DELIM. */
static CHAR *
/*static*/ CHAR *
PATSCAN (string, end, delim)
CHAR *string, *end;
INT delim;
+2 -2
View File
@@ -223,7 +223,7 @@ is_cclass (c, name)
#define COLLSYM collsym
#define PARSE_COLLSYM parse_collsym
#define BRACKMATCH brackmatch
#define PATSCAN patscan
#define PATSCAN glob_patscan
#define STRCOMPARE strcompare
#define EXTMATCH extmatch
#define STRCHR(S, C) strchr((S), (C))
@@ -355,7 +355,7 @@ is_wcclass (wc, name)
#define COLLSYM collwcsym
#define PARSE_COLLSYM parse_collwcsym
#define BRACKMATCH brackmatch_wc
#define PATSCAN patscan_wc
#define PATSCAN glob_patscan_wc
#define STRCOMPARE wscompare
#define EXTMATCH extmatch_wc
#define STRCHR(S, C) wcschr((S), (C))
+15 -15
View File
@@ -1173,6 +1173,7 @@ compute_lcd_of_matches (match_list, matches, text)
{
register int i, c1, c2, si;
int low; /* Count of max-matched characters. */
int lx;
char *dtext; /* dequoted TEXT, if needed */
#if defined (HANDLE_MULTIBYTE)
int v;
@@ -1290,21 +1291,20 @@ compute_lcd_of_matches (match_list, matches, text)
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
si = strlen (text);
if (si <= low)
{
for (i = 1; i <= matches; i++)
if (strncmp (match_list[i], text, si) == 0)
{
strncpy (match_list[0], match_list[i], low);
break;
}
/* no casematch, use first entry */
if (i > matches)
strncpy (match_list[0], match_list[1], low);
}
else
/* otherwise, just use the text the user typed. */
strncpy (match_list[0], text, low);
lx = (si <= low) ? si : low; /* check shorter of text and matches */
/* Try to preserve the case of what the user typed in the presence of
multiple matches: check each match for something that matches
what the user typed taking case into account; use it up to common
length of matches if one is found. If not, just use first match. */
for (i = 1; i <= matches; i++)
if (strncmp (match_list[i], text, lx) == 0)
{
strncpy (match_list[0], match_list[i], low);
break;
}
/* no casematch, use first entry */
if (i > matches)
strncpy (match_list[0], match_list[1], low);
FREE (dtext);
}
File diff suppressed because it is too large Load Diff
+14 -17
View File
@@ -1173,6 +1173,7 @@ compute_lcd_of_matches (match_list, matches, text)
{
register int i, c1, c2, si;
int low; /* Count of max-matched characters. */
int lx;
char *dtext; /* dequoted TEXT, if needed */
#if defined (HANDLE_MULTIBYTE)
int v;
@@ -1290,21 +1291,19 @@ compute_lcd_of_matches (match_list, matches, text)
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
si = strlen (text);
if (si <= low)
{
for (i = 1; i <= matches; i++)
if (strncmp (match_list[i], text, si) == 0)
{
strncpy (match_list[0], match_list[i], low);
break;
}
/* no casematch, use first entry */
if (i > matches)
strncpy (match_list[0], match_list[1], low);
}
else
/* otherwise, just use the text the user typed. */
strncpy (match_list[0], text, low);
/* Check each match for something that matches what the user typed
taking case into account; use it up to common length of matches
if so. If not, just use first match. */
for (i = 1; i <= matches; i++)
if (strncmp (match_list[i], text, si) == 0)
{
strncpy (match_list[0], match_list[i], low);
break;
}
/* no casematch, use first entry */
if (i > matches)
strncpy (match_list[0], match_list[1], low);
FREE (dtext);
}
@@ -1982,8 +1981,6 @@ rl_complete_internal (what_to_do)
/* */
/***************************************************************/
extern void _rl_settracefp (FILE *);
/* Return an array of (char *) which is a list of completions for TEXT.
If there are no completions, return a NULL pointer.
The first entry in the returned array is the substitution for TEXT.
+1 -1
View File
@@ -112,7 +112,7 @@ starting with
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command
preceding the current postition in the history list
preceding the current position in the history list
containing
.IR string .
The trailing \fB?\fP may be omitted if
-2
View File
@@ -88,7 +88,5 @@ swizzle ()
}
ok 1
./vredir6.sub: redirection error: cannot duplicate fd: Invalid argument
./vredir6.sub: line 10: /dev/null: Invalid argument
./vredir6.sub: redirection error: cannot duplicate fd: Invalid argument
./vredir6.sub: line 13: v: Invalid argument
unset