Commit 5830ea2e authored by Thomas Lange's avatar Thomas Lange

Merge tag 'upstream/6.19.00'

Upstream version 6.19.00
parents f38131ab eae08626
*.o
Makefile
aclocal.m4
atconfig
autom4te.cache/
config.h
config.log
config.status
config_p.h
ed.defns.h
tc.defs.c
gethost
*.cat
sh.err.h
tags
tc.const.h
tcsh
# $tcsh: .travis.yml,v 1.2 2014/03/10 12:41:27 kim Exp $
language: c
compiler:
- gcc
- clang
before_install:
- sudo apt-get update -q=2
- sudo apt-get install -q=2 automake libtinfo-dev make
script:
- ./configure
- make -j4
- make check
......@@ -10,11 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
......
41 V6.19.00 - 20150521
40. V6.18.05 - 20150510
39. fix reseting when interrupted inside an eval "eval sleep 10^C"
(paulo.cesar.pereira.de.andrade)
38. rename handle_intr -> handle_interrupt as originally intended.
37. fix input tests that need stdin on a tty
36. V6.18.04 - 20150504
35. revert fix echo "\1", it is incorrect.
34. revert fix to PR/437, breaks short strings.
33. V6.18.03 - 20150503
32. PR/437: Nakajima Akira: Fix segmentation fault reading input files
31. PR/291: Print job status messages to stderr.
30. Fridolin Pokorny NUL in `` does not mean EOF.
29. Pavel Raiskup fix hang with:
while (1)
( date & ; wait )
end
28. Add cdtohome special variable (Martin Tournoij)
27. Fix root prompt char for windows (Corinna Vinschen)
26. For "next" completion matches only consider exact matches of the previous
word (Jamie Landeg-Jones)
25. Fix echo "\1" for echo_style=both where the first character was
not processed properly (Gary Duzan)
24. V6.18.02 - 20140618
23. fix ls-F /non printing exit value twice.
22. rename configure.in to configure.ac, add aclocal.m4 to CVS
21. set foo="aabaabaa"; echo $foo:as/a// should produce bb
20. Add locked merge history support (Marcin Konarski)
19. Support more resource limits from various BSD's
18. Cache history count to speed up thing
17. PR/240: minix support
16. revert fix for 15. Causes extra quoting, for example (foo is a program
that prints its arguments):
$ ./foo 'abc' *
'\a\b\c'
15. fix globbing for ``, stripping backslashes. Example:
cat << _EOF > huh
echo 'hello\;world'
_EOF
echo `./huh 0`
echo `./huh $?`
14. fix for `` that causes hang. Example:
cat << _EOF > huh
#!/bin/sh
echo "[$@]"
echo "I am running"
echo "I am running ($$)" >> huh.out
_EOF
cat << _EOF > huh.tcsh
#!/bin/tcsh -f
./huh \
`#comment blah blah blah` \
parameter a \
`#comment blah blah blah` \
parameter b \
`#comment blah blah blah` \
parameter c
echo ok
_EOF
13. remove AsciiOnly fix now that the real issue has been fixed (Roman Kollar)
12. define utmp file for aix (Laurence Darby)
11. fix if history in loops
10. make ls-F print to stderr and set the exit code
9. make rmstar interruptible on linux
8. Get rid of pret_t and make the printf functions return the number of
characters printed as the system ones do.
7. Parse a FreeBSD compat $LSCOLORS. What to do when both LSCOLORS and
LS_COLORS are set. I am not documenting this until we decide.
6. V6.18.01 - 20120214
5. fix interruptible wait again
4. ignore bogus compiler overflow message
......
XCOMM
XCOMM $tcsh: Imakefile,v 1.87 2010/01/28 19:01:05 christos Exp $
XCOMM $tcsh: Imakefile,v 1.88 2014/07/07 20:34:58 christos Exp $
XCOMM
XCOMM Imakefile for tcsh 6.12
XCOMM Marc Horowitz, MIT SIPB
......@@ -526,8 +526,8 @@ MISCF = Makefile.std Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
WishList config_f.h eight-bit.me glob.3 patchlevel.h \
pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
README.imake complete.tcsh vmsreadme.txt Makefile.vms termcap.vms \
snames.h host.defs gethost.c tcsh.man2html Makefile.in configure.in \
Makefile.win32
snames.h host.defs gethost.c tcsh.man2html Makefile.in configure.ac \
Makefile.win32 aclocal.m4
CONFSRCS=config/[a-z]*
......
# $tcsh: Makefile.in,v 3.49 2011/02/05 17:35:31 christos Exp $
# $tcsh: Makefile.in,v 3.56 2014/07/24 22:52:13 christos Exp $
# Makefile.in 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
......@@ -315,8 +315,8 @@ CPP = @CPP@
# on the suns does not know how to make dynamically linked binaries.
# This is set by autoconf.
CC = @CC@
#CC= gcc -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Werror -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wsign-compare -Wcast-qual -Wreturn-type -Wswitch -Wshadow -Wwrite-strings -Wextra
# -ansi -pedantic
#CC= gcc -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Werror -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wsign-compare -Wcast-qual -Wreturn-type -Wswitch -Wshadow -Wwrite-strings -Wextra -Wcast-qual -Wwrite-strings -Wold-style-definition -Wuninitialized -Wpointer-sign
# -Wconversion -Wformat=2 -ansi -pedantic
#CC= gcc -Wall -pipe -B/bin/
# Generate code for Intel 486 (linux)
#CC= gcc -m486 -pipe -Wall
......@@ -377,14 +377,14 @@ ASSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h \
tw.color.c
PSSRCS= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
PSSRCS= sh.decls.h glob.c glob.h dotlock.c dotlock.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
vms.termcap.c
SHSRCS= ${ASSRCS} ${PSSRCS}
SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
sh.char.${SUF} sh.exp.${SUF} sh.file.${SUF} sh.func.${SUF} \
sh.glob.${SUF} sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} \
sh.misc.${SUF} sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} \
sh.sem.${SUF} sh.set.${SUF} sh.time.${SUF} glob.${SUF} \
sh.sem.${SUF} sh.set.${SUF} sh.time.${SUF} glob.${SUF} dotlock.${SUF} \
mi.termios.${SUF} ma.setp.${SUF} vms.termcap.${SUF}
TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
......@@ -411,8 +411,8 @@ AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
WishList config_f.h eight-bit.me glob.3 patchlevel.h \
pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
host.defs gethost.c tcsh.man2html configure.in configure config.h.in \
tests/testsuite.at
host.defs gethost.c tcsh.man2html configure.ac configure config.h.in \
tests/testsuite.at aclocal.m4
TESTFILES= tests/aliases.at tests/arguments.at tests/commands.at \
tests/expr.at tests/lexical.at tests/mb-eucjp.at \
tests/mb-utf8.at tests/noexec.at tests/syntax.at tests/subst.at \
......@@ -449,7 +449,7 @@ pure:$(P) ${OBJS}
gethost: gethost.c sh.err.h tc.const.h sh.h
rm -f gethost
${CC_FOR_GETHOST} -o gethost ${CPPFLAGS} $(srcdir)/gethost.c
${CC_FOR_GETHOST} -o gethost ${CPPFLAGS} ${CFLAGS} $(srcdir)/gethost.c
tc.defs.c: gethost host.defs
@rm -f $@.tmp
......@@ -537,7 +537,7 @@ tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
@echo '#endif /* _h_tc_const */' >> $@.tmp
@if [ -f $@ ] && cmp -s $@.tmp $@; then echo $@ unchanged.; rm -f $@.tmp; else mv -f $@.tmp $@; echo $@ recreated.; fi
$(srcdir)/tests/package.m4: $(srcdir)/configure.in
$(srcdir)/tests/package.m4: $(srcdir)/configure.ac
{ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
......@@ -594,12 +594,12 @@ vgrind:
@vgrind -t -x -h Index index >/crp/bill/csh/index.t
install-strip: install
-strip ${DESTBIN}/tcsh$(EXEEXT)
install: tcsh$(EXEEXT) install.catalogs install.man
-mkdir -p ${DESTBIN}
-mv -f ${DESTBIN}/tcsh$(EXEEXT) ${DESTBIN}/tcsh.old
cp tcsh$(EXEEXT) ${DESTBIN}/tcsh$(EXEEXT)
-strip ${DESTBIN}/tcsh$(EXEEXT)
chmod 755 ${DESTBIN}/tcsh$(EXEEXT)
install.catalogs:
......@@ -623,25 +623,6 @@ install.man: tcsh.man
# nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
# chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
install.cygwin: install
-gzip ${DESTMAN}/tcsh.${MANSECT}
-mkdir -p ${DESTDIR}${prefix}/share/doc/tcsh
cp ${srcdir}/FAQ ${srcdir}/Fixes ${DESTDIR}${prefix}/share/doc/tcsh
cp ${srcdir}/NewThings ${srcdir}/README ${DESTDIR}${prefix}/share/doc/tcsh
cp ${srcdir}/WishList ${srcdir}/Y2K ${DESTDIR}${prefix}/share/doc/tcsh
perl ${srcdir}/tcsh.man2html ${srcdir}/tcsh.man
cp -rp tcsh.html ${DESTDIR}${prefix}/share/doc/tcsh
-mkdir -p ${DESTDIR}/etc/defaults/etc/profile.d
-mkdir -p ${DESTDIR}/etc/profile.d
-mkdir -p ${DESTDIR}/etc/postinstall
-mkdir -p ${DESTDIR}/etc/preremove
cp -p ${srcdir}/cygwin/csh.cshrc ${DESTDIR}/etc/defaults/etc
cp -p ${srcdir}/cygwin/csh.login ${DESTDIR}/etc/defaults/etc
cp -p ${srcdir}/cygwin/bindkey.tcsh ${DESTDIR}/etc/defaults/etc/profile.d
cp -p ${srcdir}/complete.tcsh ${DESTDIR}/etc/defaults/etc/profile.d
cp -p ${srcdir}/cygwin/postinstall.sh ${DESTDIR}/etc/postinstall/tcsh.sh
cp -p ${srcdir}/cygwin/preremove.sh ${DESTDIR}/etc/preremove/tcsh.sh
clean: clean.catalogs
${RM} -f a.out strings x.c xs.c tcsh$(EXEEXT) tcsh.a _MAKE_LOG gethost
${RM} -f *.${SUF} *.i *.s
......@@ -748,11 +729,11 @@ ftp: tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z
autoconfigure: $(srcdir)/configure $(srcdir)/config.h.in
$(srcdir)/configure: $(srcdir)/configure.in
$(srcdir)/configure: $(srcdir)/configure.ac
cd $(srcdir) && autoconf
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: $(srcdir)/configure.in
$(srcdir)/stamp-h.in: $(srcdir)/configure.ac
cd $(srcdir) && autoheader
@echo timestamp > $(srcdir)/stamp-h.in
......@@ -787,6 +768,9 @@ ${TWOBJS} ${TWINC}: ${TWH}
# glob.h
glob.${SUF} sh.glob.${SUF}: glob.h
# dotlock.h
dotlock.${SUF}: dotlock.h
# ed.defns.h
EDDINC=tc.bind.${SUF} tc.func.${SUF} tc.os.${SUF}
${EDOBJS} ${EDDINC}: ed.defns.h
......
# $tcsh: Makefile.std,v 1.97 2006/03/02 18:46:44 christos Exp $
# $tcsh: Makefile.std,v 1.99 2014/07/07 20:34:58 christos Exp $
# Makefile.std 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
......@@ -287,14 +287,14 @@ ASSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h
PSSRCS= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
PSSRCS= sh.decls.h glob.c glob.h dotlock.c dotlock.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
vms.termcap.c
SHSRCS= ${ASSRCS} ${PSSRCS}
SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
sh.char.${SUF} sh.exp.${SUF} sh.file.${SUF} sh.func.${SUF} \
sh.glob.${SUF} sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} \
sh.misc.${SUF} sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} \
sh.sem.${SUF} sh.set.${SUF} sh.time.${SUF} glob.${SUF} \
sh.sem.${SUF} sh.set.${SUF} sh.time.${SUF} glob.${SUF} dotlock.${SUF} \
mi.termios.${SUF} ma.setp.${SUF} vms.termcap.${SUF}
TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
......@@ -321,7 +321,8 @@ AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
WishList config_f.h eight-bit.me glob.3 patchlevel.h \
pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
host.defs gethost.c tcsh.man2html configure.in configure config.h.in
host.defs gethost.c tcsh.man2html configure.ac configure config.h.in \
aclocal.m4
VHSRCS=${PVSRCS} ${AVSRCS}
......@@ -584,11 +585,11 @@ ftp: tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z
autoconfigure: $(srcdir)/configure $(srcdir)/config.h.in
$(srcdir)/configure: $(srcdir)/configure.in
$(srcdir)/configure: $(srcdir)/configure.ac
cd $(srcdir) && autoconf
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: $(srcdir)/configure.in
$(srcdir)/stamp-h.in: $(srcdir)/configure.ac
cd $(srcdir) && autoheader
@echo timestamp > $(srcdir)/stamp-h.in
......@@ -620,6 +621,9 @@ ${TWOBJS} ${TWINC}: ${TWH}
# glob.h
glob.${SUF} sh.glob.${SUF}: glob.h
# dotlock.h
dotlock.${SUF}: dotlock.h
# ed.defns.h
EDDINC=tc.bind.${SUF} tc.func.${SUF} tc.os.${SUF}
${EDOBJS} ${EDDINC}: ed.defns.h
......
# $tcsh: Makefile.vms,v 1.39 2006/03/02 18:46:44 christos Exp $
# $tcsh: Makefile.vms,v 1.40 2014/07/07 20:34:58 christos Exp $
# Makefile.vms 4.3 6/11/83
#
# C Shell with process control; VM/UNIX VAX Makefile
......@@ -299,7 +299,7 @@ AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
WishList config_f.h eight-bit.me glob.3 patchlevel.h \
pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
host.defs gethost.c tcsh.man2html configure.in
host.defs gethost.c tcsh.man2html configure.ac aclocal.m4
VHSRCS=${PVSRCS} ${AVSRCS}
......
This is tcsh version 6.18.01. Tcsh is a version of the Berkeley
This is tcsh version 6.19.00. 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.
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/* config.h.in. Generated from configure.in by autoheader. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to the type of elements in the array set by `getgroups'. Usually
this is either `int' or `gid_t'. */
......
This diff is collapsed.
......@@ -98,6 +98,7 @@
#elif defined(__APPLE__)
# define SYSMALLOC
# define BSD_STYLE_COLORLS
#endif
#endif /* _h_config */
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.47 2011/02/05 20:34:55 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/config_f.h,v 3.50 2015/02/22 16:31:54 christos Exp $ */
/*
* config_f.h -- configure various defines for tcsh
*
......@@ -50,7 +50,7 @@
* WIDE_STRINGS Represent strings using wide characters
* Allows proper function in multibyte encodings like UTF-8
*/
#if defined (SHORT_STRINGS) && defined (NLS) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX)
#if defined (SHORT_STRINGS) && defined (NLS) && !defined (WINNT_NATIVE) && !defined(_OSD_POSIX) && SIZEOF_WCHAR_T > 1
# define WIDE_STRINGS
# if SIZEOF_WCHAR_T < 4
# define UTF16_STRINGS
......@@ -135,7 +135,7 @@
* This can be much slower and no memory statistics will be
* provided.
*/
#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__CYGWIN__) || defined(__GLIBC__)
#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX) || defined(__MVS__) || defined (__CYGWIN__) || defined(__GLIBC__) || defined(__OpenBSD__) || defined(__APPLE__)
# define SYSMALLOC
#else
# undef SYSMALLOC
......
This diff is collapsed.
......@@ -7,10 +7,10 @@ dnl You'll also need a version of config.guess from a gnu package
dnl
dnl Written by Kaveh Ghazi (ghazi@caip.rutgers.edu) 5/11/96.
dnl
dnl $tcsh: configure.in,v 3.99 2012/02/13 16:33:50 christos Exp $
dnl $tcsh: configure.ac,v 3.6 2015/05/21 21:38:12 christos Exp $
AC_PREREQ([2.59])dnl Minimum Autoconf version required.
AC_INIT([tcsh], [6.18.01], [http://bugs.gw.com/])
AC_INIT([tcsh], [6.19.00], [http://bugs.gw.com/])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([tc.vers.c])
AC_CONFIG_HEADERS([config.h])
......@@ -99,6 +99,11 @@ case "${host}" in
tcsh_config_file=sysV88
;;
## Minix systems
*-*-minix*)
tcsh_config_file=minix
;;
## NetBSD systems
*-*-netbsd*)
tcsh_config_file=bsd4.4
......@@ -119,6 +124,11 @@ case "${host}" in
tcsh_config_file=bsd4.4
;;
## MirBSD systems
*-*-mirbsd*)
tcsh_config_file=bsd4.4
;;
## OpenBSD systems
*-*-openbsd*)
tcsh_config_file=bsd4.4
......
#!/bin/bash
rm -f /usr/bin/csh /usr/bin/csh.exe /usr/bin/csh.lnk /usr/share/man/man1/csh.1*
cd /bin
ln -s tcsh csh
cd /usr/share/man/man1
ln -s tcsh.1 csh.1
[ -e /etc/csh.cshrc ] || cp /etc/defaults/etc/csh.cshrc /etc
[ -e /etc/csh.login ] || cp /etc/defaults/etc/csh.login /etc
[ -e /etc/profile.d/bindkey.tcsh ] || \
cp /etc/defaults/etc/profile.d/bindkey.tcsh /etc/profile.d
[ -e /etc/profile.d/complete.tcsh ] || \
cp /etc/defaults/etc/profile.d/complete.tcsh /etc/profile.d
#!/bin/bash
rm -f /usr/bin/csh /usr/bin/csh.exe /usr/bin/csh.lnk /usr/share/man/man1/csh.1*
/* $NetBSD: dotlock.c,v 1.11 2009/10/21 01:07:46 snj Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sh.h"
RCSID("$tcsh: dotlock.c,v 3.3 2014/03/09 00:11:54 christos Exp $");
#include <stdio.h>
#ifndef O_SYNC
#define O_SYNC 0
#endif
#include "dotlock.h"
static int create_exclusive(const char *);
/*
* Create a unique file. O_EXCL does not really work over NFS so we follow
* the following trick: [Inspired by S.R. van den Berg]
*
* - make a mostly unique filename and try to create it.
* - link the unique filename to our target
* - get the link count of the target
* - unlink the mostly unique filename
* - if the link count was 2, then we are ok; else we've failed.
*/
static int
create_exclusive(const char *fname)
{
char path[MAXPATHLEN], hostname[MAXHOSTNAMELEN + 1];
const char *ptr;
struct timeval tv;
pid_t pid;
size_t ntries, cookie;
int fd, serrno;
struct stat st;
(void)gettimeofday(&tv, NULL);
(void)gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname) - 1] = '\0';
pid = getpid();
cookie = pid ^ tv.tv_usec;
/*
* We generate a semi-unique filename, from hostname.(pid ^ usec)
*/
if ((ptr = strrchr(fname, '/')) == NULL)
ptr = fname;
else
ptr++;
(void)snprintf(path, sizeof(path), "%.*s.%s.%lx",
(int)(ptr - fname), fname, hostname, (u_long)cookie);
/*
* We try to create the unique filename.
*/
for (ntries = 0; ntries < 5; ntries++) {
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_SYNC, 0);
if (fd != -1) {
(void)close(fd);
break;
}
else if (errno == EEXIST)
continue;
else
return -1;
}
/*
* We link the path to the name
*/
if (link(path, fname) == -1)
goto bad;
/*
* Note that we stat our own exclusively created name, not the
* destination, since the destination can be affected by others.
*/
if (stat(path, &st) == -1)
goto bad;
(void)unlink(path);
/*
* If the number of links was two (one for the unique file and one
* for the lock), we've won the race
*/
if (st.st_nlink != 2) {
errno = EEXIST;
return -1;
}
return 0;
bad:
serrno = errno;
(void)unlink(path);
errno = serrno;
return -1;
}
/*
* fname -- Pathname to lock
* pollinterval -- Interval (miliseconds) to check for lock, -1 return
*/
int
dot_lock(const char *fname, int pollinterval)
{
char path[MAXPATHLEN];
sigset_t nset, oset;
int retval;
(void)sigemptyset(&nset);
(void)sigaddset(&nset, SIGHUP);
(void)sigaddset(&nset, SIGINT);
(void)sigaddset(&nset, SIGQUIT);
(void)sigaddset(&nset, SIGTERM);
(void)sigaddset(&nset, SIGTTIN);
(void)sigaddset(&nset, SIGTTOU);
(void)sigaddset(&nset, SIGTSTP);
(void)sigaddset(&nset, SIGCHLD);
(void)snprintf(path, sizeof(path), "%s.lock", fname);
retval = -1;
for (;;) {
handle_pending_signals();
(void)sigprocmask(SIG_BLOCK, &nset, &oset);
if (create_exclusive(path) != -1) {
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
retval = 0;
break;
}
else
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
if (errno != EEXIST)
break;
if (pollinterval) {
if (pollinterval == -1) {
errno = EEXIST;
break;
}
(void)usleep((unsigned int)pollinterval * 1000);
}
}
handle_pending_signals();
return retval;
}
void
dot_unlock(const char *fname)
{
char path[MAXPATHLEN];
(void)snprintf(path, sizeof(path), "%s.lock", fname);
(void)unlink(path);
}
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DOTLOCK_H_
#define _DOTLOCK_H_ 1
/*
* fname -- Pathname to lock
* pollinterval -- Interval (miliseconds) to check for lock, -1 return
*/
int dot_lock(const char *fname, int pollinterval);
void dot_unlock(const char *fname);
#endif /* #ifndef _DOTLOCK_H_ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.chared.c,v 3.99 2014/03/09 00:20:26 christos Exp $ */
/*
* ed.chared.c: Character editing functions.
*/
......@@ -72,7 +72,7 @@
#include "sh.h"
RCSID("$tcsh: ed.chared.c,v 3.98 2010/05/08 00:37:39 christos Exp $")
RCSID("$tcsh: ed.chared.c,v 3.99 2014/03/09 00:20:26 christos Exp $")
#include "ed.h"
#include "tw.h"
......@@ -941,7 +941,7 @@ c_push_kill(Char *start, Char *end)
/* Save InputBuf etc in SavedBuf etc for restore after cmd exec */
static void
c_save_inputbuf()
c_save_inputbuf(void)
{
SavedBuf.len = 0;
Strbuf_append(&SavedBuf, InputBuf);
......@@ -953,7 +953,7 @@ c_save_inputbuf()
}
CCRETVAL
GetHistLine()
GetHistLine(void)
{
struct Hist *hp;
int h;
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.71 2010/12/22 17:26:04 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.inputl.c,v 3.73 2012/10/19 15:23:32 christos Exp $ */
/*
* ed.inputl.c: Input line handling.
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: ed.inputl.c,v 3.71 2010/12/22 17:26:04 christos Exp $")
RCSID("$tcsh: ed.inputl.c,v 3.73 2012/10/19 15:23:32 christos Exp $")
#include "ed.h"
#include "ed.defns.h" /* for the function names */
......@@ -683,7 +683,7 @@ GetNextCommand(KEYCMD *cmdnum, Char *ch)
#ifdef DSPMBYTE
_enable_mbdisp &&
#else
MB_CUR_MAX == 1 &&
MB_LEN_MAX == 1 &&
#endif
!adrof(STRnokanji) && (*ch & META)) {
MetaNext = 0;
......@@ -800,17 +800,13 @@ GetNextChar(Char *cp)
return -1;
}
}
if (AsciiOnly) {
*cp = (unsigned char)*cbuf;
} else {
cbp++;
if (normal_mbtowc(cp, cbuf, cbp) == -1) {
reset_mbtowc();
if (cbp < MB_CUR_MAX)
continue; /* Maybe a partial character */
/* And drop the following bytes, if any */
*cp = (unsigned char)*cbuf | INVALID_BYTE;
}
cbp++;
if (normal_mbtowc(cp, cbuf, cbp) == -1) {
reset_mbtowc();
if (cbp < MB_CUR_MAX)
continue; /* Maybe a partial character */
/* And drop the following bytes, if any */
*cp = (unsigned char)*cbuf | INVALID_BYTE;
}
break;
}
......
/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $ */
/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.50 2015/05/04 15:31:13 christos Exp $ */
/*
* ed.refresh.c: Lower level screen refreshing functions
*/
......@@ -32,7 +32,7 @@
*/
#include "sh.h"
RCSID("$tcsh: ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $")
RCSID("$tcsh: ed.refresh.c,v 3.50 2015/05/04 15:31:13 christos Exp $")