Commit 52ce2ad0 authored by Lucas Nussbaum's avatar Lucas Nussbaum

Imported Upstream version 6.17.02

parent 7a2d063d
32. V6.17.02 - 20100512
31. PR/79: nargs: Better handling for promptchars.
30. PR/97: Add parseoctal to retain compatibility with previous versions (Jim
Zajkowski)
29. PR/84: Performance fixes for large history merges (add
hashtable (Ted Anderson)
28. Revert previous #23; people should use $histlit if they want this
feature.
27. Don't kill "hup" background jobs when a child of the shell exits.
From Debian.
26. Ignore \r\n in the command line options for OS's that don't strip
these from #!; from Debian
25. Fix enhanced missing patch (Greg Dionne)
24. Callers of rt_mbtowc don't grok -2 as a return. Return -1 for now.
(Corinna Vinschen)
23. Turn HistLit on while recording history to avoid \!\! losing its \.
From Debian
22. set autoexpand; set histchars="";\n<tab> crash. From Debian
21. V6.17.01 - 20100506
20. unset verbose while we are reading the history file to avoid echoing
to the terminal. (Jeffrey Bastian)
19. globstar addition, Enhance addition, euid, euser, gid variables
(Greg Dionne)
18. Make 'e' in vi mode work like 'b' - use wordchars (Alistair Crooks)
17. Handle UTF-16 surrogates (Corinna Vinschen)
16. Make tcsh work on systems where sizeof(wchar_t) == 2 (Corinna Vinschen)
15. Better support for Solaris >= 2.9 (Thomas Uhle)
14. Change internal expression calculations to long long so that we can
deal with > 32 bit time, inodes, uids, file sizes etc.
13. Add new linux resource limits.
12. Don't print 'Exit X' when printexitvalue is set in `` expressions
(Jeff Bastian)
11. Add more LS_COLORS vars (M.H. Anderson)
10. Reduce whitespace in Makefile (Don Estabrook)
9. Manual page fixes (Alan R. S. Bueno)
8. Remove history in loops bug from the documentation (Holger Weiss)
7. Add autorehash (Holger Weiss)
6. Add history.at (Ted Anderson)
5. Better NLSPATH handling (Norm Jacobs)
4. Fix hostname building from utmp (Cyrus Rahman)
3. Handle pending signals before flush so that the the history file does
not get truncated. (Ted Anderson)
2. Fix AsciiOnly setting that broke 8 bit input. (Juergen Keil)
1. remember to closedir in mailchk (from Werner Fink, reported by
David Binderman)
21. V6.17.00 - 20090710
20. Fix dataroot autoconf issue.
19. Fix directory stuff for unit tests.
......
XCOMM
XCOMM $tcsh: Imakefile,v 1.86 2007/03/19 23:25:02 christos Exp $
XCOMM $tcsh: Imakefile,v 1.87 2010/01/28 19:01:05 christos Exp $
XCOMM
XCOMM Imakefile for tcsh 6.12
XCOMM Marc Horowitz, MIT SIPB
......@@ -93,7 +93,11 @@ ones. Please send in your fixes and additions! */
# if (OSMinorVersion < 6)
# define ConfigH sol24
# else
# define ConfigH sol26
# if (OSMinorVersion < 9)
# define ConfigH sol26
# else
# define ConfigH sol29
# endif
# endif
# endif
# endif
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ find it out-of-date, or you have additions or changes, please let me know.
christos
VENDOR : sun
VENDOR : Sun
MODELS : sun3, sun4, sun386i
COMPILER: cc, gcc, acc
CFLAGS : normal
......@@ -18,7 +18,7 @@ ENVIRON : n/a
NOTES : Don't compile with /usr/5bin/cc
VERSION : 6.08
VENDOR : sun
VENDOR : Sun
MODELS : sun4, ultra
COMPILER: cc, gcc
CFLAGS : normal
......@@ -34,18 +34,29 @@ NOTES : The sunpro compiler cannot compile tcsh with -O, it crashes
: point failures of programs exec'ed from tcsh.
VERSION : 6.08
VENDOR : sun
VENDOR : Sun
MODELS : ultra
COMPILER: WorkShop cc
CFLAGS : normal
LIBES : -lcurses -lsocket -lnsl
OS : solaris 2.6
OS : solaris 2.6, 2.7, 8
CONFIG : sol26
ENVIRON : n/a
NOTES : none
VERSION : 6.08
VENDOR : sun
VENDOR : Sun
MODELS : ultra, i686, x86_64
COMPILER: Sun Studio cc
CFLAGS : normal
LIBES : -lcurses -lsocket -lnsl
OS : solaris 9, 10
CONFIG : sol29
ENVIRON : n/a
NOTES : none
VERSION : 6.18
VENDOR : Sun
MODELS : i386
COMPILER: cc, gcc
CFLAGS : -D__STDC__=0
......@@ -56,7 +67,7 @@ ENVIRON : n/a
NOTES : n/a
VERSION : 6.04.13
VENDOR : sun
VENDOR : Sun
MODELS : sun4
COMPILER: gcc
CFLAGS : normal
......
This is tcsh version 6.17.00. Tcsh is a version of the Berkeley
This is tcsh version 6.17.01. Tcsh is a version of the Berkeley
C-Shell, with the addition of: a command line editor, command and file
name completion, listing, etc. and a bunch of small additions to the
shell itself.
......
......@@ -52,17 +52,6 @@ ey )
- bhooglan
_________________________________________________________________
I'm a long-time faithful user of tcsh, and one thing has always bugged
me -- the need to type "rehash" at a prompt when adding a new command.
My suggestions is to change tcsh so before printing "Command not
found.", it first searches its entire path and rebuilds its hash
table. Only after doing this, and if the command is still not in the
path, then print "Command not found.". I realize there are some
extreme cases in which this is suboptimal, but in most cases with
normal users this would be a big win, and simplify the manual and
perhaps even the code.
_________________________________________________________________
Wish "tcsh -l" would accept other flags. At least "-c".
Currently I can't get ssh to have the right environment unless it is a
......
#
# $tcsh: complete.tcsh,v 1.51 2007/10/01 21:51:59 christos Exp $
# $tcsh: complete.tcsh,v 1.52 2010/05/07 17:54:13 christos Exp $
# example file using the new completion code
#
# Debian GNU/Linux
......@@ -636,7 +636,7 @@ if ($?_complete) then
complete nmap 'n@-e@`ifconfig -l`@' 'p/*/$hostnames/'
complete perldoc 'n@*@`\ls -1 /usr/libdata/perl/5.*/pod | sed s%\\.pod.\*\$%%`@'
complete postfix 'n/*/(start stop reload abort flush check)/'
complete postmap 'n/1/(hash: regexp:)' 'c/hash:/f/' 'c/regexp:/f/'
complete postmap 'n/1/(hash: regexp:)/' 'c/hash:/f/' 'c/regexp:/f/'
complete rcsdiff 'p@1@`\ls -1a RCS | sed -e "s/\(.*\),v/\1/"`@'
complete X 'c/-/(I a ac allowMouseOpenFail allowNonLocalModInDev \
allowNonLocalXvidtune ar1 ar2 audit auth bestRefresh \
......
......@@ -204,6 +204,11 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
......@@ -225,6 +230,10 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
#undef volatile
......
......@@ -81,8 +81,6 @@
/****************** local defines *********************/
#define HAVENOLIMIT
#ifndef _PATH_TCSHELL
#define _PATH_TCSHELL "/bin/tcsh"
#endif
......
......@@ -107,6 +107,7 @@
/****************** local defines *********************/
#define NAMEI_BUG /* Great! you broke that one too */
#define HPUXVERSION 1100 /* For HP-UX version 8.00 */
#define HPUXVERSION 1100 /* For HP-UX version 11.00 */
#define _XOPEN_SOURCE_EXTENDED /* for socklen_t */
#endif /* _h_config */
/*
* config.h -- configure various defines for tcsh
*
* All source files should #include this FIRST.
*
* This is the config file for Solaris systems.
*/
#ifndef _h_config
#define _h_config
/****************** System dependant compilation flags ****************/
/*
* POSIX This system supports IEEE Std 1003.1-1988 (POSIX).
*/
#define POSIX
/*
* POSIXJOBS This system supports the optional IEEE Std 1003.1-1988 (POSIX)
* job control facilities.
*/
#define POSIXJOBS
/*
* VFORK This machine has a vfork().
* It used to be that for job control to work, this define
* was mandatory. This is not the case any more.
* If you think you still need it, but you don't have vfork,
* define this anyway and then do #define vfork fork.
* I do this anyway on a Sun because of yellow pages brain damage,
* [should not be needed under 4.1]
* and on the iris4d cause SGI's fork is sufficiently "virtual"
* that vfork isn't necessary. (Besides, SGI's vfork is weird).
* Note that some machines eg. rs6000 have a vfork, but not
* with the berkeley semantics, so we cannot use it there either.
*/
#undef VFORK
/*
* BSDJOBS You have BSD-style job control (both process groups and
* a tty that deals correctly
*/
#define BSDJOBS
/*
* BSDTIMES You have BSD-style process time stuff (like rusage)
* This may or may not be true. For example, Apple Unix
* (OREO) has BSDJOBS but not BSDTIMES.
*/
#define BSDTIMES
/*
* BSDLIMIT You have BSD-style resource limit stuff (getrlimit/setrlimit)
*/
#define BSDLIMIT
/*
* TERMIO You have struct termio instead of struct sgttyb.
* This is usually the case for SYSV systems, where
* BSD uses sgttyb. POSIX systems should define this
* anyway, even though they use struct termios.
*/
#define TERMIO
/*
* SYSVREL Your machine is SYSV based (HPUX, A/UX)
* NOTE: don't do this if you are on a Pyramid -- tcsh is
* built in a BSD universe.
* Set SYSVREL to 1, 2, 3, or 4, depending on the version of SYSV
* you are running, or set it to 0 if you are not SYSV based.
*/
#define SYSVREL 4
/*
* YPBUGS Work around Sun YP bugs that cause expansion of ~username
* to send command output to /dev/null [they are back!]
*/
#define YPBUGS
/*
* NISPLUS Make sure that fd's 0, 1, and 2 always are open so that
* Sun's NIS+ doesn't get them, making ~-expansion hang.
*/
#define NISPLUS
/*
* Large file support
*/
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
/*
* ECHO_STYLE Optionally change the behavior of the builtin echo
* BOTH_ECHO: Support both bsd options (-n) and sysv escapes (\nnn)
* BSD_ECHO: Support only -n
* SYSV_ECHO: Support only sysv escapes (\nnn)
* NONE_ECHO: Pure echo.
*/
#define ECHO_STYLE BSD_ECHO /* BSD options only */
/****************** local defines *********************/
#define SOLARIS2 29
/*
* Fix http://bugs.opensolaris.org/view_bug.do?bug_id=6593766
* All XPG4 and XPG4.2 applications should use __XPG4_CHAR_CLASS__
* The degree character(?) is not part of ASCII. It is part of extended-ASCII
* and needs wide char to get this to working. Hence we need to enable the
* macro __XPG4_CHAR_CLASS__ in config_f.h header file under tcsh to get
* this to working.
*/
#define __XPG4_CHAR_CLASS__
/*
* lookupname/namei ignores tailing '/' on files
*/
#define NAMEI_BUG
#endif /* _h_config */
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.42 2009/06/25 12:10:56 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.43 2010/02/09 20:28:17 christos Exp $ */
/*
* config_f.h -- configure various defines for tcsh
*
......@@ -50,8 +50,11 @@
* WIDE_STRINGS Represent strings using wide characters
* Allows proper function in multibyte encodings like UTF-8
*/
#if defined (SHORT_STRINGS) && defined (NLS) && SIZEOF_WCHAR_T >= 4 && defined (HAVE_MBRTOWC) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
#if defined (SHORT_STRINGS) && defined (NLS) && defined (HAVE_MBRTOWC) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
# define WIDE_STRINGS
# if SIZEOF_WCHAR_T < 4
# define UTF16_STRINGS
# endif
#endif
/*
......@@ -197,10 +200,6 @@
/* Consistency checks */
#ifdef WIDE_STRINGS
# if SIZEOF_WCHAR_T < 4
#error "wchar_t must be at least 4 bytes for WIDE_STRINGS"
# endif
# ifdef WINNT_NATIVE
#error "WIDE_STRINGS cannot be used together with WINNT_NATIVE"
# endif
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for tcsh 6.17.00.
# Generated by GNU Autoconf 2.61 for tcsh 6.17.02.
#
# Report bugs to <http://bugs.gw.com/>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='tcsh'
PACKAGE_TARNAME='tcsh'
PACKAGE_VERSION='6.17.00'
PACKAGE_STRING='tcsh 6.17.00'
PACKAGE_VERSION='6.17.02'
PACKAGE_STRING='tcsh 6.17.02'
PACKAGE_BUGREPORT='http://bugs.gw.com/'
ac_unique_file="tc.vers.c"
......@@ -1189,7 +1189,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 tcsh 6.17.00 to adapt to many kinds of systems.
\`configure' configures tcsh 6.17.02 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1254,7 +1254,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of tcsh 6.17.00:";;
short | recursive ) echo "Configuration of tcsh 6.17.02:";;
esac
cat <<\_ACEOF
......@@ -1346,7 +1346,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
tcsh configure 6.17.00
tcsh configure 6.17.02
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1360,7 +1360,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by tcsh $as_me 6.17.00, which was
It was created by tcsh $as_me 6.17.02, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2001,9 +2001,12 @@ case "${host}" in
*-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol24
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
*-*-solaris2.[678] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol26
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol29
;;
## Dell SVR4
*-dell-sysv4* )
......@@ -6604,6 +6607,82 @@ _ACEOF
fi
{ echo "$as_me:$LINENO: checking for uint32_t" >&5
echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; }
if test "${ac_cv_c_uint32_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_c_uint32_t=no
for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \
'unsigned long long int' 'unsigned short int' 'unsigned char'; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
case $ac_type in
uint32_t) ac_cv_c_uint32_t=yes ;;
*) ac_cv_c_uint32_t=$ac_type ;;
esac
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
test "$ac_cv_c_uint32_t" != no && break
done
fi
{ echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5
echo "${ECHO_T}$ac_cv_c_uint32_t" >&6; }
case $ac_cv_c_uint32_t in #(
no|yes) ;; #(
*)
cat >>confdefs.h <<\_ACEOF
#define _UINT32_T 1
_ACEOF
cat >>confdefs.h <<_ACEOF
#define uint32_t $ac_cv_c_uint32_t
_ACEOF
;;
esac
{ echo "$as_me:$LINENO: checking for ssize_t" >&5
......@@ -8546,7 +8625,7 @@ fi
ac_config_files="$ac_config_files Makefile"
ac_config_files="$ac_config_files Makefile nls/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
......@@ -8944,7 +9023,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by tcsh $as_me 6.17.00, which was
This file was extended by tcsh $as_me 6.17.02, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -8997,7 +9076,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
tcsh config.status 6.17.00
tcsh config.status 6.17.02
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......@@ -9107,6 +9186,7 @@ do
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"./atconfig") CONFIG_COMMANDS="$CONFIG_COMMANDS ./atconfig" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"nls/Makefile") CONFIG_FILES="$CONFIG_FILES nls/Makefile" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
......
......@@ -9,7 +9,7 @@ dnl Written by Kaveh Ghazi (ghazi@caip.rutgers.edu) 5/11/96.
dnl
AC_PREREQ([2.59])dnl Minimum Autoconf version required.
AC_INIT([tcsh], [6.17.00], [http://bugs.gw.com/])
AC_INIT([tcsh], [6.17.02], [http://bugs.gw.com/])
AC_CONFIG_SRCDIR([tc.vers.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_TESTDIR([.], [.])
......@@ -178,9 +178,12 @@ case "${host}" in
*-*-solaris2.[45] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol24
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
*-*-solaris2.[678] ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol26
;;
*-*-solaris2.* ) # Should handle sparc, x86 and powerpc
tcsh_config_file=sol29
;;
## Dell SVR4
*-dell-sysv4* )
......@@ -300,6 +303,7 @@ AC_TYPE_GETGROUPS
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT32_T
AC_DEFUN([AC_TYPE_SSIZE_T], [
AC_CHECK_TYPE(ssize_t,,
......@@ -440,5 +444,5 @@ fi
AC_SUBST(HESDEF)
AC_SUBST(HESLIB)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile nls/Makefile])
AC_OUTPUT
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $ */
/*
* ed.chared.c: Character editing functions.
*/
......@@ -72,7 +72,7 @@
#include "sh.h"
RCSID("$tcsh: ed.chared.c,v 3.95 2009/06/25 21:15:37 christos Exp $")
RCSID("$tcsh: ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $")
#include "ed.h"
#include "tw.h"
......@@ -506,7 +506,7 @@ excl_sw:
if (*q == ':') /* short form: !:arg */
--q;
if (*q != HIST) {
if (HIST != '\0' && *q != HIST) {
/*
* Search for a space, tab, or colon. See if we have a number (as
* in !1234:xyz). Remember the number.
......@@ -716,8 +716,9 @@ c_excl(Char *p)
*/
nr_exp = 0;
for (;;) {
while (*p != HIST && p < Cursor)
++p;
if (HIST != '\0')
while (*p != HIST && p < Cursor)
++p;
for (i = 1; (p - i) >= InputBuf && p[-i] == '\\'; i++)
continue;
if (i % 2 == 0)
......@@ -729,8 +730,6 @@ c_excl(Char *p)
++nr_exp;
}
}
return nr_exp;
}
......@@ -745,13 +744,13 @@ c_substitute(void)
* for white space, the beginning of the line, or a history character.
*/
for (p = Cursor - 1;
p > InputBuf && *p != ' ' && *p != '\t' && *p != HIST; --p)
p > InputBuf && *p != ' ' && *p != '\t' && *p && *p != HIST; --p)
continue;
/*
* If we found a history character, go expand it.
*/
if (*p == HIST)
if (HIST != '\0' && *p == HIST)
nr_exp = c_excl(p);
else
nr_exp = 0;
......@@ -832,11 +831,11 @@ c_eword(Char *p, Char *high, int n)
while ((p < high) && Isspace(*p))
p++;
if (Isalnum(*p))
while ((p < high) && Isalnum(*p))
if (isword(*p))
while ((p < high) && isword(*p))
p++;
else
while ((p < high) && !(Isspace(*p) || Isalnum(*p)))
while ((p < high) && !(Isspace(*p) || isword(*p)))
p++;
}
......
/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.13 2010/05/07 15:13:58 christos Exp $ */
/*
* gethost.c: Create version file from prototype
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $")
RCSID("$tcsh: gethost.c,v 1.13 2010/05/07 15:13:58 christos Exp $")
#ifdef SCO
# define perror __perror
......@@ -231,7 +231,7 @@ main(int argc, char *argv[])
break;
case T_NONE:
if (state != S_CODE && defs && *defs != '\0') {
if (state != S_CODE && *defs != '\0') {
(void) fprintf(stderr, "%s: \"%s\", %d: Discarded\n",
pname, fname, lineno);
if (++errs == 30) {
......
......@@ -329,7 +329,7 @@ glob(const char *pattern, int flags, int (*errfunc) (const char *, int),
len = mblen((const char *)(patnext - 1), MB_LEN_MAX);
if (len == -1)
(void)mblen(NULL, 0);
TCSH_IGNORE(mblen(NULL, 0));
else if (len > 1) {
*bufnext++ = (Char) c;
while (--len != 0)
......@@ -389,10 +389,13 @@ glob(const char *pattern, int flags, int (*errfunc) (const char *, int),
break;
case STAR:
pglob->gl_flags |= GLOB_MAGCHAR;
/* collapse adjacent stars to one, to avoid
* exponential behavior
/* collapse adjacent stars to one [or three if globstar],
* to avoid exponential behavior
*/
if (bufnext == patbuf || bufnext[-1] != M_ALL)
if (bufnext == patbuf || bufnext[-1] != M_ALL ||
((flags & GLOB_STAR) != 0 &&
(bufnext - 1 == patbuf || bufnext[-2] != M_ALL ||
bufnext - 2 == patbuf || bufnext[-3] != M_ALL)))
*bufnext++ = M_ALL;
break;
default:
......@@ -530,7 +533,24 @@ glob2(struct strbuf *pathbuf, const Char *pattern, glob_t *pglob, int no_match)
/* NOTREACHED */
}
static size_t
One_Char_mbtowc(__Char *pwc, const Char *s, size_t n)
{
#ifdef WIDE_STRINGS
char buf[MB_LEN_MAX], *p;
if (n > MB_LEN_MAX)
n = MB_LEN_MAX;
p = buf;
while (p < buf + n && (*p++ = LCHAR(*s++)) != 0)
;
return one_mbtowc(pwc, buf, n);
#else
*pwc = *s & CHAR;
return 1;
#endif
}
static int
glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern,
glob_t *pglob, int no_match)
......@@ -540,10 +560,26 @@ glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern,
int err;
Char m_not = (pglob->gl_flags & GLOB_ALTNOT) ? M_ALTNOT : M_NOT;
size_t orig_len;
const Char *p = pattern;
int globstar = 0;
int chase_symlinks = 0;
strbuf_terminate(pathbuf);
errno = 0;
while (p < restpattern) {
__Char wc;
size_t width = One_Char_mbtowc(&wc, p, MB_LEN_MAX);
if ((p[0] & M_MASK) == M_ALL && (p[width] & M_MASK) == M_ALL
&& p + width < restpattern) {
globstar = 1;
if (p[width + width] == M_ALL)
chase_symlinks = 1;
break;
}
p += width;
}
if (!(dirp = Opendir(pathbuf->s))) {
/* todo: don't call for ENOENT or ENOTDIR? */
if ((pglob->gl_errfunc && (*pglob->gl_errfunc) (pathbuf->s, errno)) ||
......@@ -560,16 +596,42 @@ glob3(struct strbuf *pathbuf, const Char *pattern, const Char *restpattern,
while ((dp = readdir(dirp)) != NULL) {
/* initial DOT must be matched literally */
if (dp->d_name[0] == DOT && *pattern != DOT)
continue;
if (!(pglob->gl_flags & GLOB_DOT) || !dp->d_name[1] ||
(dp->d_name[1] == DOT && !dp->d_name[2]))
continue; /*unless globdot and not . or .. */
pathbuf->len = orig_len;
strbuf_append(pathbuf, dp->d_name);
strbuf_terminate(pathbuf);
if (match(pathbuf->s + orig_len, pattern, restpattern, (int) m_not)</