Compare commits

..
Author SHA1 Message Date
Jordan K. Hubbard 324ec40db3 Tell stupid users to write the bootcode. 1994-11-22 10:58:58 +00:00
cvs2svn 17b0776217 This commit was manufactured by cvs2svn to create branch 'RELEASE_2_0'. 1994-11-22 10:57:37 +00:00
Jordan K. Hubbard 8d77b4e304 Fix some wonkiness in MY code this time. Sigh.. 1994-11-22 10:40:44 +00:00
Jordan K. Hubbard 157002a7fa Fix some 11th-hour wonkiness in Poul's code. 1994-11-22 10:37:25 +00:00
Poul-Henning Kamp 4c731d7856 -> RELEASE 1994-11-22 06:32:34 +00:00
cvs2svn 1afa50deb4 This commit was manufactured by cvs2svn to create branch 'RELEASE_2_0'. 1994-11-22 06:28:23 +00:00
Poul-Henning Kamp 5cc13c0e22 -> RELEASE_2_0 1994-11-22 06:28:22 +00:00
cvs2svn 9f0dc73359 This commit was manufactured by cvs2svn to create branch 'BETA_2_0'. 1994-11-21 11:18:49 +00:00
Jordan K. Hubbard 32cd273372 Put the cursor back in the right place.
Pretty up the help text.
1994-11-21 10:51:15 +00:00
Poul-Henning Kamp 92c9323d3b Tell Jordan when he has destroyed his disk. 1994-11-21 08:11:11 +00:00
cvs2svn 01233029ed This commit was manufactured by cvs2svn to create branch 'BETA_2_0'. 1994-11-21 07:33:22 +00:00
Poul-Henning Kamp c264e2c65c declare atdevbase
(this is on the branch of the tree)
1994-11-19 19:07:38 +00:00
Poul-Henning Kamp 45728f7c5d On the ALPHA-branch:
2.0-BETA now
1994-11-16 06:33:27 +00:00
cvs2svn e382a3a979 This commit was manufactured by cvs2svn to create branch 'ALPHA_2_0'. 1994-11-09 20:27:33 +00:00
Poul-Henning Kamp d216e1f6de Set version correctly. 1994-11-08 21:24:57 +00:00
cvs2svn f4856526c7 This commit was manufactured by cvs2svn to create branch 'ALPHA_2_0'. 1994-11-08 19:51:51 +00:00
14514 changed files with 981076 additions and 2475014 deletions

No files matched your search

-1
View File
@@ -1,4 +1,3 @@
# $Id:$
# @(#)COPYRIGHT 8.2 (Berkeley) 3/21/94
All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite
+44
View File
@@ -0,0 +1,44 @@
$FreeBSD$
This file really doesn't belong here, but I wanted to elicit comment
without starting a discussion as to where it really does belong.
Anyway, here goes...
When the new CVS tree was set up back in May, I wanted to ensure that
everybody at least gave some thought to asking other people to look at
code before it is committed. Since we have had a number of rancorous
discussions in the past about both committing code prematurely, and
committing code that was written by someone else, I decided to use the
`template' function of CVS to give people a chance to think about it.
The template looks like this:
Reviewed by:
Submitted by:
CVS: ----------------------------------------------------------------------
CVS: Delete the ``Reviewed by'' line if this is somebody else's work
CVS: (you are the reviewer).
CVS: Delete the ``Submitted by'' line if this is NOT somebody else's
CVS: work (you are the author).
If you are making substantial or possibly controversial changes to the
code, please talk to someone else who either has commit authority, or
who is recognized as an expert in the BSD community. This latter
category includes the author of the program or subsystem you're
modifying, like Rick Macklem for the NFS code, or Keith Bostic for
`vi'.
If the changes are insubstantial and noncontroversial (e.g., fixing
spelling errors, or most Makefile changes) there is no need for
review. Please delete the ``Reviewed by:'' line, though, so that the
logs look cleaner.
If you are committing code or modifications which were originally done
by some other person or group, them please please please make sure to
credit them in the ``Submitted by'' line. In this case, you are
considered to be the reviewer. If it is your own code, or that of
another team member, then you should delete the ``Submitted by'' line,
so that the logs look cleaner.
-GAWollman
+157 -568
View File
@@ -1,80 +1,64 @@
#
# $Id: Makefile,v 1.109.2.34 1998/09/04 06:07:43 jkh Exp $
# $Id: Makefile,v 1.29 1994/11/08 00:55:08 ache Exp $
#
# Make command line options:
# -DCLOBBER will remove /usr/include
# -DMAKE_KERBEROS4 to build KerberosIV
# -DCLOBBER will remove /usr/include and MOST of /usr/lib
# -DMAKE_LOCAL to add ./local to the SUBDIR list
# -DMAKE_PORTS to add ./ports to the SUBDIR list
# XXX1 -DMAKE_KERBEROS to build KerberosIV
# -DMAKE_EBONES to build eBones (KerberosIV)
#
# -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir
# -DNOCLEAN do not clean at all
# -DNOTOOLS do not rebuild any tools first
# -DNOCRYPT will prevent building of crypt versions
# -DNOLKM do not build loadable kernel modules
# -DNOOBJDIR do not run ``${MAKE} obj''
# -DNOPROFILE do not build profiled libraries
# -DNOSECURE do not go into secure subdir
# -DNOGAMES do not go into games subdir
# -DNOSHARE do not go into share subdir
# -DNOINFO do not make or install info files
# -DNOLIBC_R do not build libc_r.
# -DNOPERL do not make or install perl
# LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list
#
# The intended user-driven targets are:
# buildworld - rebuild *everything*, including glue to help do upgrades
# installworld- install everything built by "buildworld"
# world - buildworld + installworld
# update - convenient way to update your source tree (eg: sup/cvs)
# most - build user commands, no libraries or include files
# installmost - install user commands, no libraries or include files
#
# Standard targets (not defined here) are documented in the makefiles in
# /usr/share/mk. These include:
# obj depend all install clean cleandepend cleanobj
.if (!make(world)) && (!make(buildworld)) && (!make(installworld))
.MAKEFLAGS:= ${.MAKEFLAGS} -m ${.CURDIR}/share/mk
.endif
# XXX1 The kerberos IV off the 4.4-Lite tape (src/kerberosIV)
# will not build successfully yet. MAKE_KERBEROS should not be
# defined.
# Put initial settings here.
SUBDIR=
# We must do share/info early so that installation of info `dir'
# entries works correctly. Do it first since it is less likely to
# grow dependencies on include and lib than vice versa.
.if exists(share/info)
SUBDIR+= share/info
# Must be first for "distribute" to work
.if exists(release)
SUBDIR+= release
.endif
# We must do include and lib first so that the perl *.ph generation
# works correctly as it uses the header files installed by this.
.if exists(bin)
SUBDIR+= bin
.endif
.if exists(contrib)
SUBDIR+= contrib
.endif
.if exists(games)
SUBDIR+= games
.endif
.if exists(gnu)
SUBDIR+= gnu
.endif
.if exists(include)
SUBDIR+= include
.endif
.if exists(lib)
SUBDIR+= lib
.endif
.if exists(bin)
SUBDIR+= bin
.endif
.if exists(games) && !defined(NOGAMES)
SUBDIR+= games
.endif
.if exists(gnu)
SUBDIR+= gnu
.endif
.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS)
SUBDIR+= kerberosIV
.endif
.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
SUBDIR+= eBones
.endif
.if exists(libexec)
SUBDIR+= libexec
.endif
.if exists(sbin)
SUBDIR+= sbin
.endif
.if exists(share) && !defined(NOSHARE)
.if exists(share)
SUBDIR+= share
.endif
.if exists(sys)
@@ -100,297 +84,80 @@ SUBDIR+= etc
# These are last, since it is nice to at least get the base system
# rebuilt before you do them.
.if defined(LOCAL_DIRS)
.for _DIR in ${LOCAL_DIRS}
.if exists(${_DIR}) & exists(${_DIR}/Makefile)
SUBDIR+= ${_DIR}
.if defined(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
SUBDIR+= local
.endif
.endfor
.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
SUBDIR+= ports
.endif
# Handle -DNOOBJDIR, -DNOCLEAN and -DNOCLEANDIR
# Handle the -DNOOBJDIR and -DNOCLEANDIR
.if defined(NOOBJDIR)
OBJDIR=
.else
OBJDIR= obj
.endif
.if defined(NOCLEAN)
CLEANDIR=
.else
.if defined(NOCLEANDIR)
CLEANDIR= clean
.else
.else
CLEANDIR= cleandir
.endif
.endif
SUP?= cvsup
SUPFLAGS?= -g -L 2 -P -
#
# While building tools for bootstrapping, we dont need to waste time on
# profiled libraries or man pages. This speeds things up somewhat.
#
MK_FLAGS= -DNOINFO -DNOMAN -DNOPROFILE
#
# world
#
# Attempt to rebuild and reinstall *everything*, with reasonable chance of
# success, regardless of how old your existing system is.
#
# >> Beware, it overwrites the local build environment! <<
#
world:
world: hierarchy cleandist mk includes libraries tools
@echo "--------------------------------------------------------------"
@echo "make world started on `LC_TIME=C date`"
@echo " Rebuilding ${DESTDIR} The whole thing"
@echo "--------------------------------------------------------------"
.if target(pre-world)
@echo
@echo "--------------------------------------------------------------"
@echo " Making 'pre-world' target"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${MAKE} pre-world
.endif
cd ${.CURDIR} && ${MAKE} buildworld
cd ${.CURDIR} && ${MAKE} -B installworld
.if target(post-world)
@echo
@echo "--------------------------------------------------------------"
@echo " Making 'post-world' target"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${MAKE} post-world
.endif
@echo
@echo "--------------------------------------------------------------"
@echo "make world completed on `LC_TIME=C date`"
@echo "--------------------------------------------------------------"
${MAKE} depend all install
cd ${.CURDIR}/share/man && ${MAKE} makedb
.if defined(MAKEOBJDIRPREFIX)
WORLDTMP= ${MAKEOBJDIRPREFIX}${.CURDIR}/tmp
.else
WORLDTMP= /usr/obj${.CURDIR}/tmp
.endif
STRICTTMPPATH= ${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin
TMPPATH= ${STRICTTMPPATH}:${PATH}
# XXX COMPILER_PATH is needed for finding cc1, ld and as
# XXX GCC_EXEC_PREFIX is for *crt.o. It is probably unnecssary now
# tbat LIBRARY_PATH is set. We still can't use -nostdlib, since gcc
# wouldn't link *crt.o or libgcc if it were used.
# XXX LD_LIBRARY_PATH is for ld.so. It is also used by ld, although we don't
# want that - all compile-time library paths should be resolved by gcc.
# It fails for set[ug]id executables (are any used?).
COMPILER_ENV= BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \
COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \
GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \
LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \
LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib
BMAKEENV= PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t
XMAKEENV= PATH=${STRICTTMPPATH} ${COMPILER_ENV} \
CC='cc -nostdinc' # XXX -nostdlib
# used to compile and install 'make' in temporary build tree
IBMAKE= ${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP}
# bootstrap make
BMAKE= ${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
# cross make used for compilation
XMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP}
# cross make used for final installation
IXMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE}
#
# buildworld
#
# Attempt to rebuild the entire system, with reasonable chance of
# success, regardless of how old your existing system is.
#
buildworld:
.if !defined(NOCLEAN)
@echo
@echo "--------------------------------------------------------------"
@echo " Cleaning up the temporary build tree"
@echo "--------------------------------------------------------------"
mkdir -p ${WORLDTMP}
chflags -R noschg ${WORLDTMP}/
rm -rf ${WORLDTMP}
.endif
.if !defined(NOTOOLS)
@echo
@echo "--------------------------------------------------------------"
@echo " Making make"
@echo "--------------------------------------------------------------"
mkdir -p ${WORLDTMP}/usr/bin
.if !defined(NOCLEAN) || !defined(NOOBJDIR)
cd ${.CURDIR}/usr.bin/make && \
${IBMAKE} -I${.CURDIR}/share/mk ${CLEANDIR} ${OBJDIR}
.endif
cd ${.CURDIR}/usr.bin/make && \
${IBMAKE} -I${.CURDIR}/share/mk depend && \
${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all && \
${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} install && \
${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} clean cleandepend
.endif
@echo
hierarchy:
@echo "--------------------------------------------------------------"
@echo " Making hierarchy"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} hierarchy
.if !defined(NOCLEAN)
@echo
@echo "--------------------------------------------------------------"
@echo " Cleaning up the obj tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} par-${CLEANDIR}
.endif
.if !defined(NOOBJDIR)
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding the obj tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} par-obj
.endif
.if !defined(NOTOOLS)
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding bootstrap tools"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} bootstrap
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding tools necessary to build the include files"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} include-tools
.endif
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding /usr/include"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && SHARED=symlinks ${BMAKE} includes
.if !defined(NOTOOLS)
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding tools needed to build the libraries"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} lib-tools
.endif
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding /usr/lib"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} libraries
.if !defined(NOTOOLS)
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding all other tools needed to build the world"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${BMAKE} build-tools
.endif
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding dependencies"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${XMAKE} ${.MAKEFLAGS} par-depend
@echo
@echo "--------------------------------------------------------------"
@echo " Building everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${XMAKE} all
cd ${.CURDIR}/release && ${MAKE} hierarchy
#
# installworld
#
# Installs everything compiled by a 'buildworld'.
#
installworld:
cd ${.CURDIR} && ${IXMAKE} reinstall
#
# reinstall
#
# If you have a build server, you can NFS mount the source and obj directories
# and do a 'make reinstall' on the *client* to install new binaries from the
# most recent server build.
#
reinstall:
@echo "--------------------------------------------------------------"
@echo " Making hierarchy"
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${MAKE} hierarchy
@echo
@echo "--------------------------------------------------------------"
@echo " Installing everything.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ${MAKE} install
@echo
@echo "--------------------------------------------------------------"
@echo " Re-scanning the shared libraries.."
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && ldconfig -R
@echo
@echo "--------------------------------------------------------------"
@echo " Rebuilding man page indexes"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}/share/man && ${MAKE} makedb
#
# update
#
# Update the source tree, by running sup and/or running cvs to update to the
# latest copy.
#
update:
.if defined(SUP_UPDATE)
@echo "--------------------------------------------------------------"
@echo "Running ${SUP}"
@echo "Running sup"
@echo "--------------------------------------------------------------"
@${SUP} ${SUPFLAGS} ${SUPFILE}
.if defined(SUPFILE1)
@${SUP} ${SUPFLAGS} ${SUPFILE1}
.endif
.if defined(SUPFILE2)
@${SUP} ${SUPFLAGS} ${SUPFILE2}
.endif
@sup -v ${SUPFILE}
.endif
.if defined(CVS_UPDATE)
@echo "--------------------------------------------------------------"
@echo "Updating /usr/src from cvs repository" ${CVSROOT}
@echo "--------------------------------------------------------------"
cd ${.CURDIR} && cvs -q update -P -d -r RELENG_2_2
cd ${.CURDIR} && cvs update -P -d
.endif
#
# most
#
# Build most of the user binaries on the existing system libs and includes.
#
most:
cleandist:
.if !defined(NOCLEANDIR)
@echo "--------------------------------------------------------------"
@echo " Building programs only"
@echo " Cleaning up the source tree, and rebuilding the obj tree"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
# cd ${.CURDIR}/kerberosIV && ${MAKE} ${.MAKEFLAGS} most
#.endif
#.if !defined(NOSECURE) && !defined(NOCRYPT)
# cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} most
#.endif
@echo
here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
if test -d /usr/obj -a ! -d $$dest; then \
mkdir -p $$dest; \
else \
true; \
fi; \
cd $$dest && rm -rf ${SUBDIR}
find . -name obj | xargs rm -rf
.if defined(MAKE_LOCAL) & exists(local) & exists(local/Makefile)
# The cd is done as local may well be a symbolic link
-cd local && find . -name obj | xargs rm -rf
.endif
.if defined(MAKE_PORTS) & exists(ports) & exists(ports/Makefile)
# The cd is done as local may well be a symbolic link
-cd ports && find . -name obj | xargs rm -rf
.endif
${MAKE} cleandir
${MAKE} obj
.endif
#
# installmost
#
# Install the binaries built by the 'most' target. This does not include
# libraries or include files.
#
installmost:
@echo "--------------------------------------------------------------"
@echo " Installing programs only"
@@ -402,303 +169,125 @@ installmost:
cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} install
cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} install
cd ${.CURDIR}/gnu/usr.sbin && ${MAKE} ${.MAKEFLAGS} install
#.if defined(MAKE_KERBEROS4) && !defined(NOCRYPT)
# cd ${.CURDIR}/kerberos4 && ${MAKE} ${.MAKEFLAGS} installmost
#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
# cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} installmost
#.endif
#.if !defined(NOSECURE) && !defined(NOCRYPT)
# cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} installmost
#.endif
#
# ------------------------------------------------------------------------
#
# From here onwards are utility targets used by the 'make world' and
# related targets. If your 'world' breaks, you may like to try to fix
# the problem and manually run the following targets to attempt to
# complete the build. Beware, this is *not* guaranteed to work, you
# need to have a pretty good grip on the current state of the system
# to attempt to manually finish it. If in doubt, 'make world' again.
#
most:
@echo "--------------------------------------------------------------"
@echo " Building programs only"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}/bin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/sbin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/libexec && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/usr.bin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/usr.sbin && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/gnu/libexec && ${MAKE} ${.MAKEFLAGS} all
cd ${.CURDIR}/gnu/usr.bin && ${MAKE} ${.MAKEFLAGS} all
#.if defined(MAKE_EBONES) && !defined(NOCRYPT)
# cd ${.CURDIR}/eBones && ${MAKE} ${.MAKEFLAGS} most
#.endif
#.if !defined(NOSECURE) && !defined(NOCRYPT)
# cd ${.CURDIR}/secure && ${MAKE} ${.MAKEFLAGS} most
#.endif
#
# heirarchy - ensure that all the needed directories are present
#
hierarchy:
cd ${.CURDIR}/etc && ${MAKE} distrib-dirs
mk:
@echo "--------------------------------------------------------------"
@echo " Rebuilding ${DESTDIR}/usr/share/mk"
@echo "--------------------------------------------------------------"
cd ${.CURDIR}/share/mk && ${MAKE} install
#
# bootstrap - [re]build tools needed to run the actual build, this includes
# tools needed by 'make depend', as some tools are needed to generate source
# for the dependency information to be gathered from.
#
bootstrap:
.if defined(DESTDIR)
rm -f ${DESTDIR}/usr/src/sys
ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src
cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include
cd ${.CURDIR}/include && make symlinks
.endif
cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/usr.bin/lex && ${MAKE} bootstrap && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} -DNOLIB all && \
${MAKE} ${MK_FLAGS} -DNOLIB -B install ${CLEANDIR}
.if !defined(NOOBJDIR)
cd ${.CURDIR}/usr.bin/lex && ${MAKE} obj
.endif
#
# include-tools - generally the same as 'bootstrap', except that it's for
# things that are specifically needed to generate include files.
#
# XXX should be merged with bootstrap, it's not worth keeeping them separate.
# Well, maybe it is now. We force 'cleandepend' here to avoid dependencies
# on cleaned away headers in ${WORLDTMP}.
#
include-tools:
cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} -B cleandepend depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
#
# includes - possibly generate and install the include files.
#
includes:
@echo "--------------------------------------------------------------"
@echo " Rebuilding ${DESTDIR}/usr/include"
@echo "--------------------------------------------------------------"
@echo
.if defined(CLOBBER)
rm -rf ${DESTDIR}/usr/include/*
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${DESTDIR}/usr/include
rm -rf ${DESTDIR}/usr/include
mkdir ${DESTDIR}/usr/include
chown ${BINOWN}.${BINGRP} ${DESTDIR}/usr/include
chmod 755 ${DESTDIR}/usr/include
.endif
cd ${.CURDIR}/include && ${MAKE} -B all install
cd ${.CURDIR}/gnu/include && ${MAKE} install
cd ${.CURDIR}/include && ${MAKE} install
cd ${.CURDIR}/gnu/include && ${MAKE} install
cd ${.CURDIR}/gnu/lib/libreadline && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libregex && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libstdc++ && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libg++ && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libdialog && ${MAKE} beforeinstall
.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
cd ${.CURDIR}/kerberosIV/lib/libacl && ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkadm && ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkafs && ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkdb && ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libkrb && ${MAKE} beforeinstall
cd ${.CURDIR}/kerberosIV/lib/libtelnet && ${MAKE} beforeinstall
.else
cd ${.CURDIR}/lib/libtelnet && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libg++ && ${MAKE} beforeinstall
cd ${.CURDIR}/gnu/lib/libdialog && ${MAKE} beforeinstall
.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS)
cd ${.CURDIR}/kerberosIV/include && ${MAKE} install
.endif
.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
cd ${.CURDIR}/eBones/include && ${MAKE} beforeinstall
.endif
cd ${.CURDIR}/lib/csu/i386 && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libalias && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libc && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libcurses && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libedit && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libftpio && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libmd && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libmytinfo && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libncurses && ${MAKE} beforeinstall
.if !defined(WANT_CSRG_LIBM)
cd ${.CURDIR}/lib/libmytinfo && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libncurses && ${MAKE} beforeinstall
.if defined(WANT_MSUN)
cd ${.CURDIR}/lib/msun && ${MAKE} beforeinstall
.endif
cd ${.CURDIR}/lib/libpcap && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/librpcsvc && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libskey && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libtermcap && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libcom_err && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libss && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libscsi && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libutil && ${MAKE} beforeinstall
cd ${.CURDIR}/lib/libz && ${MAKE} beforeinstall
#
# lib-tools - build tools to compile and install the libraries.
#
# XXX gperf is required for cc
# XXX a new ld and tsort is required for cc
lib-tools:
.for d in \
gnu/usr.bin/gperf \
gnu/usr.bin/ld \
usr.bin/tsort \
gnu/usr.bin/as \
gnu/usr.bin/bison \
gnu/usr.bin/awk \
usr.bin/ar \
usr.bin/compile_et \
usr.bin/lex/lib \
usr.bin/mk_cmds \
usr.bin/nm \
usr.bin/ranlib \
usr.bin/uudecode \
gnu/usr.bin/cc
cd ${.CURDIR}/$d && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endfor
#
# libraries - build and install the libraries
#
libraries:
.if exists(lib/csu/i386)
cd ${.CURDIR}/lib/csu/i386 && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib/libcompat)
cd ${.CURDIR}/lib/libcompat && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib/libc)
cd ${.CURDIR}/lib/libc && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib/libmytinfo)
cd ${.CURDIR}/lib/libmytinfo && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib/libncurses)
cd ${.CURDIR}/lib/libncurses && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib/libtermcap)
cd ${.CURDIR}/lib/libtermcap && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(gnu)
cd ${.CURDIR}/gnu/lib && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
@echo "--------------------------------------------------------------"
@echo " Rebuilding ${DESTDIR}/usr/lib"
@echo "--------------------------------------------------------------"
@echo
.if defined(CLOBBER)
find ${DESTDIR}/usr/lib \! -name '*.s[ao].*' -a \! -type d | \
xargs rm -rf
.endif
cd ${.CURDIR}/gnu/lib && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/gnu/usr.bin/cc/libgcc && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.if exists(secure) && !defined(NOCRYPT) && !defined(NOSECURE)
cd ${.CURDIR}/secure/lib && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/secure/lib && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(lib)
cd ${.CURDIR}/lib && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/lib/csu/i386 && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/lib && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(usr.bin/lex/lib)
cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/usr.bin/lex/lib && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.if exists(kerberosIV) && !defined(NOCRYPT) && defined(MAKE_KERBEROS)
cd ${.CURDIR}/kerberosIV/acl && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/kerberosIV/des && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/kerberosIV/kdb && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/kerberosIV/krb && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(kerberosIV) && exists(crypto) && !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
cd ${.CURDIR}/kerberosIV/lib && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endif
.if exists(usr.sbin/pcvt/keycap)
cd ${.CURDIR}/usr.sbin/pcvt/keycap && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.if exists(eBones) && !defined(NOCRYPT) && defined(MAKE_EBONES)
cd ${.CURDIR}/eBones/des && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/eBones/acl && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/eBones/kdb && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/eBones/krb && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.endif
# Exclude perl from the build-tools if NOPERL is defined.
.if defined(NOPERL)
_perl=
.else
_perl= gnu/usr.bin/perl/perl
.endif
#
# build-tools - build and install any other tools needed to complete the
# compile and install.
# ifdef stale
# bc and cpp are required to build groff. Otherwise, the order here is
# mostly historical, i.e., bogus.
# chmod is used to build gcc's tmpmultilib[2] at obscure times.
# endif stale
# XXX uname is a bug - the target should not depend on the host.
#
build-tools:
.for d in \
bin/cat \
bin/chmod \
bin/cp \
bin/date \
bin/dd \
bin/echo \
usr.bin/yacc \
bin/expr \
bin/hostname \
bin/ln \
bin/ls \
bin/mkdir \
bin/mv \
bin/rm \
bin/test \
gnu/usr.bin/bc \
gnu/usr.bin/grep \
gnu/usr.bin/groff \
gnu/usr.bin/gzip \
gnu/usr.bin/man/makewhatis \
gnu/usr.bin/patch \
${_perl} \
gnu/usr.bin/sort \
gnu/usr.bin/texinfo \
usr.bin/basename \
usr.bin/cap_mkdb \
usr.bin/chflags \
usr.bin/cmp \
usr.bin/col \
usr.bin/cpp \
usr.bin/expand \
usr.bin/file2c \
usr.bin/find \
usr.bin/gencat \
usr.bin/id \
usr.bin/lorder \
usr.bin/m4 \
usr.bin/mkdep \
usr.bin/paste \
usr.bin/sed \
usr.bin/size \
usr.bin/soelim \
usr.bin/strip \
usr.bin/symorder \
usr.bin/touch \
usr.bin/tr \
usr.bin/true \
usr.bin/uname \
usr.bin/uuencode \
usr.bin/vgrind \
usr.bin/vi \
usr.bin/wc \
usr.sbin/chown \
usr.sbin/mtree \
usr.sbin/zic \
bin/sh
cd ${.CURDIR}/$d && ${MAKE} depend && \
${MAKE} ${MK_FLAGS} all && \
${MAKE} ${MK_FLAGS} -B install ${CLEANDIR} ${OBJDIR}
.endfor
.for __target in clean cleandir obj depend
.for entry in ${SUBDIR}
${entry}.${__target}__D: .PHONY
if test -d ${.CURDIR}/${entry}.${MACHINE}; then \
${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE}"; \
edir=${entry}.${MACHINE}; \
cd ${.CURDIR}/$${edir}; \
else \
${ECHODIR} "===> ${DIRPRFX}${entry}"; \
edir=${entry}; \
cd ${.CURDIR}/$${edir}; \
fi; \
${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/
.endfor
par-${__target}: ${SUBDIR:S/$/.${__target}__D/}
.endfor
tools:
@echo "--------------------------------------------------------------"
@echo " Rebuilding ${DESTDIR} Compiler and Make"
@echo "--------------------------------------------------------------"
@echo
cd ${.CURDIR}/gnu/usr.bin/cc && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
cd ${.CURDIR}/usr.bin/make && \
${MAKE} depend all install ${CLEANDIR} ${OBJDIR}
.include <bsd.subdir.mk>
-76
View File
@@ -1,76 +0,0 @@
This is the top level of the FreeBSD source directory. This file
was last revised on: $Id: README,v 1.7.2.2 1998/02/15 10:47:57 jkh Exp $
For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).
The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel and the contents of /etc. Please see the top of the Makefile
in this directory for more information on the standard build targets
and compile-time flags.
Building a kernel with config(8) is a somewhat more involved process,
documentation for which can be found at:
http://www.freebsd.org/handbook/kernelconfig.html
And in the config(8) man page.
The sample kernel configuration files reside in the sys/i386/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel. The file LINT contains entries for all possible devices, not
just those commonly used, and is meant more as a general reference
than an actual kernel configuration file (a kernel built from it
wouldn't even run).
Source Roadmap:
---------------
bin System/User commands.
contrib Packages contributed by 3rd parties.
crypto Export controlled stuff (see crypto/README).
etc Template files for /etc
games Amusements.
gnu Various commands and libraries under the GNU Public License.
Please see gnu/COPYING* for more information.
include System include files.
kerberosIV Kerberos package - also export controlled.
lib System libraries.
libexec System daemons.
lkm Loadable Kernel Modules.
release Release building Makefile & associated tools.
sbin System commands.
secure DES and DES-related utilities - NOT FOR EXPORT!
share Shared resources.
sys Kernel sources.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
http://www.freebsd.org/handbook/synching.html
+168
View File
@@ -0,0 +1,168 @@
; $Id: TODO,v 1.4 1994/09/11 20:01:03 phk Exp $
** To skip this preamble, search forward for the pattern `**'.
This file contains a list of ideas that people have come up for "good
things to do" in FreeBSD 2.0. These aren't necessarily things on the
fast-track, and in fact consist mostly of things that the core team is
never going to find the time to do so, if most things here are going
to happen at all, they'll happen when someone reading this list steps
forward and volunteers!
That said, a lot of these ideas would be very nice to have and would
add substantially to the perceived value of FreeBSD. Some items on
this list would add a LOT of value, for that matter, and are by no
means trivial. Take and fix an item with a (*) next to it and WC will
even send you a free 2.0 CD for your troubles! It's the least they
can do for all notable contributors.
This is a also good place to look if you're keen for a little
assignment, whole project or just something random to do. Many folks
often feel intimidated by the sheer size of FreeBSD and think "I'd
like to pitch in somehow, but god, what can _I_ do? I can't possibly
do any of the things the core team are doing - aiiggh! They'll laugh
at my code, I know it! I can't do it!"
Trust us, don't worry! Take a dedicated stab at something on this
list and most of us will applaud - even if you don't finish, you may
stir someone else into picking it up where you left off. Above all,
pick something you'll have fun doing!
There are small things and large things in this list, and we may
periodically reshuffle it to mark things done, outdated or more
important. Tasks are tagged with a unique ID number (YYMMDDNNN) for
later tracking and are also easily machine-parsable by those seeking
to browse them with some home-rolled search program. Some indication
of relative difficulty level is also given for each task, though it
should be kept in mind that one persons "easy" is anothers
"impossible", so take the ratings with a grain of salt! :)
If you start working on something from this list, we also suggest that
you contact the email-address listed for more information and to
provide some central coordination for your effort. If the email
address given is simply <foo> then the email address can be presumed
to be <[email protected]>. If no email address is listed, then
simply send to <[email protected]>.
Thanks!
The FreeBSD core team.
** --- cut here ---
TASKID: 940820001
TASK: Add interupts to pas.c
DETAIL: { You'll need a manual for the ncr-5380 chip and possibly some
doc on the PAS16. Linux/NetBSD also have existing drivers to study. }
EMAIL: <phk>
CATS: kernel scsi
GRADE: ADVANCED
STATUS: OPEN
TASKID: 940820002
TASK: Add Linux/Crynwr compatible plip mode to lpt.c
DETAIL: { Use IF_LLC0 as mode-flag. Look at the crynwr packet-driver
plip.asm (ftp::ftp.ftp.com) and the linux driver for reference. }
EMAIL: <phk>
CATS: kernel networking
GRADE: ADVANCED
STATUS: OPEN (*)
TASKID: 940820003
TASK: Add laptop-feature to wd.c
DETAIL: { If disk just spun up, do sync when we have it running. Need
to detect that disk was turned off, e.g. had a long delay in becomming
ready again. }
EMAIL: <phk>
CATS: kernel laptop
GRADE: INTERMEDIATE
STATUS: OPEN
TASKID: 940820004
TASK: Add hot-swap PCMICIA bus and driver support.
DETAIL: { Several teams in Linux and one in NetBSD are working on providing
hot insertion/removal and autoconfiguration of PCMCIA cards. This task
also requires some modification of existing drivers to support being used
by PCMCIA cards. This task is both really hard and comparatively easy;
hard because it's a big job, easy because others have already gone much of
the way and you have their work for reference. }
EMAIL: <jkh>
CATS: kernel laptop
GRADE: ADVANCED
STATUS: OPEN (*)
TASKID: 940820005
TASK: Salvage seagate.c driver from 1.1.5.1
DETAIL: { We've got a seagate driver that could use a little cleanup and
migration effort }
EMAIL: <jkh>
CATS: kernel scsi
GRADE: BEGINNER
STATUS: OPEN
TASKID: 940820006
TASK: Add bootp/DHCP to the generic ethernet code.
DETAIL: { Implement an ioctl(), which will send a bootp on a particular
interface and return the data in a usable format. OR make a program which uses
existing ioctls to do it. See RFC153[34] for information on DHCP. }
EMAIL: <phk>
CATS: kernel networking
GRADE: ADVANCED
STATUS: OPEN (*)
TASKID: 940820007
TASK: Add bootp/DHCP capability to slip driver.
DETAIL: { Cisco's products implement this. Both master and slave side would be
desirable. }
EMAIL: <phk>
CATS: kernel networking
GRADE: ADVANCED
STATUS: OPEN (*)
TASKID: 940820009
TASK: Make a freebsd.com MS-DOS boot program
DETAIL: { This program should be able to boot like the boot-blocks, that is
find a FreeBSD-partition and load the kernel from there, but it should
also be able to load the kernel from an optional MS-DOS file. }
EMAIL: <phk>
CATS: kernel DOS
GRADE: ADVANCED
STATUS: OPEN (*)
TASKID: 940820010
TASK: Make iostat find the disks
DETAIL: { This is actually mostly a change to the device-drivers to collect
the information in the first place. }
EMAIL: <phk>
CATS: kernel
GRADE: INTERMEDIATE
STATUS: OPEN
TASKID: 940820011
TASK: Silence "cc -Wall"
DETAIL: { Lots of warnings if you try this. You will find this a challenge
actually, and it is good training in the C language.}
EMAIL: <phk>
CATS: kernel user
GRADE: INTERMEDIATE
STATUS: OPEN (*)
TASKID: 940821001
TASK: Add XPG-style message catalogs.
DETAIL: { NetBSD has apparently already done the necessary work, so this
pretty much comes down to either evaluating their stuff and making any changes
necessary, or simply starting from scratch. Not having seen the code in
question, I leave it up to the best judgement of the implementor as to how to
best accomplish the task. }
EMAIL: <jkh>
CATS: user
GRADE: INTERMEDIATE
STATUS: OPEN
TASKID: 940911001
TASK: Make PAS16 a controller.
DETAIL: { Make the ProAudioSpectrum a controller like wdc1 and attach
sound and cdrom drivers to it. }
EMAIL: <phk>
CATS: kernel
GRADE: INTERMEDIATE
STATUS: OPEN
+2 -2
View File
@@ -1,7 +1,7 @@
# From: @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.4 1995/10/01 14:24:01 markm Exp $
# $Id$
SUBDIR= cat chio chmod cp csh date dd df domainname echo ed expr hostname \
SUBDIR= cat chmod cp csh date dd df domainname echo ed expr hostname \
kill ln ls mkdir mv pax ps pwd rcp rm rmail rmdir sh sleep \
stty sync test
-11
View File
@@ -1,15 +1,4 @@
# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
# $Id$
BINDIR?= /bin
NOSHARED?= YES
.if exists (${.CURDIR}/../../secure)
.if exists(${.CURDIR}/../../secure/lib/libcipher/obj)
CIPHEROBJDIR= ${.CURDIR}/../../secure/lib/libcipher/obj
.else
CIPHEROBJDIR= ${.CURDIR}/../../secure/lib/libcipher
.endif
.endif
+25 -26
View File
@@ -32,10 +32,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
.\" $Id: cat.1,v 1.3.2.2 1998/06/30 06:42:19 charnier Exp $
.\" @(#)cat.1 8.1 (Berkeley) 6/29/93
.\" $Id$
.\"
.Dd May 2, 1995
.Dd June 29, 1993
.Dt CAT 1
.Os BSD 3
.Sh NAME
@@ -48,7 +48,7 @@
.Op Ar
.Sh DESCRIPTION
The
.Nm
.Nm cat
utility reads files sequentially, writing them to the standard output.
The
.Ar file
@@ -56,56 +56,60 @@ operands are processed in command line order.
A single dash represents the standard input.
.Pp
The options are as follows:
.Bl -tag -width indent
.Bl -tag -width Ds
.It Fl b
Number the non-blank output lines, starting at 1.
Implies the
.Fl n
option but doesn't number blank lines.
.It Fl e
Display non-printing characters (see the
Implies the
.Fl v
option), and display a dollar sign
option, and displays a dollar sign
.Pq Ql \&$
at the end of each line.
at the end of each line
as well.
.It Fl n
Number the output lines, starting at 1.
Number the
.Ar output
lines, starting at 1.
.It Fl s
Squeeze multiple adjacent empty lines, causing the output to be
single spaced.
.It Fl t
Display non-printing characters (see the
Implies the
.Fl v
option), and display tab characters as
.Ql ^I .
option, and displays tab characters as
.Pq Ql ^I
as well.
.It Fl u
The
.Fl u
option guarantees that the output is unbuffered.
.It Fl v
Display non-printing characters so they are visible.
Displays non-printing characters so they are visible.
Control characters print as
.Ql ^X
for control-X; the delete
character (octal 0177) prints as
.Ql ^?
.Pf Non- Tn ASCII
characters (with the high bit set) are printed as
Non-ascii characters (with the high bit set) are printed as
.Ql M-
(for meta) followed by the character for the low 7 bits.
.El
.Pp
The
.Nm
.Nm cat
utility exits 0 on success, and >0 if an error occurs.
.Sh BUGS
Because of the shell language mechanism used to perform output
redirection, the command
.Dq Li cat file1 file2 > file1
.Dq Li cat file1 file 2 > file1
will cause the original data in file1 to be destroyed!
.Sh SEE ALSO
.Xr head 1 ,
.Xr more 1 ,
.Xr pr 1 ,
.Xr tail 1 ,
.Xr vis 1
.Xr tail 1
.Rs
.%A Rob Pike
.%T "UNIX Style, or cat -v Considered Harmful"
@@ -115,9 +119,4 @@ will cause the original data in file1 to be destroyed!
.Sh HISTORY
A
.Nm
command appeared in Version 1 AT&T UNIX.
.An Dennis Ritchie
designed and wrote the first man page.
It appears to have been
.Xr cat 1 .
command appeared in Version 6 AT&T UNIX.
+8 -16
View File
@@ -33,17 +33,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cat.c,v 1.5 1996/09/30 15:45:36 ache Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
static char sccsid[] = "@(#)cat.c 8.1 (Berkeley) 7/19/93";
#endif /* not lint */
#include <sys/param.h>
@@ -53,7 +53,6 @@ static char const sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -76,9 +75,7 @@ main(argc, argv)
extern int optind;
int ch;
setlocale(LC_CTYPE, "");
while ((ch = getopt(argc, argv, "benstuv")) != -1)
while ((ch = getopt(argc, argv, "benstuv")) != EOF)
switch (ch) {
case 'b':
bflag = nflag = 1; /* -b implies -n */
@@ -101,7 +98,7 @@ main(argc, argv)
case 'v':
vflag = 1;
break;
default:
case '?':
(void)fprintf(stderr,
"usage: cat [-benstuv] [-] [file ...]\n");
exit(1);
@@ -131,7 +128,6 @@ cook_args(argv)
fp = stdin;
else if ((fp = fopen(*argv, "r")) == NULL) {
warn("%s", *argv);
rval = 1;
++argv;
continue;
}
@@ -182,7 +178,7 @@ cook_buf(fp)
continue;
}
} else if (vflag) {
if (!isascii(ch) && !isprint(ch)) {
if (!isascii(ch)) {
if (putchar('M') == EOF || putchar('-') == EOF)
break;
ch = toascii(ch);
@@ -200,7 +196,6 @@ cook_buf(fp)
}
if (ferror(fp)) {
warn("%s", filename);
rval = 1;
clearerr(fp);
}
if (ferror(stdout))
@@ -221,7 +216,6 @@ raw_args(argv)
fd = fileno(stdin);
else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
warn("%s", *argv);
rval = 1;
++argv;
continue;
}
@@ -248,14 +242,12 @@ raw_cat(rfd)
err(1, "%s", filename);
bsize = MAX(sbuf.st_blksize, 1024);
if ((buf = malloc((u_int)bsize)) == NULL)
err(1, NULL);
err(1, "");
}
while ((nr = read(rfd, buf, bsize)) > 0)
for (off = 0; nr; nr -= nw, off += nw)
if ((nw = write(wfd, buf + off, nr)) < 0)
err(1, "stdout");
if (nr < 0) {
if (nr < 0)
warn("%s", filename);
rval = 1;
}
}
-7
View File
@@ -1,7 +0,0 @@
# $Id: Makefile,v 1.1.1.1 1997/03/06 15:30:06 joerg Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= chio
SRCS= chio.c
.include <bsd.prog.mk>
-205
View File
@@ -1,205 +0,0 @@
.\" $NetBSD: $
.\"
.\" Copyright (c) 1996 Jason R. Thorpe <[email protected]>
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgements:
.\" This product includes software developed by Jason R. Thorpe
.\" for And Communications, http://www.and.com/
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" 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.
.\"
.\" $Id$
.\"
.Dd April 2, 1996
.Dt CHIO 1
.Os
.Sh NAME
.Nm chio
.Nd medium changer control utility
.Sh SYNOPSIS
.Nm chio
.Op Fl f Ar changer
.Ar command
.Ar arg1
.Ar arg2
.Oo
.Ar arg3 Oo ...
.Oc
.Oc
.Sh DESCRIPTION
.Nm Chio
is used to control the operation of medium changers, such as those found
in tape and optical disk jukeboxes.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl f Ar changer
Use the device
.Pa changer
rather than the default device
.Pa /dev/ch0 .
.El
.Pp
The default changer may be overridden by setting the environment variable
.Ev CHANGER
to the desired changer device.
.Pp
A medium changer apparatus is made up of
.Em elements .
There are four element types:
.Em picker
(medium transport),
.Em slot
(storage),
.Em portal
(import/export), and
.Em drive
(data transfer). In this command description, the shorthand
.Em ET
will be used to represent an element type, and
.Em EU
will be used to represent an element unit. For example, to represent
the first robotic arm in the changer, the
.Em ET
would be
.Dq picker
and the
.Em EU
would be
.Dq 0 .
.Pp
.Sh SUPPORTED COMMANDS
.Bl -tag -width indent
.It Xo Nm chio move
.Ar <from ET> <from EU> <to ET> <to EU>
.Op Ar inv
.Xc
Move the media unit from
.Pa <from ET/EU>
to
.Pa <to ET/EU> .
If the optional modifier
.Pa inv
is specified, the media unit will be inverted before insertion.
.It Xo Nm chio exchange
.Ar <src ET> <src EU> <dst1 ET> <dst1 EU>
.Op Ar <dst2 ET> <dst2 ET>
.Op Ar inv1
.Op Ar inv2
.Xc
Perform a media unit exchange operation. The media unit in
.Pa <src ET/EU>
is moved to
.Pa <dst1 ET/EU>
and the media unit previously in
.Pa <dst1 ET/EU>
is moved to
.Pa <dst2 ET/EU> .
In the case of a simple exchange,
.Pa <dst2 ET/EU>
is omitted and the values
.Pa <src ET/EU>
are used in their place.
The optional modifiers
.Pa inv1
and
.Pa inv2
specify whether the media units are to be inverted before insertion into
.Pa <dst1 ET/EU>
and
.Pa <dst2 ET/EU>
respectively.
.Pp
Note that not all medium changers support the
.Nm exchange
operation; The changer must have multiple free pickers or emulate
multiple free pickers with transient storage.
.It Xo Nm chio position
.Ar <to ET> <to EU>
.Op Ar inv
.Xc
Position the picker in front of the element described by
.Pa <to ET/EU> .
If the optional modifier
.Pa inv
is specified, the media unit will be inverted before insertion.
.Pp
Note that not all changers behave as expected when issued this command.
.It Nm chio params
Report the number of slots, drives, pickers, and portals in the changer,
and which picker unit the changer is currently configured to use.
.It Nm chio getpicker
Report which picker unit the changer is currently configured to use.
.It Xo Nm chio setpicker
.Ar <unit>
.Xc
Configure the changer to use picker
.Pa <unit> .
.It Xo Nm chio status
.Op Ar <type>
.Xc
Report the status of all elements in the changer. If
.Pa <type>
is specified, report the status of all elements of type
.Pa <type> .
.El
.Pp
The status bits are defined as follows:
.Bl -tag -width indent
.It FULL
Element contains a media unit.
.It IMPEXP
Media was deposited into element by an outside human operator.
.It EXCEPT
Element is in an abnormal state.
.It ACCESS
Media in this element is accessible by a picker.
.It EXENAB
Element supports passing media (exporting) to an outside human operator.
.It INENAB
Element supports receiving media (importing) from an outside human operator.
.El
.Sh EXAMPLES
.Bl -tag -width indent
.It Nm chio move slot 3 drive 0
Move the media in slot 3 (fourth slot) to drive 0 (first drive).
.It Nm chio setpicker 2
Configure the changer to use picker 2 (third picker) for operations.
.El
.Sh FILES
.Bl -tag -width /dev/ch0 -compact
.It Pa /dev/ch0
default changer device
.El
.Sh SEE ALSO
.Xr mt 1 ,
.Xr ch 4 ,
.Xr mount 8
.Sh AUTHORS
The
.Nm
program and SCSI changer driver were written by
.An Jason R. Thorpe Aq [email protected]
for And Communications, http://www.and.com/
-667
View File
@@ -1,667 +0,0 @@
/* $Id: chio.c,v 1.1.1.1.2.2 1997/08/24 10:29:16 jkh Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgements:
* This product includes software developed by Jason R. Thorpe
* for And Communications, http://www.and.com/
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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 <sys/param.h>
#include <sys/ioctl.h>
#include <sys/chio.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "defs.h"
#include "pathnames.h"
static void usage __P((void));
static void cleanup __P((void));
static int parse_element_type __P((char *));
static int parse_element_unit __P((char *));
static int parse_special __P((char *));
static int is_special __P((char *));
static char *bits_to_string __P((int, const char *));
static int do_move __P((char *, int, char **));
static int do_exchange __P((char *, int, char **));
static int do_position __P((char *, int, char **));
static int do_params __P((char *, int, char **));
static int do_getpicker __P((char *, int, char **));
static int do_setpicker __P((char *, int, char **));
static int do_status __P((char *, int, char **));
/* Valid changer element types. */
const struct element_type elements[] = {
{ "picker", CHET_MT },
{ "slot", CHET_ST },
{ "portal", CHET_IE },
{ "drive", CHET_DT },
{ NULL, 0 },
};
/* Valid commands. */
const struct changer_command commands[] = {
{ "move", do_move },
{ "exchange", do_exchange },
{ "position", do_position },
{ "params", do_params },
{ "getpicker", do_getpicker },
{ "setpicker", do_setpicker },
{ "status", do_status },
{ NULL, 0 },
};
/* Valid special words. */
const struct special_word specials[] = {
{ "inv", SW_INVERT },
{ "inv1", SW_INVERT1 },
{ "inv2", SW_INVERT2 },
{ NULL, 0 },
};
static int changer_fd;
static char *changer_name;
int
main(argc, argv)
int argc;
char **argv;
{
int ch, i;
while ((ch = getopt(argc, argv, "f:")) != -1) {
switch (ch) {
case 'f':
changer_name = optarg;
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc == 0)
usage();
/* Get the default changer if not already specified. */
if (changer_name == NULL)
if ((changer_name = getenv(CHANGER_ENV_VAR)) == NULL)
changer_name = _PATH_CH;
/* Open the changer device. */
if ((changer_fd = open(changer_name, O_RDWR, 0600)) == -1)
err(1, "%s: open", changer_name);
/* Register cleanup function. */
if (atexit(cleanup))
err(1, "can't register cleanup function");
/* Find the specified command. */
for (i = 0; commands[i].cc_name != NULL; ++i)
if (strcmp(*argv, commands[i].cc_name) == 0)
break;
if (commands[i].cc_name == NULL)
errx(1, "unknown command: %s", *argv);
/* Skip over the command name and call handler. */
++argv; --argc;
exit ((*commands[i].cc_handler)(commands[i].cc_name, argc, argv));
}
static int
do_move(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct changer_move cmd;
int val;
/*
* On a move command, we expect the following:
*
* <from ET> <from EU> <to ET> <to EU> [inv]
*
* where ET == element type and EU == element unit.
*/
if (argc < 4) {
warnx("%s: too few arguments", cname);
goto usage;
} else if (argc > 5) {
warnx("%s: too many arguments", cname);
goto usage;
}
bzero(&cmd, sizeof(cmd));
/* <from ET> */
cmd.cm_fromtype = parse_element_type(*argv);
++argv; --argc;
/* <from EU> */
cmd.cm_fromunit = parse_element_unit(*argv);
++argv; --argc;
/* <to ET> */
cmd.cm_totype = parse_element_type(*argv);
++argv; --argc;
/* <to EU> */
cmd.cm_tounit = parse_element_unit(*argv);
++argv; --argc;
/* Deal with optional command modifier. */
if (argc) {
val = parse_special(*argv);
switch (val) {
case SW_INVERT:
cmd.cm_flags |= CM_INVERT;
break;
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
/* NOTREACHED */
}
}
/* Send command to changer. */
if (ioctl(changer_fd, CHIOMOVE, (char *)&cmd))
err(1, "%s: CHIOMOVE", changer_name);
return (0);
usage:
fprintf(stderr, "usage: chio %s "
"<from ET> <from EU> <to ET> <to EU> [inv]\n", cname);
return (1);
}
static int
do_exchange(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct changer_exchange cmd;
int val;
/*
* On an exchange command, we expect the following:
*
* <src ET> <src EU> <dst1 ET> <dst1 EU> [<dst2 ET> <dst2 EU>] [inv1] [inv2]
*
* where ET == element type and EU == element unit.
*/
if (argc < 4) {
warnx("%s: too few arguments", cname);
goto usage;
} else if (argc > 8) {
warnx("%s: too many arguments", cname);
goto usage;
}
bzero(&cmd, sizeof(cmd));
/* <src ET> */
cmd.ce_srctype = parse_element_type(*argv);
++argv; --argc;
/* <src EU> */
cmd.ce_srcunit = parse_element_unit(*argv);
++argv; --argc;
/* <dst1 ET> */
cmd.ce_fdsttype = parse_element_type(*argv);
++argv; --argc;
/* <dst1 EU> */
cmd.ce_fdstunit = parse_element_unit(*argv);
++argv; --argc;
/*
* If the next token is a special word or there are no more
* arguments, then this is a case of simple exchange.
* dst2 == src.
*/
if ((argc == 0) || is_special(*argv)) {
cmd.ce_sdsttype = cmd.ce_srctype;
cmd.ce_sdstunit = cmd.ce_srcunit;
goto do_special;
}
/* <dst2 ET> */
cmd.ce_sdsttype = parse_element_type(*argv);
++argv; --argc;
/* <dst2 EU> */
cmd.ce_sdstunit = parse_element_unit(*argv);
++argv; --argc;
do_special:
/* Deal with optional command modifiers. */
while (argc) {
val = parse_special(*argv);
++argv; --argc;
switch (val) {
case SW_INVERT1:
cmd.ce_flags |= CE_INVERT1;
break;
case SW_INVERT2:
cmd.ce_flags |= CE_INVERT2;
break;
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
/* NOTREACHED */
}
}
/* Send command to changer. */
if (ioctl(changer_fd, CHIOEXCHANGE, (char *)&cmd))
err(1, "%s: CHIOEXCHANGE", changer_name);
return (0);
usage:
fprintf(stderr,
"usage: chio %s <src ET> <src EU> <dst1 ET> <dst1 EU>\n"
" [<dst2 ET> <dst2 EU>] [inv1] [inv2]\n", cname);
return (1);
}
static int
do_position(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct changer_position cmd;
int val;
/*
* On a position command, we expect the following:
*
* <to ET> <to EU> [inv]
*
* where ET == element type and EU == element unit.
*/
if (argc < 2) {
warnx("%s: too few arguments", cname);
goto usage;
} else if (argc > 3) {
warnx("%s: too many arguments", cname);
goto usage;
}
bzero(&cmd, sizeof(cmd));
/* <to ET> */
cmd.cp_type = parse_element_type(*argv);
++argv; --argc;
/* <to EU> */
cmd.cp_unit = parse_element_unit(*argv);
++argv; --argc;
/* Deal with optional command modifier. */
if (argc) {
val = parse_special(*argv);
switch (val) {
case SW_INVERT:
cmd.cp_flags |= CP_INVERT;
break;
default:
errx(1, "%s: inappropriate modifier `%s'",
cname, *argv);
/* NOTREACHED */
}
}
/* Send command to changer. */
if (ioctl(changer_fd, CHIOPOSITION, (char *)&cmd))
err(1, "%s: CHIOPOSITION", changer_name);
return (0);
usage:
fprintf(stderr, "usage: chio %s <to ET> <to EU> [inv]\n", cname);
return (1);
}
static int
do_params(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct changer_params data;
/* No arguments to this command. */
if (argc) {
warnx("%s: no arguments expected", cname);
goto usage;
}
/* Get params from changer and display them. */
bzero(&data, sizeof(data));
if (ioctl(changer_fd, CHIOGPARAMS, (char *)&data))
err(1, "%s: CHIOGPARAMS", changer_name);
printf("%s: %d slot%s, %d drive%s, %d picker%s",
changer_name,
data.cp_nslots, (data.cp_nslots > 1) ? "s" : "",
data.cp_ndrives, (data.cp_ndrives > 1) ? "s" : "",
data.cp_npickers, (data.cp_npickers > 1) ? "s" : "");
if (data.cp_nportals)
printf(", %d portal%s", data.cp_nportals,
(data.cp_nportals > 1) ? "s" : "");
printf("\n%s: current picker: %d\n", changer_name, data.cp_curpicker);
return (0);
usage:
fprintf(stderr, "usage: chio %s\n", cname);
return (1);
}
static int
do_getpicker(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
int picker;
/* No arguments to this command. */
if (argc) {
warnx("%s: no arguments expected", cname);
goto usage;
}
/* Get current picker from changer and display it. */
if (ioctl(changer_fd, CHIOGPICKER, (char *)&picker))
err(1, "%s: CHIOGPICKER", changer_name);
printf("%s: current picker: %d\n", changer_name, picker);
return (0);
usage:
fprintf(stderr, "usage: chio %s\n", cname);
return (1);
}
static int
do_setpicker(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
int picker;
if (argc < 1) {
warnx("%s: too few arguments", cname);
goto usage;
} else if (argc > 1) {
warnx("%s: too many arguments", cname);
goto usage;
}
picker = parse_element_unit(*argv);
/* Set the changer picker. */
if (ioctl(changer_fd, CHIOSPICKER, (char *)&picker))
err(1, "%s: CHIOSPICKER", changer_name);
return (0);
usage:
fprintf(stderr, "usage: chio %s <picker>\n", cname);
return (1);
}
static int
do_status(cname, argc, argv)
char *cname;
int argc;
char **argv;
{
struct changer_element_status cmd;
struct changer_params data;
u_int8_t *statusp;
int i, count, chet, schet, echet;
char *description;
count = 0;
description = NULL;
/*
* On a status command, we expect the following:
*
* [<ET>]
*
* where ET == element type.
*
* If we get no arguments, we get the status of all
* known element types.
*/
if (argc > 1) {
warnx("%s: too many arguments", cname);
goto usage;
}
/*
* Get params from changer. Specifically, we need the element
* counts.
*/
bzero(&data, sizeof(data));
if (ioctl(changer_fd, CHIOGPARAMS, (char *)&data))
err(1, "%s: CHIOGPARAMS", changer_name);
if (argc)
schet = echet = parse_element_type(*argv);
else {
schet = CHET_MT;
echet = CHET_DT;
}
for (chet = schet; chet <= echet; ++chet) {
switch (chet) {
case CHET_MT:
count = data.cp_npickers;
description = "picker";
break;
case CHET_ST:
count = data.cp_nslots;
description = "slot";
break;
case CHET_IE:
count = data.cp_nportals;
description = "portal";
break;
case CHET_DT:
count = data.cp_ndrives;
description = "drive";
break;
}
if (count == 0) {
if (argc == 0)
continue;
else {
printf("%s: no %s elements\n",
changer_name, description);
return (0);
}
}
/* Allocate storage for the status bytes. */
if ((statusp = (u_int8_t *)malloc(count)) == NULL)
errx(1, "can't allocate status storage");
bzero(statusp, count);
bzero(&cmd, sizeof(cmd));
cmd.ces_type = chet;
cmd.ces_data = statusp;
if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cmd)) {
free(statusp);
err(1, "%s: CHIOGSTATUS", changer_name);
}
/* Dump the status for each element of this type. */
for (i = 0; i < count; ++i) {
printf("%s %d: %s\n", description, i,
bits_to_string(statusp[i], CESTATUS_BITS));
}
free(statusp);
}
return (0);
usage:
fprintf(stderr, "usage: chio %s [<element type>]\n", cname);
return (1);
}
static int
parse_element_type(cp)
char *cp;
{
int i;
for (i = 0; elements[i].et_name != NULL; ++i)
if (strcmp(elements[i].et_name, cp) == 0)
return (elements[i].et_type);
errx(1, "invalid element type `%s'", cp);
}
static int
parse_element_unit(cp)
char *cp;
{
int i;
char *p;
i = (int)strtol(cp, &p, 10);
if ((i < 0) || (*p != '\0'))
errx(1, "invalid unit number `%s'", cp);
return (i);
}
static int
parse_special(cp)
char *cp;
{
int val;
val = is_special(cp);
if (val)
return (val);
errx(1, "invalid modifier `%s'", cp);
}
static int
is_special(cp)
char *cp;
{
int i;
for (i = 0; specials[i].sw_name != NULL; ++i)
if (strcmp(specials[i].sw_name, cp) == 0)
return (specials[i].sw_value);
return (0);
}
static char *
bits_to_string(v, cp)
int v;
const char *cp;
{
const char *np;
char f, sep, *bp;
static char buf[128];
bp = buf;
bzero(buf, sizeof(buf));
for (sep = '<'; (f = *cp++) != 0; cp = np) {
for (np = cp; *np >= ' ';)
np++;
if ((v & (1 << (f - 1))) == 0)
continue;
bp += snprintf(bp, sizeof(buf) - (bp - &buf[0]),
"%c%.*s", sep, np - cp, cp);
sep = ',';
}
if (sep != '<')
*bp = '>';
return (buf);
}
static void
cleanup()
{
/* Simple enough... */
(void)close(changer_fd);
}
static void
usage()
{
int i;
fprintf(stderr, "usage: chio [-f changer] command [args ...]\n");
fprintf(stderr, "commands:");
for (i = 0; commands[i].cc_name; i++)
fprintf(stderr, " %s", commands[i].cc_name);
fprintf(stderr, "\n");
exit(1);
}
-57
View File
@@ -1,57 +0,0 @@
/* $Id: $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgements:
* This product includes software developed by Jason R. Thorpe
* for And Communications, http://www.and.com/
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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.
*/
struct element_type {
char *et_name; /* name; i.e. "picker, "slot", etc. */
int et_type; /* type number */
};
struct changer_command {
char *cc_name; /* command name */
/* command handler */
int (*cc_handler) __P((char *, int, char **));
};
struct special_word {
char *sw_name; /* special word */
int sw_value; /* token value */
};
/* sw_value */
#define SW_INVERT 1 /* set "invert media" flag */
#define SW_INVERT1 2 /* set "invert media 1" flag */
#define SW_INVERT2 3 /* set "invert media 2" flag */
/* Environment variable to check for default changer. */
#define CHANGER_ENV_VAR "CHANGER"
-35
View File
@@ -1,35 +0,0 @@
/* $Id: $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <[email protected]>
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgements:
* This product includes software developed by Jason R. Thorpe
* for And Communications, http://www.and.com/
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* 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.
*/
#define _PATH_CH "/dev/ch0"
+22 -59
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
.\" $Id: chmod.1,v 1.4.2.3 1998/05/22 10:41:45 jkoshy Exp $
.\" $Id$
.\"
.Dd March 31, 1994
.Dt CHMOD 1
@@ -51,7 +51,7 @@
.Ar file ...
.Sh DESCRIPTION
The
.Nm
.Nm chmod
utility modifies the file mode bits of the listed files
as specified by the
.Ar mode
@@ -82,7 +82,7 @@ Symbolic links do not have modes, so unless the
or
.Fl L
option is set,
.Nm
.Nm chmod
on a symbolic link always succeeds and has no effect.
The
.Fl H ,
@@ -99,63 +99,35 @@ Only the owner of a file or the super-user is permitted to change
the mode of a file.
.Pp
The
.Nm
.Nm chmod
utility exits 0 on success, and >0 if an error occurs.
.Sh MODES
Modes may be absolute or symbolic.
An absolute mode is an octal number constructed from the sum of
one or more of the following values:
An absolute mode is an octal number constructed by
.Ar or-ing
the following values:
.Pp
.Bl -tag -width 6n -compact -offset indent
.It Li 4000
(the set-user-ID-on-execution bit) Executable files with this bit set
will run with effective uid set to the uid of the file owner.
Directories with the set-user-id bit set will force all files and
sub-directories created in them to be owned by the directory owner
and not by the uid of the creating process, if the underlying file
system supports this feature: see
.Xr chmod 2
and the
.Ar suiddir
option to
.Xr mount 1 .
set-user-ID-on-execution
.It Li 2000
(the set-group-ID-on-execution bit) Executable files with this bit set
will run with effective gid set to the gid of the file owner.
set-group-ID-on-execution
.It Li 1000
(the sticky bit)
When set on a directory, unprivileged users can delete and rename
only those files in the directory that are owned by them, regardless of
the permissions on the directory. Under FreeBSD, the sticky bit is
ignored for executable files and may only be set for directories (see
.Xr sticky 8 ).
sticky bit, see chmod(2)
.It Li 0400
Allow read by owner.
read by owner
.It Li 0200
Allow write by owner.
write by owner
.It Li 0100
For files, allow execution by owner. For directories, allow the owner to
search in the directory.
.It Li 0040
Allow read by group members.
.It Li 0020
Allow write by group members.
.It Li 0010
For files, allow execution by group members. For directories, allow
group members to search in the directory.
.It Li 0004
Allow read by others.
.It Li 0002
Allow write by others.
.It Li 0001
For files, allow execution by others. For directories allow others to
search in the directory.
execute (or search for directories) by owner
.It Li 0070
read, write, execute/search by group
.It Li 0007
read, write, execute/search by others
.El
.Pp
For example, the absolute mode that permits read, write and execute by
the owner, read and execute by group members, read and execute by
others, and no set-uid or set-gid behaviour is 755
(400+200+100+040+010+004+001).
The read, write, and execute/search values for group and others
are encoded as described for owner.
.Pp
The symbolic mode is described by the following grammar:
.Bd -literal -offset indent
@@ -302,22 +274,18 @@ There's no
.Ar perm
option for the naughty bits.
.Sh SEE ALSO
.Xr chflags 1 ,
.Xr install 1 ,
.Xr mount 1 ,
.Xr chmod 2 ,
.Xr stat 2 ,
.Xr umask 2 ,
.Xr fts 3 ,
.Xr setmode 3 ,
.Xr symlink 7 ,
.Xr chown 8 ,
.Xr sticky 8
.Xr chown 8
.Sh STANDARDS
The
.Nm
utility is expected to be
.St -p1003.2
.Nm chmod
utility is expected to be POSIX 1003.2
compatible with the exception of the
.Ar perm
symbols
@@ -325,8 +293,3 @@ symbols
and
.Dq X
which are not included in that standard.
.Sh HISTORY
A
.Nm
command appeared in
.At v1 .
+9 -11
View File
@@ -30,17 +30,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: chmod.c,v 1.5.2.1 1997/08/24 10:30:25 jkh Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1989, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
static char sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
#endif /* not lint */
#include <sys/types.h>
@@ -49,7 +49,6 @@ static char const sccsid[] = "@(#)chmod.c 8.8 (Berkeley) 4/1/94";
#include <err.h>
#include <errno.h>
#include <fts.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -70,10 +69,8 @@ main(argc, argv)
int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
char *ep, *mode;
set = NULL;
omode = 0;
Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != -1)
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
@@ -161,10 +158,11 @@ done: argv += optind;
err(1, NULL);
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
switch (p->fts_info) {
case FTS_D: /* Change it at FTS_DP. */
if (!Rflag)
fts_set(ftsp, p, FTS_SKIP);
continue;
case FTS_D:
if (Rflag) /* Change it at FTS_DP. */
continue;
fts_set(ftsp, p, FTS_SKIP);
break;
case FTS_DNR: /* Warn, chmod, continue. */
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
+21 -37
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\" $Id: cp.1,v 1.6.2.2 1998/07/15 02:01:05 jkh Exp $
.\" $Id$
.\"
.Dd April 18, 1994
.Dt CP 1
@@ -47,20 +47,18 @@
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i
.Op Fl p
.Op Fl fip
.Ar source_file target_file
.Nm cp
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Oc
.Op Fl f | i
.Op Fl p
.Op Fl fip
.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
.Nm
.Nm cp
utility copies the contents of the
.Ar source_file
to the
@@ -72,7 +70,7 @@ is copied to the destination
.Ar target_directory .
The names of the files themselves are not changed.
If
.Nm
.Nm cp
detects an attempt to copy a file to itself, the copy will fail.
.Pp
The following options are available:
@@ -94,11 +92,11 @@ option is specified, no symbolic links are followed.
If
.Ar source_file
designates a directory,
.Nm
.Nm cp
copies the directory and the entire subtree connected at that point.
This option also causes symbolic links to be copied, rather than
indirected through, and for
.Nm
.Nm cp
to create special files rather than copying them as normal files.
Created directories have the same mode as the corresponding source
directory, unmodified by the process' umask.
@@ -107,28 +105,21 @@ For each existing destination pathname, remove it and
create a new file, without prompting for confirmation
regardless of its permissions.
(The
.Fl f
option overrides any previous
.Fl i
options.)
option is ignored if the
.Fl f
option is specified.)
.It Fl i
Cause
.Nm
Causes
.Nm cp
to write a prompt to the standard error output before copying a file
that would overwrite an existing file.
If the response from the standard input begins with the character
.Sq Li y
or
.Sq Li Y ,
.Sq Li y ,
the file copy is attempted.
(The
.Fl i
option overrides any previous
.Fl f
options.)
.It Fl p
Cause
.Nm
Causes
.Nm cp
to preserve in the copy as many of the modification time, access time,
file flags, file mode, user ID, and group ID as allowed by permissions.
.Pp
@@ -143,15 +134,13 @@ be preserved, the set group ID bit is not preserved
in the copy's permissions.
If the source file has both its set user ID and set group ID bits on,
and either the user ID or group ID cannot be preserved, neither
the set user ID nor set group ID bits are preserved in the copy's
the set user ID or set group ID bits are preserved in the copy's
permissions.
.El
.Pp
For each destination file that already exists, its contents are
overwritten if permissions allow. Its mode, user ID, and group
ID are unchanged unless the
.Fl p
option was specified.
overwritten if permissions allow, but its mode, user ID, and group
ID are unchanged.
.Pp
In the second synopsis form,
.Ar target_directory
@@ -202,7 +191,7 @@ command's actions are determined by the last one specified.
exits 0 on success, >0 if an error occurred.
.Sh COMPATIBILITY
Historic versions of the
.Nm
.Nm cp
utility had a
.Fl r
option.
@@ -215,14 +204,9 @@ or fifo's.
.Xr umask 2 ,
.Xr fts 3 ,
.Xr symlink 7
.Sh STANDARDS
.Sh HISTORY
The
.Nm
.Nm cp
command is expected to be
.St -p1003.2
compatible.
.Sh HISTORY
A
.Nm
command appeared in
.At v1 .
+45 -53
View File
@@ -33,26 +33,26 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cp.c,v 1.10.2.1 1997/08/24 10:34:45 jkh Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1988, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
#endif /* not lint */
/*
* Cp copies source files to target files.
*
*
* The global PATH_T structure "to" always contains the path to the
* current target file. Since fts(3) does not change directories,
* this path can be either absolute or dot-relative.
*
* this path can be either absolute or dot-realative.
*
* The basic algorithm is to initialize "to" and use fts(3) to traverse
* the file hierarchy rooted in the argument list. A trivial case is the
* case of 'cp file1 file2'. The more interesting case is the case of
@@ -79,14 +79,14 @@ static char const sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
#include "extern.h"
#define STRIP_TRAILING_SLASH(p) { \
while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/') \
while ((p).p_end > (p).p_path && (p).p_end[-1] == '/') \
*--(p).p_end = 0; \
}
PATH_T to = { to.p_path, "" };
uid_t myuid;
int Rflag, iflag, pflag, rflag, fflag;
int Rflag, iflag, pflag, rflag;
int myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
@@ -104,8 +104,8 @@ main(argc, argv)
int Hflag, Lflag, Pflag, ch, fts_options, r;
char *target;
Hflag = Lflag = Pflag = 0;
while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
Hflag = Lflag = Pflag = Rflag = 0;
while ((ch = getopt(argc, argv, "HLPRfipr")) != EOF)
switch (ch) {
case 'H':
Hflag = 1;
@@ -123,12 +123,10 @@ main(argc, argv)
Rflag = 1;
break;
case 'f':
fflag = 1;
iflag = 0;
break;
case 'i':
iflag = 1;
fflag = 0;
iflag = isatty(fileno(stdin));
break;
case 'p':
pflag = 1;
@@ -136,6 +134,7 @@ main(argc, argv)
case 'r':
rflag = 1;
break;
case '?':
default:
usage();
break;
@@ -189,8 +188,8 @@ main(argc, argv)
to.target_end = to.p_end;
/* Set end of argument list for fts(3). */
argv[argc] = NULL;
argv[argc] = NULL;
/*
* Cp has two distinct cases:
*
@@ -211,7 +210,7 @@ main(argc, argv)
if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
/*
* Case (1). Target is not a directory.
*/
*/
if (argc > 1) {
usage();
exit(1);
@@ -228,7 +227,7 @@ main(argc, argv)
stat(*argv, &tmp_stat);
else
lstat(*argv, &tmp_stat);
if (S_ISDIR(tmp_stat.st_mode) && (Rflag || rflag))
type = DIR_TO_DNE;
else
@@ -253,15 +252,14 @@ copy(argv, type, fts_options)
struct stat to_stat;
FTS *ftsp;
FTSENT *curr;
int base = 0, dne, nlen, rval;
char *p, *target_mid;
int base, dne, nlen, rval;
char *p;
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
err(1, NULL);
for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR:
case FTS_ERR:
warnx("%s: %s",
curr->fts_path, strerror(curr->fts_errno));
@@ -276,10 +274,18 @@ copy(argv, type, fts_options)
}
/*
* If we are in case (2) or (3) above, we need to append the
* source name to the target name.
* If we are in case (2) or (3) above, we need to append the
* source name to the target name.
*/
if (type != FILE_TO_FILE) {
if ((curr->fts_namelen +
to.target_end - to.p_path + 1) > MAXPATHLEN) {
warnx("%s/%s: name too long (not copied)",
to.p_path, curr->fts_name);
rval = 1;
continue;
}
/*
* Need to remember the roots of traversals to create
* correct pathnames. If there's a directory being
@@ -302,29 +308,24 @@ copy(argv, type, fts_options)
if (curr->fts_level == FTS_ROOTLEVEL)
if (type != DIR_TO_DNE) {
p = strrchr(curr->fts_path, '/');
base = (p == NULL) ? 0 :
base = (p == NULL) ? 0 :
(int)(p - curr->fts_path + 1);
if (!strcmp(&curr->fts_path[base],
if (!strcmp(&curr->fts_path[base],
".."))
base += 1;
} else
base = curr->fts_pathlen;
if (to.target_end[-1] != '/') {
*to.target_end = '/';
*(to.target_end + 1) = 0;
}
p = &curr->fts_path[base];
nlen = curr->fts_pathlen - base;
target_mid = to.target_end;
if (*p != '/' && target_mid[-1] != '/')
*target_mid++ = '/';
*target_mid = 0;
if (target_mid - to.p_path + nlen > MAXPATHLEN) {
warnx("%s%s: name too long (not copied)",
to.p_path, p);
rval = 1;
continue;
}
(void)strncat(target_mid, p, nlen);
to.p_end = target_mid + nlen;
(void)strncat(to.target_end + 1, p, nlen);
to.p_end = to.target_end + nlen + 1;
*to.p_end = 0;
STRIP_TRAILING_SLASH(to);
}
@@ -342,13 +343,6 @@ copy(argv, type, fts_options)
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
}
if (!S_ISDIR(curr->fts_statp->st_mode) &&
S_ISDIR(to_stat.st_mode)) {
warnx("cannot overwrite directory %s with non-directory %s",
to.p_path, curr->fts_path);
rval = 1;
continue;
}
dne = 0;
}
@@ -374,23 +368,23 @@ copy(argv, type, fts_options)
* umask blocks owner writes, we fail..
*/
if (dne) {
if (mkdir(to.p_path,
if (mkdir(to.p_path,
curr->fts_statp->st_mode | S_IRWXU) < 0)
err(1, "%s", to.p_path);
} else if (!S_ISDIR(to_stat.st_mode)) {
errno = ENOTDIR;
err(1, "%s", to.p_path);
err(1, "%s: %s", to.p_path);
}
/*
* If not -p and directory didn't exist, set it to be
* the same as the from directory, umodified by the
* umask; arguably wrong, but it's been that way
* the same as the from directory, umodified by the
* umask; arguably wrong, but it's been that way
* forever.
*/
if (pflag && setfile(curr->fts_statp, 0))
rval = 1;
else if (dne)
(void)chmod(to.p_path,
(void)chmod(to.p_path,
curr->fts_statp->st_mode);
break;
case S_IFBLK:
@@ -398,19 +392,17 @@ copy(argv, type, fts_options)
if (Rflag) {
if (copy_special(curr->fts_statp, !dne))
rval = 1;
} else {
} else
if (copy_file(curr, dne))
rval = 1;
}
break;
case S_IFIFO:
if (Rflag) {
if (Rflag)
if (copy_fifo(curr->fts_statp, !dne))
rval = 1;
} else {
else
if (copy_file(curr, dne))
rval = 1;
}
break;
default:
if (copy_file(curr, dne))
+2 -2
View File
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/1/94
* $Id: extern.h,v 1.3 1996/02/18 18:48:26 wosch Exp $
* $Id$
*/
typedef struct {
@@ -42,7 +42,7 @@ typedef struct {
extern PATH_T to;
extern uid_t myuid;
extern int iflag, pflag, fflag, myumask;
extern int iflag, pflag, myumask;
#include <sys/cdefs.h>
+36 -74
View File
@@ -30,11 +30,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: utils.c,v 1.9.2.2 1998/02/15 10:53:17 jkh Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
#endif /* not lint */
#include <sys/param.h>
@@ -60,12 +60,11 @@ copy_file(entp, dne)
{
static char buf[MAXBSIZE];
struct stat to_stat, *fs;
int ch, checkch, from_fd, rcount, rval, to_fd, wcount, wresid;
char *bufp;
int ch, checkch, from_fd, rcount, rval, to_fd, wcount;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
char *p;
#endif
if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
warn("%s", entp->fts_path);
return (1);
@@ -82,29 +81,17 @@ copy_file(entp, dne)
* modified by the umask.)
*/
if (!dne) {
#define YESNO "(y/n [n]) "
if (iflag) {
(void)fprintf(stderr, "overwrite %s? %s",
to.p_path, YESNO);
(void)fprintf(stderr, "overwrite %s? ", to.p_path);
checkch = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
if (checkch != 'y' && checkch != 'Y') {
if (checkch != 'y') {
(void)close(from_fd);
(void)fprintf(stderr, "not overwritten\n");
return (0);
}
}
if (fflag) {
/* remove existing destination file name,
* create a new file */
(void)unlink(to.p_path);
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
} else
/* overwrite existing destination file name */
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
} else
to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
fs->st_mode & ~(S_ISUID | S_ISGID));
@@ -125,17 +112,11 @@ copy_file(entp, dne)
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
if (fs->st_size <= 8 * 1048576) {
if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
MAP_SHARED, from_fd, (off_t)0)) == MAP_FAILED) {
0, from_fd, (off_t)0)) == (char *)-1) {
warn("%s", entp->fts_path);
rval = 1;
} else {
for (bufp = p, wresid = fs->st_size; ;
bufp += wcount, wresid -= wcount) {
wcount = write(to_fd, bufp, wresid);
if (wcount >= wresid || wcount <= 0)
break;
}
if (wcount != wresid) {
if (write(to_fd, p, fs->st_size) != fs->st_size) {
warn("%s", to.p_path);
rval = 1;
}
@@ -149,13 +130,8 @@ copy_file(entp, dne)
#endif
{
while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
for (bufp = buf, wresid = rcount; ;
bufp += wcount, wresid -= wcount) {
wcount = write(to_fd, bufp, wresid);
if (wcount >= wresid || wcount <= 0)
break;
}
if (wcount != wresid) {
wcount = write(to_fd, buf, rcount);
if (rcount != wcount || wcount == -1) {
warn("%s", to.p_path);
rval = 1;
break;
@@ -167,12 +143,13 @@ copy_file(entp, dne)
}
}
/*
* Don't remove the target even after an error. The target might
* not be a regular file, or its attributes might be important,
* or its contents might be irreplacable. It would only be safe
* to remove it if we created it and its length is 0.
*/
/* If the copy went bad, lose the file. */
if (rval == 1) {
(void)unlink(to.p_path);
(void)close(from_fd);
(void)close(to_fd);
return (1);
}
if (pflag && setfile(fs, to_fd))
rval = 1;
@@ -207,7 +184,7 @@ copy_link(p, exists)
int len;
char link[MAXPATHLEN];
if ((len = readlink(p->fts_path, link, sizeof(link) - 1)) == -1) {
if ((len = readlink(p->fts_path, link, sizeof(link))) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
}
@@ -262,13 +239,10 @@ setfile(fs, fd)
int fd;
{
static struct timeval tv[2];
struct stat ts;
int rval;
int gotstat;
rval = 0;
fs->st_mode &= S_ISUID | S_ISGID | S_ISVTX |
S_IRWXU | S_IRWXG | S_IRWXO;
fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
@@ -276,42 +250,30 @@ setfile(fs, fd)
warn("utimes: %s", to.p_path);
rval = 1;
}
if (fd ? fstat(fd, &ts) : stat(to.p_path, &ts))
gotstat = 0;
else {
gotstat = 1;
ts.st_mode &= S_ISUID | S_ISGID | S_ISVTX |
S_IRWXU | S_IRWXG | S_IRWXO;
}
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (!gotstat || fs->st_uid != ts.st_uid || fs->st_gid != ts.st_gid)
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISUID | S_ISGID);
}
if (!gotstat || fs->st_mode != ts.st_mode)
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISUID | S_ISGID);
}
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
warn("chown: %s", to.p_path);
rval = 1;
}
if (!gotstat || fs->st_flags != ts.st_flags)
if (fd ?
fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags)) {
warn("chflags: %s", to.p_path);
rval = 1;
}
if (fd ?
fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags)) {
warn("chflags: %s", to.p_path);
rval = 1;
}
return (rval);
}
@@ -319,7 +281,7 @@ void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target",
" cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory");
"usage: cp [-R [-H | -L | -P] [-fip] src target",
" cp [-R [-H | -L | -P] [-fip] src1 ... srcN directory");
exit(1);
}
+15 -15
View File
@@ -1,5 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.5 1994/09/24 02:53:44 davidg Exp $
# $Id$
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
@@ -11,7 +11,7 @@ DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
CFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
sem.c set.c str.c time.c const.h errnum.h
sem.c set.c str.c time.c const.h err.h
.PATH: ${.CURDIR}/../../usr.bin/printf
MAN1= csh.1
@@ -19,23 +19,23 @@ MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
csh.1 stop.1 csh.1 source.1
CLEANFILES+=const.h errnum.h
CLEANFILES+=err.h const.h
const.h: errnum.h
const.h: err.h
errnum.h: err.c
@rm -f ${.TARGET}
@echo '/* Do not edit this file, make creates it. */' > ${.TARGET}
@echo '#ifndef _h_sh_error' >> ${.TARGET}
@echo '#define _h_sh_error' >> ${.TARGET}
egrep 'ERR_' ${.ALLSRC} | egrep '^#define' >> ${.TARGET}
@echo '#endif /* _h_sh_error */' >> ${.TARGET}
err.h: err.c
@rm -f $@
@echo '/* Do not edit this file, make creates it. */' > $@
@echo '#ifndef _h_sh_err' >> $@
@echo '#define _h_sh_err' >> $@
egrep 'ERR_' ${.CURDIR}/$*.c | egrep '^#define' >> $@
@echo '#endif /* _h_sh_err */' >> $@
const.h: const.c
@rm -f ${.TARGET}
@echo '/* Do not edit this file, make creates it. */' > ${.TARGET}
${CC} -E ${CFLAGS} ${.ALLSRC} | egrep 'Char STR' | \
@rm -f $@
@echo '/* Do not edit this file, make creates it. */' > $@
${CC} -E ${CFLAGS} ${.CURDIR}/$*.c | egrep 'Char STR' | \
sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
sort >> ${.TARGET}
sort >> $@
.include <bsd.prog.mk>
+2 -2
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.1 8.1 (Berkeley) 6/8/93
.\" $Id: csh.1,v 1.2 1994/09/24 02:54:23 davidg Exp $
.\" $Id$
.\"
.EH 'USD:4-%''An Introduction to the C shell'
.OH 'An Introduction to the C shell''USD:4-%'
@@ -617,7 +617,7 @@ order than we listed them above.
The
.I echo
command receives four words as arguments, even though we only typed
one word as an argument directly.
one word as as argument directly.
The four words were generated by
.I "filename expansion"
of the one input word.
+2 -2
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.2 8.1 (Berkeley) 6/8/93
.\" $Id: csh.2,v 1.2 1994/09/24 02:54:24 davidg Exp $
.\" $Id$
.\"
.nr H1 1
.NH
@@ -1300,7 +1300,7 @@ One useful feature which is discussed later is the
built-in command which can be used to run the same command
sequence with a number of different arguments.
.PP
If you intend to use \s-2UNIX\s0 a lot you should look through
If you intend to use \s-2UNIX\s0 a lot you you should look through
the rest of this document and the csh manual pages (section1) to become familiar
with the other facilities which are available to you.
.bp
+2 -3
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: alloc.c,v 1.3 1995/03/19 13:28:10 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -122,6 +122,5 @@ showall(v, t)
{
memtop = (char *) sbrk(0);
(void) fprintf(cshout, "Allocated memory from 0x%lx to 0x%lx (%ld).\n",
(unsigned long) membot, (unsigned long) memtop,
(unsigned long) (memtop - membot));
(unsigned long) membot, (unsigned long) memtop, memtop - membot);
}
+6 -8
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: const.c,v 1.3 1995/05/30 00:06:29 rgrimes Exp $
* $Id$
*/
#ifndef lint
@@ -47,9 +47,7 @@ Char STR0[] = { '0', '\0' };
Char STR1[] = { '1', '\0' };
Char STRHOME[] = { 'H', 'O', 'M', 'E', '\0' };
Char STRLANG[] = { 'L', 'A', 'N', 'G', '\0' };
Char STRLC_ALL[] = { 'L', 'C', '_', 'A', 'L', 'L', '\0' };
Char STRLC_CTYPE[] = { 'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E', '\0' };
Char STRLC_COLLATE[] = { 'L', 'C', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E', '\0' };
Char STRLC_CTYPE[] = { 'L', 'C', '_', 'C', 'T', 'Y', 'P', 'E' ,'\0' };
Char STRLOGNAME[] = { 'L', 'O', 'G', 'N', 'A', 'M', 'E', '\0' };
Char STRLbrace[] = { '{', '\0' };
Char STRLparen[] = { '(', '\0' };
@@ -74,7 +72,7 @@ Char STRcent2[] = { '%', '%', '\0' };
Char STRcenthash[] = { '%', '#', '\0' };
Char STRcentplus[] = { '%', '+', '\0' };
Char STRcentminus[] = { '%', '-', '\0' };
Char STRchase_symlinks[] = { 'c', 'h', 'a', 's', 'e', '_', 's', 'y', 'm', 'l',
Char STRchase_symlinks[] = { 'c', 'h', 'a', 's', 'e', '_', 's', 'y', 'm', 'l',
'i', 'n', 'k', 's', '\0' };
Char STRchild[] = { 'c', 'h', 'i', 'l', 'd', '\0' };
Char STRcolon[] = { ':', '\0' };
@@ -92,7 +90,7 @@ Char STRfignore[] = { 'f', 'i', 'g', 'n', 'o', 'r', 'e', '\0' };
Char STRfilec[] = { 'f', 'i', 'l', 'e', 'c', '\0' };
#endif /* FILEC */
Char STRhistchars[] = { 'h', 'i', 's', 't', 'c', 'h', 'a', 'r', 's', '\0' };
Char STRtildothist[] = { '~', '/', '.', 'h', 'i', 's', 't', 'o', 'r',
Char STRtildothist[] = { '~', '/', '.', 'h', 'i', 's', 't', 'o', 'r',
'y', '\0' };
Char STRhistfile[] = { 'h', 'i', 's', 't', 'f', 'i', 'l', 'e', '\0' };
Char STRhistory[] = { 'h', 'i', 's', 't', 'o', 'r', 'y', '\0' };
@@ -111,7 +109,7 @@ Char STRml[] = { '-', 'l', '\0' };
Char STRmn[] = { '-', 'n', '\0' };
Char STRmquestion[] = { '?' | QUOTE, ' ', '\0' };
Char STRnice[] = { 'n', 'i', 'c', 'e', '\0' };
Char STRnoambiguous[] = { 'n', 'o', 'a', 'm', 'b', 'i', 'g', 'u', 'o', 'u',
Char STRnoambiguous[] = { 'n', 'o', 'a', 'm', 'b', 'i', 'g', 'u', 'o', 'u',
's', '\0' };
Char STRnobeep[] = { 'n', 'o', 'b', 'e', 'e', 'p', '\0' };
Char STRnoclobber[] = { 'n', 'o', 'c', 'l', 'o', 'b', 'b', 'e', 'r', '\0' };
@@ -123,7 +121,7 @@ Char STRnotify[] = { 'n', 'o', 't', 'i', 'f', 'y', '\0' };
Char STRor[] = { '|', '\0' };
Char STRor2[] = { '|', '|', '\0' };
Char STRpath[] = { 'p', 'a', 't', 'h', '\0' };
Char STRprintexitvalue[] = { 'p', 'r', 'i', 'n', 't', 'e', 'x', 'i', 't', 'v',
Char STRprintexitvalue[] = { 'p', 'r', 'i', 'n', 't', 'e', 'x', 'i', 't', 'v',
'a', 'l', 'u', 'e', '\0' };
Char STRprompt[] = { 'p', 'r', 'o', 'm', 'p', 't', '\0' };
Char STRprompt2[] = { 'p', 'r', 'o', 'm', 'p', 't', '2', '\0' };
+80 -98
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)csh.1 8.2 (Berkeley) 1/21/94
.\" $Id: csh.1,v 1.5.2.2 1998/06/30 06:42:24 charnier Exp $
.\" $Id$
.\"
.Dd January 21, 1994
.Dt CSH 1
@@ -40,21 +40,21 @@
.Nd a shell (command interpreter) with C-like syntax
.Sh SYNOPSIS
.Nm csh
.Op Fl bcefimnstvVxX
.Op Fl bcefinstvVxX
.Op arg ...
.Nm csh
.Op Fl l
.Sh DESCRIPTION
The
.Nm
.Nm csh
is a command language interpreter
incorporating a history mechanism (see
.Sx History Substitutions ) ,
.Nm History Substitutions ) ,
job control facilities (see
.Sx Jobs ) ,
.Nm Jobs ) ,
interactive file name
and user name completion (see
.Sx File Name Completion ) ,
.Nm File Name Completion ) ,
and a C-like syntax. It is used both as an interactive
login shell and a shell script command processor.
.Ss Argument list processing
@@ -96,14 +96,6 @@ and outputs are terminals.
The shell is a login shell (only applicable if
.Fl l
is the only flag specified).
.It Fl m
The shell loads
.Pa .cshrc
even if it does not belong to the effective user.
.Xr Su 1
can pass
.Fl m
to the shell.
.It Fl n
Commands are parsed, but not executed.
This aids in syntactic checking of shell scripts.
@@ -116,16 +108,16 @@ A
may be used to escape the newline at the end of this
line and continue onto another line.
.It Fl v
Cause the
Causes the
.Ar verbose
variable to be set, with the effect
that command input is echoed after history substitution.
.It Fl x
Cause the
Causes the
.Ar echo
variable to be set, so that commands are echoed immediately before execution.
.It Fl V
Cause the
Causes the
.Ar verbose
variable to be set even before
.Pa .cshrc
@@ -157,7 +149,7 @@ Remaining arguments initialize the variable
.Ar argv .
.Pp
An instance of
.Nm
.Nm csh
begins by executing commands from the file
.Pa /etc/csh.cshrc
and,
@@ -256,7 +248,7 @@ showing that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process id was 1234.
.Pp
If you are running a job and wish to do something else you may hit the key
.Em ^Z
.Nm ^Z
(control-Z) which sends a STOP signal to the current job.
The shell will then normally show that the job has been `Stopped',
and print another prompt. You can then manipulate the state of this job,
@@ -271,11 +263,11 @@ the
command
.Ar fg .
A
.Em ^Z
.Nm ^Z
takes effect immediately and
is like an interrupt in that pending output and unread input are discarded
when it is typed. There is another special key
.Em ^Y
.Nm ^Y
that does not generate a STOP signal until a program attempts to
.Xr read 2
it.
@@ -353,7 +345,7 @@ the shell variable
.Ar filec
(see
.Ic set ) ,
.Nm
.Nm csh
will
interactively complete file names and user names from unique
prefixes, when they are input from the terminal followed by
@@ -370,7 +362,7 @@ and the input is
.Pp
.Dl % vi ch<escape>
.Pp
.Nm
.Nm csh
will complete the prefix ``ch''
to the only matching file name ``chaosnet'', changing the input
line to
@@ -381,7 +373,7 @@ However, given
.Pp
.Dl % vi D<escape>
.Pp
.Nm
.Nm csh
will only expand the input to
.Pp
.Dl % vi DSC.
@@ -391,7 +383,7 @@ incomplete, since there are two file names matching the prefix ``D''.
.Pp
If a partial file name is followed by the end-of-file character
(usually control-D), then, instead of completing the name,
.Nm
.Nm csh
will list all file names matching the prefix. For example,
the input
.Pp
@@ -455,7 +447,7 @@ in the previous command with little typing and a high degree of confidence.
History substitutions begin with the character `!' and may begin
.Ar anywhere
in the input stream (with the proviso that they
.Em "do not"
.Nm "do not"
nest.)
This `!' may be preceded by a `\e' to prevent its special meaning; for
convenience, an `!' is passed unchanged when it is followed by a blank,
@@ -631,7 +623,7 @@ Strings enclosed in `"' may be expanded as described below.
.Pp
In both cases the resulting text becomes (all or part of) a single word;
only in one special case (see
.Sx Command Substitution
.Em Command Substitution
below) does a `"' quoted string yield parts of more than one word;
`\'' quoted strings never do.
.Ss Alias substitution
@@ -708,7 +700,7 @@ occurs, and within `\''s where it
.Em never
occurs.
Strings quoted by `\*(ga' are interpreted later (see
.Sx "Command substitution"
.Nm "Command substitution"
below) so `$' substitution does not occur there until later, if at all.
A `$' is passed unchanged if followed by a blank, tab, or end-of-line.
.Pp
@@ -764,11 +756,11 @@ It is not an error for a range to be empty if the second argument is omitted
or in range.
.It $#name
.It ${#name}
Give the number of words in the variable.
Gives the number of words in the variable.
This is useful for later use in a
`$argv[selector]'.
.It $0
Substitute the name of the file from which command input is being read.
Substitutes the name of the file from which command input is being read.
An error occurs if the name is not known.
.It $number
.It ${number}
@@ -788,16 +780,16 @@ The following substitutions may not be modified with `:' modifiers.
.Bl -tag -width Ds -compact -offset indent
.It $?name
.It ${?name}
Substitute the string `1' if name is set, `0' if it is not.
Substitutes the string `1' if name is set, `0' if it is not.
.It $?0
Substitute `1' if the current input filename is known, `0' if it is not.
Substitutes `1' if the current input filename is known, `0' if it is not.
.It \&$\&$\&
Substitute the (decimal) process number of the (parent) shell.
.It $!
Substitute the (decimal) process number of the last background process
started by this shell.
.It $<
Substitute a line from the standard
Substitutes a line from the standard
input, with no further interpretation.
It can be used to read from the keyboard in a shell script.
.El
@@ -922,7 +914,7 @@ is expanded in the same way as `<' input filenames are.
.It >>& name
.It >>! name
.It >>&! name
Use file
Uses file
.Ar name
as the standard output;
like `>' but places output at the end of the file.
@@ -961,11 +953,11 @@ Several of the builtin commands (to be described later)
take expressions, in which the operators are similar to those of C, with
the same precedence.
These expressions appear in the
.Em @ ,
.Em exit ,
.Em if ,
.Nm @,
.Ar exit ,
.Ar if ,
and
.Em while
.Ar while
commands.
The following operators are available:
.Bd -ragged -offset indent
@@ -1076,7 +1068,7 @@ or
.Ar unalias .
.Pp
.It Ic alloc
Show the amount of dynamic memory acquired, broken down into used and
Shows the amount of dynamic memory acquired, broken down into used and
free memory.
With an argument shows the number of free and used blocks in each size
category. The categories start at size 8 and double at each step.
@@ -1085,11 +1077,11 @@ systems other than the VAX may use a different memory allocator.
.Pp
.It Ic bg
.It Ic bg \&% Ns Ar job ...
Put the current or specified jobs into the background, continuing them
Puts the current or specified jobs into the background, continuing them
if they were stopped.
.Pp
.It Ic break
Cause execution to resume after the
Causes execution to resume after the
.Ic end
of the nearest enclosing
.Ic foreach
@@ -1099,7 +1091,7 @@ The remaining commands on the current line are executed.
Multi-level breaks are thus possible by writing them all on one line.
.Pp
.It Ic breaksw
Cause a break from a
Causes a break from a
.Ic switch ,
resuming after the
.Ic endsw .
@@ -1137,7 +1129,7 @@ or
The rest of the commands on the current line are executed.
.Pp
.It Ic default :
Label the default case in a
Labels the default case in a
.Ic switch
statement.
The default should come after all
@@ -1145,7 +1137,7 @@ The default should come after all
labels.
.Pp
.It Ic dirs
Print the directory stack; the top of the stack is at the left,
Prints the directory stack; the top of the stack is at the left,
the first directory in the stack being the current directory.
.Pp
.It Ic echo Ar wordlist
@@ -1192,7 +1184,7 @@ variable (first form) or with the value of the specified
.Pp
.It Ic fg
.It Ic fg % Ns Ar job ...
Bring the current or specified jobs into the foreground, continuing them if
Brings the current or specified jobs into the foreground, continuing them if
they were stopped.
.Pp
.It Ic foreach Ar name (wordlist)
@@ -1252,7 +1244,7 @@ that does not begin with a `/'.
.It Ic history Ar n
.It Ic history Fl r Ar n
.It Ic history Fl h Ar n
Display the history event list; if
Displays the history event list; if
.Ar n
is given only the
.Ar n
@@ -1324,7 +1316,7 @@ must appear alone on its input line or after an
.Pp
.It Ic jobs
.It Ic jobs Fl l
List the active jobs; the
Lists the active jobs; the
.Fl l
option lists process id's in addition to the normal information.
.Pp
@@ -1332,10 +1324,10 @@ option lists process id's in addition to the normal information.
.It Ic kill Ar pid
.It Ic kill Fl sig Ar pid ...
.It Ic kill Fl l
Send either the TERM (terminate) signal or the
Sends either the TERM (terminate) signal or the
specified signal to the specified jobs or processes.
Signals are either given by number or by names (as given in
.Pa /usr/include/signal.h ,
.Pa /usr/include/signal.h,
stripped of the prefix ``SIG'').
The signal names are listed by ``kill \-l''.
There is no default, just saying `kill' does not
@@ -1349,7 +1341,7 @@ then the job or process will be sent a CONT (continue) signal as well.
.It Ic limit Fl h
.It Ic limit Fl h Ar resource
.It Ic limit Fl h Ar resource maximum-use
Limit the consumption by the current process and each process
Limits the consumption by the current process and each process
it creates to not individually exceed
.Ar maximum-use
on the
@@ -1405,7 +1397,7 @@ of the names suffice.
.Pp
.It Ic login
Terminate a login shell, replacing it with an instance of
.Pa /usr/bin/login .
.Pa /bin/login.
This is one way to log off, included for compatibility with
.Xr sh 1 .
.Pp
@@ -1448,7 +1440,7 @@ All processes detached with `&' are effectively
.Pp
.It Ic notify
.It Ic notify % Ns Ar job ...
Cause the shell to notify the user asynchronously when the status of the
Causes the shell to notify the user asynchronously when the status of the
current or specified jobs change; normally notification is presented
before a prompt. This is automatic if the shell variable
.Ic notify
@@ -1478,7 +1470,7 @@ are disabled (/etc/csh.cshrc, /etc/csh.login).
.Pp
.It Ic popd
.It Ic popd Ar +n
Pop the directory stack, returning to the new top directory.
Pops the directory stack, returning to the new top directory.
With an argument
.Ns \`+ Ar n Ns \'
discards the
@@ -1511,7 +1503,7 @@ stack around to be the top element and changes to it. The members
of the directory stack are numbered from the top starting at 0.
.Pp
.It Ic rehash
Cause the internal hash table of the contents of the directories in
Causes the internal hash table of the contents of the directories in
the
.Ic path
variable to be recomputed. This is needed if new commands are added
@@ -1589,7 +1581,7 @@ The most commonly used environment variables
and
.Ev PATH
are automatically imported to and exported from the
.Nm
.Nm csh
variables
.Ar user ,
.Ar term ,
@@ -1625,21 +1617,19 @@ commands.
Normally input during
.Ic source
commands is not placed on the history list;
the
.Fl h
option causes the commands to be placed on the
the \-h option causes the commands to be placed on the
history list without being executed.
.Pp
.It Ic stop
.It Ic stop % Ns Ar job ...
Stop the current or specified jobs that are executing in the background.
Stops the current or specified jobs that are executing in the background.
.Pp
.It Ic suspend
Cause the shell to stop in its tracks, much as if it had been sent a stop
Causes the shell to stop in its tracks, much as if it had been sent a stop
signal with
.Em ^Z .
.Ic ^Z .
This is most often used to stop shells started by
.Xr su 1 .
.Xr su 1 .
.Pp
.It Ic switch Ar (string)
.It Ic case Ar str1 :
@@ -1701,7 +1691,7 @@ is disabled.
.It Ic unlimit Ar resource
.It Ic unlimit Fl h
.It Ic unlimit Fl h Ar resource
Remove the limitation on
Removes the limitation on
.Ar resource .
If no
.Ar resource
@@ -1720,7 +1710,7 @@ It is not an error for nothing to be
.Ic unset .
.Pp
.It Ic unsetenv Ar pattern
Remove all variables whose name match the specified pattern from the
Removes all variables whose name match the specified pattern from the
environment. See also the
.Ic setenv
command above and
@@ -1732,7 +1722,7 @@ If the shell is interactive, then an interrupt can disrupt the wait.
After the interrupt, the shell prints names and job numbers of all jobs
known to be outstanding.
.It Ic which Ar command
Display the resolved command that will be executed by the shell.
Displays the resolved command that will be executed by the shell.
.Pp
.It Ic while Ar (expr)
.It \&...
@@ -1757,14 +1747,14 @@ Prompting occurs here the first time through the loop as for the
statement if the input is a terminal.
.Pp
.It Ic % Ns Ar job
Bring the specified job into the foreground.
Brings the specified job into the foreground.
.Pp
.It Ic % Ns Ar job Ic &
Continue the specified job in the background.
Continues the specified job in the background.
.Pp
.It Ic @
.It Ic @ Ar name Ns = Ns expr
.It Ic @ Ar name[index] Ns = Ns expr
.It Ic @ Ns Ar name Ns = expr
.It Ic @ Ns Ar name[index] Ns = expr
The first form prints the values of all the shell variables.
The second form sets the specified
.Ar name
@@ -1833,7 +1823,7 @@ is likewise handled; it is not
necessary to worry about its setting other than in the file
.Ar \&.cshrc
as inferior
.Nm
.Nm csh
processes will import the definition of
.Ar path
from the environment, and re-export it if you then change it.
@@ -1844,7 +1834,7 @@ positional parameters are substituted, i.e., `$1' is replaced by
`$argv[1]',
etc.
.It Ic cdpath
Give a list of alternate directories searched to find subdirectories
Gives a list of alternate directories searched to find subdirectories
in
.Ar chdir
commands.
@@ -1912,9 +1902,10 @@ files are not accidentally destroyed, and that `>>' redirections
refer to existing files.
.It Ic noglob
If set, filename expansion is inhibited.
This inhibition is most useful in shell scripts that are not dealing with
filenames, or after a list of filenames has been obtained and further
expansions are not desirable.
This inhibition is most useful in shell scripts that
are not dealing with filenames,
or after a list of filenames has been obtained and further expansions
are not desirable.
.It Ic nonomatch
If set, it is not an error for a filename expansion to not match any
existing files; instead the primitive pattern is returned.
@@ -1982,7 +1973,7 @@ If it terminated abnormally, then 0200 is added to the status.
Builtin commands that fail return exit status `1',
all other builtin commands set status to `0'.
.It Ic time
Control automatic timing of commands.
Controls automatic timing of commands.
If set, then any command that takes more than this many cpu seconds
will cause a line giving user, system, and real times and a utilization
percentage which is the ratio of user plus system times to real time
@@ -2081,35 +2072,27 @@ signal; otherwise this signal is passed on to children from the state in the
shell's parent.
Interrupts are not allowed when a login shell is reading the file
.Pa \&.logout .
.Sh AUTHORS
.An William Joy .
.Pp
Job control and directory stack features first implemented by
.An J.E. Kulp
of IIASA, Laxenburg, Austria,
.Sh AUTHOR
William Joy.
Job control and directory stack features first implemented by J.E. Kulp of
IIASA, Laxenburg, Austria,
with different syntax than that used now.
.Pp
File name completion code written by
.An Ken Greer ,
HP Labs.
.Pp
Eight-bit implementation
.An Christos S. Zoulas ,
Cornell University.
File name completion code written by Ken Greer, HP Labs.
Eight-bit implementation Christos S. Zoulas, Cornell University.
.Sh FILES
.Bl -tag -width /etc/passwd -compact
.It Pa ~/.cshrc
read at beginning of execution by each shell.
Read at beginning of execution by each shell.
.It Pa ~/.login
read by login shell, after `.cshrc' at login.
Read by login shell, after `.cshrc' at login.
.It Pa ~/.logout
read by login shell, at logout.
Read by login shell, at logout.
.It Pa /bin/sh
standard shell, for shell scripts not starting with a `#'.
Standard shell, for shell scripts not starting with a `#'.
.It Pa /tmp/sh*
temporary file for `<<'.
Temporary file for `<<'.
.It Pa /etc/passwd
source of home directories for `~name'.
Source of home directories for `~name'.
.El
.Sh LIMITATIONS
Word lengths \-
@@ -2124,19 +2107,18 @@ To detect looping, the shell restricts the number of
substitutions on a single line to 20.
.Sh SEE ALSO
.Xr sh 1 ,
.Xr su 1 ,
.Xr access 2 ,
.Xr execve 2 ,
.Xr fork 2 ,
.Xr killpg 2 ,
.Xr pipe 2 ,
.Xr setrlimit 2 ,
.Xr sigvec 2 ,
.Xr umask 2 ,
.Xr setrlimit 2 ,
.Xr wait 2 ,
.Xr tty 4 ,
.Xr a.out 5 ,
.Xr environ 7
.Xr environ 7 ,
.br
.Em An introduction to the C shell
.Sh HISTORY
+40 -46
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: csh.c,v 1.6.2.2 1998/01/31 17:06:13 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -46,7 +46,6 @@ static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <fcntl.h>
#include <errno.h>
#include <pwd.h>
@@ -115,10 +114,10 @@ main(argc, argv)
int argc;
char **argv;
{
Char *cp;
char *tcp;
int f;
char **tempv;
register Char *cp;
register char *tcp;
register int f;
register char **tempv;
struct sigvec osv;
cshin = stdin;
@@ -187,9 +186,7 @@ main(argc, argv)
AsciiOnly = k > 0377;
}
#else
AsciiOnly = getenv("LANG") == NULL &&
getenv("LC_ALL") == NULL &&
getenv("LC_CTYPE") == NULL;
AsciiOnly = getenv("LANG") == NULL && getenv("LC_CTYPE") == NULL;
#endif /* NLS */
/*
@@ -230,7 +227,7 @@ main(argc, argv)
*/
set(STRstatus, Strsave(STR0));
if ((tcp = getenv("HOME")) != NULL && strlen(tcp) < MAXPATHLEN)
if ((tcp = getenv("HOME")) != NULL)
cp = SAVE(tcp);
else
cp = NULL;
@@ -251,6 +248,14 @@ main(argc, argv)
if ((tcp = getenv("TERM")) != NULL)
set(STRterm, SAVE(tcp));
/*
* Re-initialize path if set in environment
*/
if ((tcp = getenv("PATH")) == NULL)
set1(STRpath, defaultpath(), &shvhed);
else
importpath(SAVE(tcp));
set(STRshell, Strsave(STR_SHELLPATH));
doldol = putn((int) getpid()); /* For $$ */
@@ -412,16 +417,6 @@ main(argc, argv)
stderror(ERR_SYSTEM, "csh", strerror(errno));
}
}
/*
* Re-initialize path if set in environment
* importpath uses intty and intact
*/
if ((tcp = getenv("PATH")) == NULL)
set1(STRpath, defaultpath(), &shvhed);
else
importpath(SAVE(tcp));
/*
* Decide whether we should play with signals or not. If we are explicitly
* told (via -i, or -) or we are a login shell (arg0 starts with -) or the
@@ -525,7 +520,7 @@ notty:
{
int osetintr = setintr;
sig_t oparintr = parintr;
int omask = sigblock(sigmask(SIGINT));
sigset_t omask = sigblock(sigmask(SIGINT));
setintr = 0;
parintr = SIG_IGN; /* Disable onintr */
@@ -604,9 +599,9 @@ void
importpath(cp)
Char *cp;
{
int i = 0;
Char *dp;
Char **pv;
register int i = 0;
register Char *dp;
register Char **pv;
int c;
for (dp = cp; *dp; dp++)
@@ -623,8 +618,7 @@ importpath(cp)
for (;;) {
if ((c = *dp) == ':' || c == 0) {
*dp = 0;
if (*cp != '/' && (euid == 0 || uid == 0) &&
(intact || (intty && isatty(SHOUT))))
if ((*cp != '/' || *cp == '\0') && (euid == 0 || uid == 0))
(void) fprintf(csherr,
"Warning: imported path contains relative components\n");
pv[i++] = Strsave(*cp ? cp : STRdot);
@@ -648,7 +642,7 @@ static int
srccat(cp, dp)
Char *cp, *dp;
{
Char *ep = Strspl(cp, dp);
register Char *ep = Strspl(cp, dp);
char *ptr = short2str(ep);
xfree((ptr_t) ep);
@@ -663,7 +657,7 @@ srcfile(f, onlyown, flag)
char *f;
bool onlyown, flag;
{
int unit;
register int unit;
if ((unit = open(f, O_RDONLY)) == -1)
return 0;
@@ -681,7 +675,7 @@ srcfile(f, onlyown, flag)
int insource;
static void
srcunit(unit, onlyown, hflg)
int unit;
register int unit;
bool onlyown, hflg;
{
/* We have to push down a lot of state here */
@@ -696,7 +690,7 @@ srcunit(unit, onlyown, hflg)
bool otell = cantell;
struct Bin saveB;
volatile int omask;
volatile sigset_t omask;
jmp_buf oldexit;
/* The (few) real local variables */
@@ -732,7 +726,7 @@ srcunit(unit, onlyown, hflg)
if (setintr)
omask = sigblock(sigmask(SIGINT));
/* Setup the new values of the state stuff saved above */
memmove((char *) &(saveB), (char *) &B, sizeof(B));
bcopy((char *) &B, (char *) &(saveB), sizeof(B));
fbuf = NULL;
fseekp = feobp = fblocks = 0;
oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
@@ -757,7 +751,7 @@ srcunit(unit, onlyown, hflg)
if (setintr)
(void) sigsetmask(omask);
if (oSHIN >= 0) {
int i;
register int i;
/* We made it to the new state... free up its storage */
/* This code could get run twice but xfree doesn't care */
@@ -766,7 +760,7 @@ srcunit(unit, onlyown, hflg)
xfree((ptr_t) fbuf);
/* Reset input arena */
memmove((char *) &B, (char *) &(saveB), sizeof(B));
bcopy((char *) &(saveB), (char *) &B, sizeof(B));
(void) close(SHIN), SHIN = oSHIN;
arginp = oarginp, onelflg = oonelflg;
@@ -815,7 +809,7 @@ rechist()
(void) Strcat(buf, STRsldthist);
}
if ((fp = creat(short2str(hfile), 0600)) == -1)
if ((fp = creat(short2str(hfile), 0600)) == -1)
return;
oldidfds = didfds;
@@ -879,14 +873,14 @@ int sig;
/*
* We kill the last foreground process group. It then becomes
* responsible to propagate the SIGHUP to its progeny.
* responsible to propagate the SIGHUP to its progeny.
*/
{
struct process *pp, *np;
for (pp = proclist.p_next; pp; pp = pp->p_next) {
np = pp;
/*
/*
* Find if this job is in the foreground. It could be that
* the process leader has exited and the foreground flag
* is cleared for it.
@@ -894,7 +888,7 @@ int sig;
do
/*
* If a process is in the foreground; we try to kill
* it's process group. If we succeed, then the
* it's process group. If we succeed, then the
* whole job is gone. Otherwise we keep going...
* But avoid sending HUP to the shell again.
*/
@@ -932,9 +926,9 @@ pintr1(wantnl)
bool wantnl;
{
Char **v;
int omask;
sigset_t omask;
omask = sigblock(0);
omask = sigblock((sigset_t) 0);
if (setintr) {
(void) sigsetmask(omask & ~sigmask(SIGINT));
if (pjobs) {
@@ -1004,7 +998,7 @@ process(catch)
* Interruptible during interactive reads
*/
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
/*
* For the sake of reset()
@@ -1121,7 +1115,7 @@ dosource(v, t)
struct command *t;
{
Char *f;
register Char *f;
bool hflg = 0;
Char buf[BUFSIZ];
@@ -1151,8 +1145,8 @@ dosource(v, t)
static void
mailchk()
{
struct varent *v;
Char **vp;
register struct varent *v;
register Char **vp;
time_t t;
int intvl, cnt;
struct stat stb;
@@ -1273,9 +1267,9 @@ vis_fputc(ch, fp)
{
char uenc[5]; /* 4 + NULL */
if (ch & QUOTE)
if (ch & QUOTE)
return fputc(ch & TRIM, fp);
/*
/*
* XXX: When we are in AsciiOnly we want all characters >= 0200 to
* be encoded, but currently there is no way in vis to do that.
*/
@@ -1339,7 +1333,7 @@ defaultpath()
void
printprompt()
{
Char *cp;
register Char *cp;
if (!whyles) {
for (cp = value(STRprompt); *cp; cp++)
+6 -4
View File
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)csh.h 8.1 (Berkeley) 5/31/93
* $Id: csh.h,v 1.2 1994/09/24 02:53:52 davidg Exp $
* $Id$
*/
/*
@@ -84,7 +84,7 @@ typedef void *ptr_t;
#include "const.h"
#include "char.h"
#include "errnum.h"
#include "err.h"
#define xmalloc(i) Malloc(i)
#define xrealloc(p, i) Realloc(p, i)
@@ -187,8 +187,8 @@ jmp_buf reslab;
#define setexit() (setjmp(reslab))
#define reset() longjmp(reslab, 1)
/* Should use structure assignment here */
#define getexit(a) memmove((char *)(a), (char *)reslab, sizeof reslab)
#define resexit(a) memmove((char *)reslab, (char *)(a), sizeof reslab)
#define getexit(a) bcopy((char *)reslab, ((char *)(a)), sizeof reslab)
#define resexit(a) bcopy((char *)(a), (char *)reslab, sizeof reslab)
Char *gointr; /* Label for an onintr transfer */
@@ -421,6 +421,8 @@ struct varent {
#define v_right v_link[1]
#define v_parent v_link[2]
struct varent *adrof1();
#define adrof(v) adrof1(v, &shvhed)
#define value(v) value1(v, &shvhed)
+31 -29
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: dir.c,v 1.4.2.1 1997/08/24 21:41:30 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -75,16 +75,16 @@ void
dinit(hp)
Char *hp;
{
char *tcp;
Char *cp;
struct directory *dp;
register char *tcp;
register Char *cp;
register struct directory *dp;
char path[MAXPATHLEN];
static char *emsg = "csh: Trying to start from \"%s\"\n";
/* Don't believe the login shell home, because it may be a symlink */
tcp = getwd(path); /* see ngetwd.c for System V version */
if (tcp == NULL || *tcp == '\0') {
(void) fprintf(csherr, "csh: %s: %s\n", path, strerror(errno));
(void) fprintf(csherr, "csh: %s\n", path);
if (hp && *hp) {
tcp = short2str(hp);
if (chdir(tcp) == -1)
@@ -145,7 +145,7 @@ Char *dp;
* Don't call set() directly cause if the directory contains ` or
* other junk characters glob will fail.
*/
Char **vec = (Char **) xmalloc((size_t) (2 * sizeof(Char **)));
register Char **vec = (Char **) xmalloc((size_t) (2 * sizeof(Char **)));
vec[0] = Strsave(dp);
vec[1] = 0;
@@ -203,7 +203,7 @@ dodirs(v, t)
static void
printdirs()
{
struct directory *dp;
register struct directory *dp;
Char *s, *hp = value(STRhome);
int idx, len, cur;
@@ -221,7 +221,7 @@ printdirs()
}
if (!(dirflag & DIR_LONG) && hp != NULL && !eq(hp, STRslash) &&
(len = Strlen(hp), Strncmp(hp, dp->di_name, len) == 0) &&
(dp->di_name[len] == '\0' || dp->di_name[len] == '/'))
(dp->di_name[len] == '\0' || dp->di_name[len] == '/'))
len = Strlen(s = (dp->di_name + len)) + 2;
else
len = Strlen(s = dp->di_name) + 1;
@@ -240,7 +240,7 @@ printdirs()
void
dtildepr(home, dir)
Char *home, *dir;
register Char *home, *dir;
{
if (!eq(home, STRslash) && prefix(home, dir))
@@ -340,8 +340,8 @@ dochngd(v, t)
Char **v;
struct command *t;
{
Char *cp;
struct directory *dp;
register Char *cp;
register struct directory *dp;
skipargs(&v, " [<dir>]");
printd = 0;
@@ -389,7 +389,7 @@ dgoto(cp)
Char *dp;
if (*cp != '/') {
Char *p, *q;
register Char *p, *q;
int cwdlen;
for (p = dcwd->di_name; *p++;)
@@ -423,9 +423,9 @@ dgoto(cp)
*/
static Char *
dfollow(cp)
Char *cp;
register Char *cp;
{
Char *dp;
register Char *dp;
struct varent *c;
char ebuf[MAXPATHLEN];
int serrno;
@@ -449,7 +449,7 @@ dfollow(cp)
if (cp[0] != '/' && !prefix(STRdotsl, cp) && !prefix(STRdotdotsl, cp)
&& (c = adrof(STRcdpath))) {
Char **cdp;
Char *p;
register Char *p;
Char buf[MAXPATHLEN];
for (cdp = c->vec; *cdp; cdp++) {
@@ -491,7 +491,7 @@ dopushd(v, t)
Char **v;
struct command *t;
{
struct directory *dp;
register struct directory *dp;
skipargs(&v, " [<dir>|+<n>]");
printd = 1;
@@ -523,7 +523,7 @@ dopushd(v, t)
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
else {
Char *ccp;
register Char *ccp;
ccp = dfollow(*v);
dp = (struct directory *) xcalloc(sizeof(struct directory), 1);
@@ -542,11 +542,11 @@ dopushd(v, t)
*/
static struct directory *
dfind(cp)
Char *cp;
register Char *cp;
{
struct directory *dp;
int i;
Char *ep;
register struct directory *dp;
register int i;
register Char *ep;
if (*cp++ != '+')
return (0);
@@ -576,7 +576,7 @@ dopopd(v, t)
Char **v;
struct command *t;
{
struct directory *dp, *p = NULL;
register struct directory *dp, *p = NULL;
skipargs(&v, " [+<n>]");
printd = 1;
@@ -614,7 +614,7 @@ dopopd(v, t)
*/
void
dfree(dp)
struct directory *dp;
register struct directory *dp;
{
if (dp->di_count != 0) {
@@ -633,10 +633,10 @@ dfree(dp)
*/
Char *
dcanon(cp, p)
Char *cp, *p;
register Char *cp, *p;
{
Char *sp;
Char *p1, *p2; /* general purpose */
register Char *sp;
register Char *p1, *p2; /* general purpose */
bool slash;
Char link[MAXPATHLEN];
@@ -702,7 +702,8 @@ dcanon(cp, p)
*/
*--sp = 0; /* form the pathname for readlink */
if (sp != cp && !adrof(STRignore_symlinks) &&
(cc = readlink(short2str(cp), tlink, sizeof(tlink) - 1)) >= 0) {
(cc = readlink(short2str(cp), tlink,
sizeof tlink)) >= 0) {
(void) Strcpy(link, str2short(tlink));
link[cc] = '\0';
@@ -786,7 +787,8 @@ dcanon(cp, p)
if (sp != cp && adrof(STRchase_symlinks) &&
!adrof(STRignore_symlinks) &&
(cc = readlink(short2str(cp), tlink, sizeof(tlink) - 1)) >= 0) {
(cc = readlink(short2str(cp), tlink,
sizeof tlink)) >= 0) {
(void) Strcpy(link, str2short(tlink));
link[cc] = '\0';
@@ -921,7 +923,7 @@ dcanon(cp, p)
*/
static void
dnewcwd(dp)
struct directory *dp;
register struct directory *dp;
{
dcwd = dp;
dset(dcwd->di_name);
+29 -29
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: dol.c,v 1.3 1995/05/30 00:06:31 rgrimes Exp $
* $Id$
*/
#ifndef lint
@@ -105,10 +105,10 @@ static void Dtestq __P((int));
*/
void
Dfix(t)
struct command *t;
register struct command *t;
{
Char **pp;
Char *p;
register Char **pp;
register Char *p;
if (noexec)
return;
@@ -130,7 +130,7 @@ Dfix(t)
*/
Char *
Dfix1(cp)
Char *cp;
register Char *cp;
{
Char *Dv[2];
@@ -173,8 +173,8 @@ static Char *
Dpack(wbuf, wp)
Char *wbuf, *wp;
{
int c;
int i = MAXWLEN - (wp - wbuf);
register int c;
register int i = MAXWLEN - (wp - wbuf);
for (;;) {
c = DgetC(DODOL);
@@ -220,11 +220,11 @@ Dpack(wbuf, wp)
static int
Dword()
{
int c, c1;
register int c, c1;
Char wbuf[BUFSIZ];
Char *wp = wbuf;
int i = MAXWLEN;
bool dolflg;
register Char *wp = wbuf;
register int i = MAXWLEN;
register bool dolflg;
bool sofar = 0, done = 0;
while (!done) {
@@ -340,9 +340,9 @@ Dword()
*/
static int
DgetC(flag)
int flag;
register int flag;
{
int c;
register int c;
top:
if ((c = Dpeekc) != '\0') {
@@ -401,8 +401,8 @@ dolerror(s)
static void
Dgetdol()
{
Char *np;
struct varent *vp = NULL;
register Char *np;
register struct varent *vp = NULL;
Char name[4 * MAXVARLEN + 1];
int c, sc;
int subscr = 0, lwb = 1, upb = 0;
@@ -425,7 +425,7 @@ Dgetdol()
if (dimen || bitset)
stderror(ERR_SYNTAX);
if (backpid != 0) {
if (dolbang)
if (dolbang)
xfree((ptr_t) dolbang);
setDolp(dolbang = putn(backpid));
}
@@ -574,7 +574,7 @@ Dgetdol()
else if (*np != '-')
stderror(ERR_MISSING, '-');
else {
int i = upb;
register int i = upb;
np++;
if (Isdigit(*np)) {
@@ -632,7 +632,7 @@ eatbrac:
static void
fixDolMod()
{
int c;
register int c;
c = DgetC(0);
if (c == ':') {
@@ -645,13 +645,13 @@ fixDolMod()
dolwcnt = 10000;
c = DgetC(0);
}
if ((c == 'g' && dolmcnt != 10000) ||
if ((c == 'g' && dolmcnt != 10000) ||
(c == 'a' && dolwcnt != 10000)) {
if (c == 'g')
dolmcnt = 10000;
else
dolwcnt = 10000;
c = DgetC(0);
c = DgetC(0);
}
if (c == 's') { /* [eichin:19910926.0755EST] */
@@ -659,12 +659,12 @@ fixDolMod()
int delim = DgetC(0);
dolmod[dolnmod++] = c;
dolmod[dolnmod++] = delim;
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
}
while ((c = DgetC(0)) != (-1)) {
dolmod[dolnmod++] = c;
if(c == delim) delimcnt--;
@@ -691,9 +691,9 @@ fixDolMod()
static void
setDolp(cp)
Char *cp;
register Char *cp;
{
Char *dp;
register Char *dp;
int i;
if (dolnmod == 0 || dolmcnt == 0) {
@@ -708,7 +708,7 @@ setDolp(cp)
Char *lhsub, *rhsub, *np;
size_t lhlen = 0, rhlen = 0;
int didmod = 0;
delim = dolmod[++i];
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
@@ -804,7 +804,7 @@ unDredc(c)
static int
Dredc()
{
int c;
register int c;
if ((c = Dpeekrd) != '\0') {
Dpeekrd = 0;
@@ -822,7 +822,7 @@ Dredc()
static void
Dtestq(c)
int c;
register int c;
{
if (cmap(c, QUOTES))
@@ -839,11 +839,11 @@ void
heredoc(term)
Char *term;
{
int c;
register int c;
Char *Dv[2];
Char obuf[BUFSIZ], lbuf[BUFSIZ], mbuf[BUFSIZ];
int ocnt, lcnt, mcnt;
Char *lbp, *obp, *mbp;
register Char *lbp, *obp, *mbp;
Char **vp;
bool quoted;
char *tmp;
+3 -3
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: err.c,v 1.2.8.1 1997/08/24 21:41:31 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -307,7 +307,7 @@ seterror(id, va_alist)
#endif
if (id < 0 || id > sizeof(errorlist) / sizeof(errorlist[0]))
id = ERR_INVALID;
vsnprintf(berr, sizeof(berr), errorlist[id], va);
vsprintf(berr, errorlist[id], va);
va_end(va);
seterr = strsave(berr);
@@ -342,7 +342,7 @@ stderror(id, va_alist)
#endif
{
va_list va;
Char **v;
register Char **v;
int flags = id & ERR_FLAGS;
id &= ~ERR_FLAGS;
+33 -40
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: exec.c,v 1.4.2.1 1997/08/24 21:41:31 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -50,7 +50,7 @@ static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 5/31/93";
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#endif
#include "csh.h"
#include "extern.h"
@@ -113,10 +113,10 @@ doexec(v, t)
Char **v;
struct command *t;
{
Char *dp, **pv, **av, *sav;
struct varent *pathv;
bool slash;
int hashval = 0, hashval1, i;
register Char *dp, **pv, **av, *sav;
register struct varent *pathv;
register bool slash;
register int hashval = 0, hashval1, i;
Char *blk[2];
/*
@@ -193,7 +193,7 @@ doexec(v, t)
* We must do this AFTER any possible forking (like `foo` in glob) so that
* this shell can still do subprocesses.
*/
(void) sigsetmask(0);
(void) sigsetmask((sigset_t) 0);
/*
* If no path, no words in path, or a / in the filename then restrict the
* command search.
@@ -265,12 +265,12 @@ pexerr()
static void
texec(sf, st)
Char *sf;
Char **st;
register Char **st;
{
char **t;
char *f;
struct varent *v;
Char **vp;
register char **t;
register char *f;
register struct varent *v;
register Char **vp;
Char *lastsh[2];
int fd;
unsigned char c;
@@ -361,7 +361,7 @@ texec(sf, st)
void
execash(t, kp)
Char **t;
struct command *kp;
register struct command *kp;
{
int saveIN, saveOUT, saveDIAG, saveSTD;
int oSHIN;
@@ -446,8 +446,8 @@ dohash(v, t)
struct command *t;
{
DIR *dirp;
struct dirent *dp;
int cnt;
register struct dirent *dp;
register int cnt;
int i = 0;
struct varent *pathv = adrof(STRpath);
Char **pv;
@@ -504,9 +504,9 @@ hashstat(v, t)
*/
static int
hashname(cp)
Char *cp;
register Char *cp;
{
long h = 0;
register long h = 0;
while (*cp)
h = hash(h, *cp++);
@@ -517,11 +517,11 @@ static int
iscommand(name)
Char *name;
{
Char **pv;
Char *sav;
struct varent *v;
bool slash = any(short2str(name), '/');
int hashval = 0, hashval1, i;
register Char **pv;
register Char *sav;
register struct varent *v;
register bool slash = any(short2str(name), '/');
register int hashval = 0, hashval1, i;
v = adrof(STRpath);
if (v == 0 || v->vec[0] == 0 || slash)
@@ -618,7 +618,7 @@ executable(dir, name, dir_ok)
/*ARGSUSED*/
void
dowhich(v, c)
Char **v;
register Char **v;
struct command *c;
{
struct wordent lex[3];
@@ -652,11 +652,11 @@ static void
tellmewhat(lex)
struct wordent *lex;
{
int i;
struct biltins *bptr;
struct wordent *sp = lex->next;
register int i;
register struct biltins *bptr;
register struct wordent *sp = lex->next;
bool aliased = 0;
Char *s0, *s1, *s2, *cmd;
Char *s0, *s1, *s2;
Char qc;
if (adrof1(sp->word, &aliases)) {
@@ -696,18 +696,16 @@ tellmewhat(lex)
if (eq(sp->word, str2short(bptr->bname))) {
if (aliased)
prlex(cshout, lex);
(void) fprintf(cshout, "%s: shell built-in command.\n",
(void) fprintf(cshout, "%s: shell built-in command.\n",
vis_str(sp->word));
sp->word = s0; /* we save and then restore this */
return;
}
}
sp->word = cmd = globone(sp->word, G_IGNORE);
if ((i = iscommand(strip(sp->word))) != 0) {
Char **pv;
struct varent *v;
register Char **pv;
register struct varent *v;
bool slash = any(short2str(sp->word), '/');
v = adrof(STRpath);
@@ -719,14 +717,10 @@ tellmewhat(lex)
while (--i)
pv++;
if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
if (!slash) {
sp->word = Strspl(STRdotsl, sp->word);
prlex(cshout, lex);
xfree((ptr_t) sp->word);
} else
prlex(cshout, lex);
sp->word = Strspl(STRdotsl, sp->word);
prlex(cshout, lex);
xfree((ptr_t) sp->word);
sp->word = s0; /* we save and then restore this */
xfree((ptr_t) cmd);
return;
}
s1 = Strspl(*pv, STRslash);
@@ -740,6 +734,5 @@ tellmewhat(lex)
prlex(cshout, lex);
(void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word));
}
xfree((ptr_t) cmd);
sp->word = s0; /* we save and then restore this */
}
+45 -45
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: exp.c,v 1.2 1994/09/24 02:54:00 davidg Exp $
* $Id$
*/
#ifndef lint
@@ -91,23 +91,23 @@ static void etraci __P((char *, int, Char ***));
int
expr(vp)
Char ***vp;
register Char ***vp;
{
return (exp0(vp, 0));
}
int
exp0(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int p1 = exp1(vp, ignore);
register int p1 = exp1(vp, ignore);
#ifdef EDEBUG
etraci("exp0 p1", p1, vp);
#endif
if (**vp && eq(**vp, STRor2)) {
int p2;
register int p2;
(*vp)++;
p2 = exp0(vp, (ignore & IGNORE) || p1);
@@ -121,16 +121,16 @@ exp0(vp, ignore)
static int
exp1(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int p1 = exp2(vp, ignore);
register int p1 = exp2(vp, ignore);
#ifdef EDEBUG
etraci("exp1 p1", p1, vp);
#endif
if (**vp && eq(**vp, STRand2)) {
int p2;
register int p2;
(*vp)++;
p2 = exp1(vp, (ignore & IGNORE) || !p1);
@@ -144,16 +144,16 @@ exp1(vp, ignore)
static int
exp2(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int p1 = exp2a(vp, ignore);
register int p1 = exp2a(vp, ignore);
#ifdef EDEBUG
etraci("exp3 p1", p1, vp);
#endif
if (**vp && eq(**vp, STRor)) {
int p2;
register int p2;
(*vp)++;
p2 = exp2(vp, ignore);
@@ -167,16 +167,16 @@ exp2(vp, ignore)
static int
exp2a(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int p1 = exp2b(vp, ignore);
register int p1 = exp2b(vp, ignore);
#ifdef EDEBUG
etraci("exp2a p1", p1, vp);
#endif
if (**vp && eq(**vp, STRcaret)) {
int p2;
register int p2;
(*vp)++;
p2 = exp2a(vp, ignore);
@@ -190,16 +190,16 @@ exp2a(vp, ignore)
static int
exp2b(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int p1 = exp2c(vp, ignore);
register int p1 = exp2c(vp, ignore);
#ifdef EDEBUG
etraci("exp2b p1", p1, vp);
#endif
if (**vp && eq(**vp, STRand)) {
int p2;
register int p2;
(*vp)++;
p2 = exp2b(vp, ignore);
@@ -213,12 +213,12 @@ exp2b(vp, ignore)
static int
exp2c(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
Char *p1 = exp3(vp, ignore);
Char *p2;
int i;
register Char *p1 = exp3(vp, ignore);
register Char *p2;
register int i;
#ifdef EDEBUG
etracc("exp2c p1", p1, vp);
@@ -261,11 +261,11 @@ exp2c(vp, ignore)
static Char *
exp3(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
Char *p1, *p2;
int i;
register Char *p1, *p2;
register int i;
p1 = exp3a(vp, ignore);
#ifdef EDEBUG
@@ -307,11 +307,11 @@ exp3(vp, ignore)
static Char *
exp3a(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
Char *p1, *p2, *op;
int i;
register Char *p1, *p2, *op;
register int i;
p1 = exp4(vp, ignore);
#ifdef EDEBUG
@@ -337,18 +337,18 @@ exp3a(vp, ignore)
static Char *
exp4(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
Char *p1, *p2;
int i = 0;
register Char *p1, *p2;
register int i = 0;
p1 = exp5(vp, ignore);
#ifdef EDEBUG
etracc("exp4 p1", p1, vp);
#endif
if (isa(**vp, ADDOP)) {
Char *op = *(*vp)++;
register Char *op = *(*vp)++;
p2 = exp4(vp, ignore);
#ifdef EDEBUG
@@ -374,18 +374,18 @@ exp4(vp, ignore)
static Char *
exp5(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
Char *p1, *p2;
int i = 0;
register Char *p1, *p2;
register int i = 0;
p1 = exp6(vp, ignore);
#ifdef EDEBUG
etracc("exp5 p1", p1, vp);
#endif
if (isa(**vp, MULOP)) {
Char *op = *(*vp)++;
register Char *op = *(*vp)++;
p2 = exp5(vp, ignore);
#ifdef EDEBUG
@@ -421,11 +421,11 @@ exp5(vp, ignore)
static Char *
exp6(vp, ignore)
Char ***vp;
register Char ***vp;
bool ignore;
{
int ccode, i = 0;
Char *cp, *dp, *ep;
register Char *cp, *dp, *ep;
if (**vp == 0)
stderror(ERR_NAME | ERR_EXPRESSION);
@@ -461,7 +461,7 @@ exp6(vp, ignore)
return (putn(ccode));
}
if (eq(**vp, STRLbrace)) {
Char **v;
register Char **v;
struct command faket;
Char *fakecom[2];
@@ -600,18 +600,18 @@ exp6(vp, ignore)
static void
evalav(v)
Char **v;
register Char **v;
{
struct wordent paraml1;
struct wordent *hp = &paraml1;
register struct wordent *hp = &paraml1;
struct command *t;
struct wordent *wdp = hp;
register struct wordent *wdp = hp;
set(STRstatus, Strsave(STR0));
hp->prev = hp->next = hp;
hp->word = STRNULL;
while (*v) {
struct wordent *new =
register struct wordent *new =
(struct wordent *) xcalloc(1, sizeof *wdp);
new->prev = wdp;
@@ -631,8 +631,8 @@ evalav(v)
static int
isa(cp, what)
Char *cp;
int what;
register Char *cp;
register int what;
{
if (cp == 0)
return ((what & RESTOP) != 0);
@@ -680,7 +680,7 @@ isa(cp, what)
static int
egetn(cp)
Char *cp;
register Char *cp;
{
if (*cp && *cp != '-' && !Isdigit(*cp))
stderror(ERR_NAME | ERR_EXPRESSION);
+2 -2
View File
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 5/31/93
* $Id: extern.h,v 1.2 1994/09/24 02:54:02 davidg Exp $
* $Id$
*/
#include <sys/cdefs.h>
@@ -161,7 +161,7 @@ Char *globone __P((Char *, int));
int Gmatch __P((Char *, Char *));
void ginit __P((void));
Char **globall __P((Char **));
void rscan __P((Char **, void (*)(int)));
void rscan __P((Char **, void (*)()));
void tglob __P((Char **));
void trim __P((Char **));
#ifdef FILEC
+34 -34
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: file.c,v 1.4.2.1 1997/08/24 21:41:33 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -112,14 +112,14 @@ static void
setup_tty(on)
int on;
{
struct termios tchars;
static struct termios tchars;
(void) tcgetattr(SHIN, &tchars);
if (on) {
tchars.c_cc[VEOL] = ESC;
if (tchars.c_lflag & ICANON)
on = TCSADRAIN;
on = TCSANOW;
else {
on = TCSAFLUSH;
tchars.c_lflag |= ICANON;
@@ -127,10 +127,10 @@ setup_tty(on)
}
else {
tchars.c_cc[VEOL] = _POSIX_VDISABLE;
on = TCSADRAIN;
on = TCSANOW;
}
(void) tcsetattr(SHIN, on, &tchars);
(void) tcsetattr(SHIN, TCSANOW, &tchars);
}
/*
@@ -160,7 +160,7 @@ static void
pushback(string)
Char *string;
{
Char *p;
register Char *p;
struct termios tty, tty_normal;
int omask;
char c;
@@ -184,8 +184,8 @@ pushback(string)
*/
static void
catn(des, src, count)
Char *des, *src;
int count;
register Char *des, *src;
register int count;
{
while (--count >= 0 && *des)
des++;
@@ -201,8 +201,8 @@ catn(des, src, count)
*/
static void
copyn(des, src, count)
Char *des, *src;
int count;
register Char *des, *src;
register int count;
{
while (--count >= 0)
if ((*des++ = *src++) == 0)
@@ -251,7 +251,7 @@ print_by_column(dir, items, count)
Char *dir, *items[];
int count;
{
int i, rows, r, c, maxwidth = 0, columns;
register int i, rows, r, c, maxwidth = 0, columns;
if (ioctl(SHOUT, TIOCGWINSZ, (ioctl_t) & win) < 0 || win.ws_col == 0)
win.ws_col = 80;
@@ -266,7 +266,7 @@ print_by_column(dir, items, count)
for (c = 0; c < columns; c++) {
i = c * rows + r;
if (i < count) {
int w;
register int w;
(void) fprintf(cshout, "%s", vis_str(items[i]));
(void) fputc(dir ? filetype(dir, items[i]) : ' ', cshout);
@@ -292,8 +292,8 @@ static Char *
tilde(new, old)
Char *new, *old;
{
Char *o, *p;
struct passwd *pw;
register Char *o, *p;
register struct passwd *pw;
static Char person[40];
if (old[0] != '~')
@@ -375,7 +375,7 @@ static void
extract_dir_and_name(path, dir, name)
Char *path, *dir, *name;
{
Char *p;
register Char *p;
p = Strrchr(path, '/');
if (p == NULL) {
@@ -393,8 +393,8 @@ getentry(dir_fd, looking_for_lognames)
DIR *dir_fd;
int looking_for_lognames;
{
struct passwd *pw;
struct dirent *dirp;
register struct passwd *pw;
register struct dirent *dirp;
if (looking_for_lognames) {
if ((pw = getpwent()) == NULL)
@@ -408,9 +408,9 @@ getentry(dir_fd, looking_for_lognames)
static void
free_items(items)
Char **items;
register Char **items;
{
int i;
register int i;
for (i = 0; items[i]; i++)
xfree((ptr_t) items[i]);
@@ -436,9 +436,9 @@ tsearch(word, command, max_word_length)
int max_word_length;
{
static Char **items = NULL;
DIR *dir_fd;
int numitems = 0, ignoring = TRUE, nignored = 0;
int name_length, looking_for_lognames;
register DIR *dir_fd;
register numitems = 0, ignoring = TRUE, nignored = 0;
register name_length, looking_for_lognames;
Char tilded_dir[MAXPATHLEN + 1], dir[MAXPATHLEN + 1];
Char name[MAXNAMLEN + 1], extended_name[MAXNAMLEN + 1];
Char *entry;
@@ -450,7 +450,7 @@ tsearch(word, command, max_word_length)
looking_for_lognames = (*word == '~') && (Strchr(word, '/') == NULL);
if (looking_for_lognames) {
setpwent();
(void) setpwent();
copyn(name, &word[1], MAXNAMLEN); /* name sans ~ */
dir_fd = NULL;
}
@@ -498,7 +498,7 @@ again: /* search for matches */
ignoring = FALSE;
nignored = 0;
if (looking_for_lognames)
setpwent();
(void) setpwent();
else
rewinddir(dir_fd);
goto again;
@@ -521,7 +521,7 @@ again: /* search for matches */
return (numitems);
}
else { /* LIST */
qsort((ptr_t) items, numitems, sizeof(items[0]),
qsort((ptr_t) items, numitems, sizeof(items[0]),
(int (*) __P((const void *, const void *))) sortscmp);
print_by_column(looking_for_lognames ? NULL : tilded_dir,
items, numitems);
@@ -547,8 +547,8 @@ recognize(extended_name, entry, name_length, numitems)
if (numitems == 1) /* 1st match */
copyn(extended_name, entry, MAXNAMLEN);
else { /* 2nd & subsequent matches */
Char *x, *ent;
int len = 0;
register Char *x, *ent;
register int len = 0;
x = extended_name;
for (ent = entry; *x && *x == *ent++; x++, len++)
@@ -567,7 +567,7 @@ recognize(extended_name, entry, name_length, numitems)
*/
static int
is_prefix(check, template)
Char *check, *template;
register Char *check, *template;
{
do
if (*check == 0)
@@ -584,7 +584,7 @@ static int
is_suffix(check, template)
Char *check, *template;
{
Char *c, *t;
register Char *c, *t;
for (c = check; *c++;)
continue;
@@ -603,7 +603,7 @@ tenex(inputline, inputline_size)
Char *inputline;
int inputline_size;
{
int numitems, num_read;
register int numitems, num_read;
char tinputline[BUFSIZ];
@@ -613,8 +613,8 @@ tenex(inputline, inputline_size)
int i;
static Char delims[] = {' ', '\'', '"', '\t', ';', '&', '<',
'>', '(', ')', '|', '^', '%', '\0'};
Char *str_end, *word_start, last_Char, should_retype;
int space_left;
register Char *str_end, *word_start, last_Char, should_retype;
register int space_left;
COMMAND command;
for (i = 0; i < num_read; i++)
@@ -671,10 +671,10 @@ tenex(inputline, inputline_size)
static int
ignored(entry)
Char *entry;
register Char *entry;
{
struct varent *vp;
Char **cp;
register Char **cp;
if ((vp = adrof(STRfignore)) == NULL || (cp = vp->vec) == NULL)
return (FALSE);
+63 -65
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: func.c,v 1.5.2.1 1997/08/24 21:41:33 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -72,8 +72,8 @@ struct biltins *
isbfunc(t)
struct command *t;
{
Char *cp = t->t_dcom[0];
struct biltins *bp, *bp1, *bp2;
register Char *cp = t->t_dcom[0];
register struct biltins *bp, *bp1, *bp2;
static struct biltins label = {"", dozip, 0, 0};
static struct biltins foregnd = {"%job", dofg1, 0, 0};
static struct biltins backgnd = {"%job &", dobg1, 0, 0};
@@ -96,7 +96,7 @@ isbfunc(t)
* one past the end.
*/
for (bp1 = bfunc, bp2 = bfunc + nbfunc; bp1 < bp2;) {
int i;
register i;
bp = bp1 + ((bp2 - bp1) >> 1);
if ((i = *cp - *bp->bname) == 0 &&
@@ -112,8 +112,8 @@ isbfunc(t)
void
func(t, bp)
struct command *t;
struct biltins *bp;
register struct command *t;
register struct biltins *bp;
{
int i;
@@ -133,8 +133,8 @@ doonintr(v, t)
Char **v;
struct command *t;
{
Char *cp;
Char *vv = v[1];
register Char *cp;
register Char *vv = v[1];
if (parintr == SIG_IGN)
return;
@@ -194,8 +194,8 @@ doalias(v, t)
Char **v;
struct command *t;
{
struct varent *vp;
Char *p;
register struct varent *vp;
register Char *p;
v++;
p = *v++;
@@ -265,8 +265,8 @@ doif(v, kp)
Char **v;
struct command *kp;
{
int i;
Char **vv;
register int i;
register Char **vv;
v++;
i = expr(&v);
@@ -302,7 +302,7 @@ doif(v, kp)
*/
static void
reexecute(kp)
struct command *kp;
register struct command *kp;
{
kp->t_dflg &= F_SAVE;
kp->t_dflg |= F_REPEAT;
@@ -339,7 +339,7 @@ void
gotolab(lab)
Char *lab;
{
struct whyle *wp;
register struct whyle *wp;
/*
* While we still can, locate any unknown ends of existing loops. This
* obscure code is the WORST result of the fact that we don't really parse.
@@ -365,7 +365,7 @@ doswitch(v, t)
Char **v;
struct command *t;
{
Char *cp, *lp;
register Char *cp, *lp;
v++;
if (!*v || *(*v++) != '(')
@@ -419,8 +419,8 @@ doforeach(v, t)
Char **v;
struct command *t;
{
Char *cp, *sp;
struct whyle *nwp;
register Char *cp, *sp;
register struct whyle *nwp;
v++;
sp = cp = strip(*v);
@@ -463,8 +463,8 @@ dowhile(v, t)
Char **v;
struct command *t;
{
int status;
bool again = whyles != 0 && SEEKEQ(&whyles->w_start, &lineloc) &&
register int status;
register bool again = whyles != 0 && SEEKEQ(&whyles->w_start, &lineloc) &&
whyles->w_fename == 0;
v++;
@@ -479,7 +479,7 @@ dowhile(v, t)
if (*v)
stderror(ERR_NAME | ERR_EXPRESSION);
if (!again) {
struct whyle *nwp =
register struct whyle *nwp =
(struct whyle *) xcalloc(1, sizeof(*nwp));
nwp->w_start = lineloc;
@@ -507,7 +507,7 @@ preread()
{
whyles->w_end.type = I_SEEK;
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
search(T_BREAK, 0, NULL); /* read the expression in */
if (setintr)
@@ -564,8 +564,8 @@ dorepeat(v, kp)
Char **v;
struct command *kp;
{
int i;
int omask = 0;
register int i;
register sigset_t omask = 0;
i = getn(v[1]);
if (setintr)
@@ -593,10 +593,10 @@ doswbrk(v, t)
int
srchx(cp)
Char *cp;
register Char *cp;
{
struct srch *sp, *sp1, *sp2;
int i;
register struct srch *sp, *sp1, *sp2;
register i;
/*
* Binary search Sp1 is the beginning of the current search range. Sp2 is
@@ -622,12 +622,12 @@ static Char *Sgoal;
static void
search(type, level, goal)
int type;
int level;
register int level;
Char *goal;
{
Char wordbuf[BUFSIZ];
Char *aword = wordbuf;
Char *cp;
register Char *aword = wordbuf;
register Char *cp;
Stype = type;
Sgoal = goal;
@@ -722,10 +722,10 @@ search(type, level, goal)
static int
getword(wp)
Char *wp;
register Char *wp;
{
int found = 0;
int c, d;
register int found = 0;
register int c, d;
int kwd = 0;
Char *owp = wp;
@@ -851,7 +851,7 @@ wfree()
btell(&o);
for (; whyles; whyles = nwp) {
struct whyle *wp = whyles;
register struct whyle *wp = whyles;
nwp = wp->w_next;
/*
@@ -860,12 +860,12 @@ wfree()
if (wp->w_end.type != I_SEEK && wp->w_start.type == wp->w_end.type &&
wp->w_start.type == o.type) {
if (wp->w_end.type == F_SEEK) {
if (o.f_seek >= wp->w_start.f_seek &&
if (o.f_seek >= wp->w_start.f_seek &&
(wp->w_end.f_seek == 0 || o.f_seek < wp->w_end.f_seek))
break;
}
else {
if (o.a_seek >= wp->w_start.a_seek &&
if (o.a_seek >= wp->w_start.a_seek &&
(wp->w_end.a_seek == 0 || o.a_seek < wp->w_end.a_seek))
break;
}
@@ -901,13 +901,13 @@ doglob(v, t)
static void
xecho(sep, v)
int sep;
Char **v;
register Char **v;
{
Char *cp;
register Char *cp;
int nonl = 0;
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
v++;
if (*v == 0)
return;
@@ -924,7 +924,7 @@ xecho(sep, v)
if (sep == ' ' && *v && eq(*v, STRmn))
nonl++, v++;
while ((cp = *v++) != NULL) {
int c;
register int c;
while ((c = *cp++) != '\0')
(void) vis_fputc(c | QUOTE, cshout);
@@ -952,10 +952,10 @@ dosetenv(v, t)
v++;
if ((vp = *v++) == 0) {
Char **ep;
register Char **ep;
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
for (ep = STR_environ; *ep; ep++)
(void) fprintf(cshout, "%s\n", vis_str(*ep));
return;
@@ -967,8 +967,7 @@ dosetenv(v, t)
importpath(lp);
dohash(NULL, NULL);
}
else if (eq(vp, STRLANG) || eq(vp, STRLC_CTYPE) ||
eq(vp, STRLC_ALL) || eq(vp, STRLC_COLLATE)) {
else if (eq(vp, STRLANG) || eq(vp, STRLC_CTYPE)) {
#ifdef NLS
int k;
@@ -1016,12 +1015,7 @@ dounsetenv(v, t)
if (!Gmatch(name, *v))
continue;
maxi = 1;
/*
* Delete name, and start again cause the environment changes
*/
Unsetenv(name);
if (eq(name, STRLANG) || eq(name, STRLC_CTYPE) ||
eq(name, STRLC_ALL) || eq(name, STRLC_COLLATE)) {
if (eq(name, STRLANG) || eq(name, STRLC_CTYPE)) {
#ifdef NLS
int k;
@@ -1031,10 +1025,13 @@ dounsetenv(v, t)
AsciiOnly = k > 0377;
#else
AsciiOnly = getenv("LANG") == NULL &&
getenv("LC_ALL") == NULL &&
getenv("LC_CTYPE") == NULL;
#endif /* NLS */
}
/*
* Delete name, and start again cause the environment changes
*/
Unsetenv(name);
break;
}
xfree((ptr_t) name);
@@ -1045,8 +1042,8 @@ void
Setenv(name, val)
Char *name, *val;
{
Char **ep = STR_environ;
Char *cp, *dp;
register Char **ep = STR_environ;
register Char *cp, *dp;
Char *blk[2];
Char **oep = ep;
@@ -1078,8 +1075,8 @@ static void
Unsetenv(name)
Char *name;
{
Char **ep = STR_environ;
Char *cp, *dp;
register Char **ep = STR_environ;
register Char *cp, *dp;
Char **oep = ep;
for (; *ep; ep++) {
@@ -1104,8 +1101,8 @@ doumask(v, t)
Char **v;
struct command *t;
{
Char *cp = v[1];
int i;
register Char *cp = v[1];
register int i;
if (cp == 0) {
i = umask(0);
@@ -1151,7 +1148,7 @@ static struct limits *
findlim(cp)
Char *cp;
{
struct limits *lp, *res;
register struct limits *lp, *res;
res = (struct limits *) NULL;
for (lp = limits; lp->limconst >= 0; lp++)
@@ -1173,8 +1170,8 @@ dolimit(v, t)
Char **v;
struct command *t;
{
struct limits *lp;
RLIM_TYPE limit;
register struct limits *lp;
register RLIM_TYPE limit;
char hard = 0;
v++;
@@ -1199,10 +1196,11 @@ dolimit(v, t)
static RLIM_TYPE
getval(lp, v)
struct limits *lp;
register struct limits *lp;
Char **v;
{
float f;
register float f;
double atof();
Char *cp = *v++;
f = atof(short2str(cp));
@@ -1282,7 +1280,7 @@ limtail(cp, str)
/*ARGSUSED*/
static void
plim(lp, hard)
struct limits *lp;
register struct limits *lp;
Char hard;
{
struct rlimit rlim;
@@ -1309,7 +1307,7 @@ dounlimit(v, t)
Char **v;
struct command *t;
{
struct limits *lp;
register struct limits *lp;
int lerr = 0;
Char hard = 0;
@@ -1335,7 +1333,7 @@ dounlimit(v, t)
static int
setlim(lp, hard, limit)
struct limits *lp;
register struct limits *lp;
Char hard;
RLIM_TYPE limit;
{
@@ -1367,7 +1365,7 @@ dosuspend(v, t)
{
int ctpgrp;
void (*old) __P((int));
void (*old) ();
if (loginsh)
stderror(ERR_SUSPLOG);
+21 -40
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: glob.c,v 1.6 1996/10/31 07:22:48 ache Exp $
* $Id$
*/
#ifndef lint
@@ -40,7 +40,6 @@ static char sccsid[] = "@(#)glob.c 8.1 (Berkeley) 5/31/93";
#include <sys/param.h>
#include <glob.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -94,24 +93,7 @@ static int pmatch __P((Char *, Char *));
static void pword __P((void));
static void psave __P((int));
static void backeval __P((Char *, bool));
static int collate_range_cmp __P((int, int));
static int collate_range_cmp (c1, c2)
int c1, c2;
{
static char s1[2], s2[2];
int ret;
c1 &= UCHAR_MAX;
c2 &= UCHAR_MAX;
if (c1 == c2)
return (0);
s1[0] = c1;
s2[0] = c2;
if ((ret = strcoll(s1, s2)) != 0)
return (ret);
return (c1 - c2);
}
static Char *
globtilde(nv, s)
@@ -553,10 +535,10 @@ ginit()
void
rscan(t, f)
Char **t;
void (*f) __P((int));
register Char **t;
void (*f) ();
{
Char *p;
register Char *p;
while ((p = *t++) != NULL)
while (*p)
@@ -565,9 +547,9 @@ rscan(t, f)
void
trim(t)
Char **t;
register Char **t;
{
Char *p;
register Char *p;
while ((p = *t++) != NULL)
while (*p)
@@ -576,9 +558,9 @@ trim(t)
void
tglob(t)
Char **t;
register Char **t;
{
Char *p, c;
register Char *p, c;
while ((p = *t++) != NULL) {
if (*p == '~' || *p == '=')
@@ -592,7 +574,7 @@ tglob(t)
*/
if (c == '`') {
gflag |= G_CSH;
while (*p && *p != '`')
while (*p && *p != '`')
if (*p++ == '\\') {
if (*p) /* Quoted chars */
p++;
@@ -622,7 +604,7 @@ dobackp(cp, literal)
Char *cp;
bool literal;
{
Char *lp, *rp;
register Char *lp, *rp;
Char *ep, word[MAXPATHLEN];
if (pargv) {
@@ -667,8 +649,8 @@ backeval(cp, literal)
Char *cp;
bool literal;
{
int icnt, c;
Char *ip;
register int icnt, c;
register Char *ip;
struct command faket;
bool hadnl;
int pvec[2], quoted;
@@ -824,7 +806,7 @@ pword()
pnleft = MAXPATHLEN - 4;
}
int
int
Gmatch(string, pattern)
Char *string, *pattern;
{
@@ -847,13 +829,13 @@ Gmatch(string, pattern)
blkfree(blk);
return(gres == gpol);
}
}
static int
pmatch(string, pattern)
Char *string, *pattern;
register Char *string, *pattern;
{
Char stringc, patternc;
register Char stringc, patternc;
int match, negate_range;
Char rangec;
@@ -884,12 +866,11 @@ pmatch(string, pattern)
if (match)
continue;
if (rangec == '-' && *(pattern-2) != '[' && *pattern != ']') {
match = ( collate_range_cmp(stringc, *pattern & TRIM) <= 0
&& collate_range_cmp(*(pattern-2) & TRIM, stringc) <= 0
);
match = (stringc <= (*pattern & TRIM) &&
(*(pattern-2) & TRIM) <= stringc);
pattern++;
}
else
else
match = (stringc == (rangec & TRIM));
}
if (rangec == 0)
@@ -910,7 +891,7 @@ void
Gcat(s1, s2)
Char *s1, *s2;
{
Char *p, *q;
register Char *p, *q;
int n;
for (p = s1; *p++;)
@@ -934,7 +915,7 @@ Gcat(s1, s2)
#ifdef FILEC
int
sortscmp(a, b)
const ptr_t a, b;
register const ptr_t a, b;
{
#if defined(NLS) && !defined(NOSTRCOLL)
char buf[2048];
+9 -9
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: hist.c,v 1.2.8.1 1997/08/24 21:41:34 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -56,8 +56,8 @@ void
savehist(sp)
struct wordent *sp;
{
struct Hist *hp, *np;
int histlen = 0;
register struct Hist *hp, *np;
register int histlen = 0;
Char *cp;
/* throw away null lines */
@@ -65,7 +65,7 @@ savehist(sp)
return;
cp = value(STRhistory);
if (*cp) {
Char *p = cp;
register Char *p = cp;
while (*p) {
if (!Isdigit(*p)) {
@@ -86,10 +86,10 @@ savehist(sp)
struct Hist *
enthist(event, lp, docopy)
int event;
struct wordent *lp;
register struct wordent *lp;
bool docopy;
{
struct Hist *np;
register struct Hist *np;
np = (struct Hist *) xmalloc((size_t) sizeof(*np));
np->Hnum = np->Href = event;
@@ -109,7 +109,7 @@ enthist(event, lp, docopy)
static void
hfree(hp)
struct Hist *hp;
register struct Hist *hp;
{
freelex(&hp->Hlex);
@@ -127,7 +127,7 @@ dohist(v, t)
if (getn(value(STRhistory)) == 0)
return;
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
while (*++v && **v == '-') {
Char *vp = *v;
@@ -177,7 +177,7 @@ dohist1(hp, np, rflg, hflg)
static void
phist(hp, hflg)
struct Hist *hp;
register struct Hist *hp;
int hflg;
{
if (hflg == 0)
+50 -50
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: lex.c,v 1.4 1995/08/10 05:13:42 ache Exp $
* $Id$
*/
#ifndef lint
@@ -142,9 +142,9 @@ static Char getCtmp;
int
lex(hp)
struct wordent *hp;
register struct wordent *hp;
{
struct wordent *wdp;
register struct wordent *wdp;
int c;
btell(&lineloc);
@@ -165,7 +165,7 @@ lex(hp)
* be ready and rarin to go even if it is interrupted.
*/
do {
struct wordent *new;
register struct wordent *new;
new = (struct wordent *) xmalloc((size_t) sizeof(*wdp));
new->word = 0;
@@ -184,7 +184,7 @@ prlex(fp, sp0)
FILE *fp;
struct wordent *sp0;
{
struct wordent *sp = sp0->next;
register struct wordent *sp = sp0->next;
for (;;) {
(void) fprintf(fp, "%s", vis_str(sp->word));
@@ -198,15 +198,15 @@ prlex(fp, sp0)
void
copylex(hp, fp)
struct wordent *hp;
struct wordent *fp;
register struct wordent *hp;
register struct wordent *fp;
{
struct wordent *wdp;
register struct wordent *wdp;
wdp = hp;
fp = fp->next;
do {
struct wordent *new;
register struct wordent *new;
new = (struct wordent *) xmalloc((size_t) sizeof(*wdp));
new->prev = wdp;
@@ -221,9 +221,9 @@ copylex(hp, fp)
void
freelex(vp)
struct wordent *vp;
register struct wordent *vp;
{
struct wordent *fp;
register struct wordent *fp;
while (vp->next != vp) {
fp = vp->next;
@@ -237,11 +237,11 @@ freelex(vp)
static Char *
word()
{
Char c, c1;
Char *wp;
register Char c, c1;
register Char *wp;
Char wbuf[BUFSIZ];
bool dolflg;
int i;
register bool dolflg;
register int i;
wp = wbuf;
i = BUFSIZ - 4;
@@ -358,9 +358,9 @@ ret:
static int
getC1(flag)
int flag;
register int flag;
{
Char c;
register Char c;
while (1) {
if ((c = peekc) != '\0') {
@@ -416,9 +416,9 @@ getC1(flag)
static void
getdol()
{
Char *np, *ep;
register Char *np, *ep;
Char name[4 * MAXVARLEN + 1];
int c;
register int c;
int sc;
bool special = 0, toolong;
@@ -575,12 +575,12 @@ getdol()
int delimcnt = 2;
int delim = getC(0);
*np++ = delim;
if (!delim || letter(delim)
|| Isdigit(delim) || any(" \t\n", delim)) {
seterror(ERR_BADSUBST);
break;
}
}
while ((c = getC(0)) != (-1)) {
*np++ = c;
if(c == delim) delimcnt--;
@@ -650,9 +650,9 @@ static void
getexcl(sc)
int sc;
{
struct wordent *hp, *ip;
register struct wordent *hp, *ip;
int left, right, dol;
int c;
register int c;
if (sc == 0) {
sc = getC(0);
@@ -727,9 +727,9 @@ static struct wordent *
getsub(en)
struct wordent *en;
{
Char *cp;
register Char *cp;
int delim;
int c;
register int c;
int sc;
bool global;
Char orhsb[sizeof(rhsb) / sizeof(Char)];
@@ -872,12 +872,12 @@ dosub(sc, en, global)
struct wordent lexi;
bool didsub = 0, didone = 0;
struct wordent *hp = &lexi;
struct wordent *wdp;
int i = exclc;
register struct wordent *wdp;
register int i = exclc;
wdp = hp;
while (--i >= 0) {
struct wordent *new =
register struct wordent *new =
(struct wordent *) xcalloc(1, sizeof *wdp);
new->word = 0;
@@ -924,8 +924,8 @@ subword(cp, type, adid)
bool *adid;
{
Char wbuf[BUFSIZ];
Char *wp, *mp, *np;
int i;
register Char *wp, *mp, *np;
register int i;
*adid = 0;
switch (type) {
@@ -996,8 +996,8 @@ domod(cp, type)
Char *cp;
int type;
{
Char *wp, *xp;
int c;
register Char *wp, *xp;
register int c;
switch (type) {
@@ -1042,7 +1042,7 @@ domod(cp, type)
static int
matchs(str, pat)
Char *str, *pat;
register Char *str, *pat;
{
while (*str && *pat && *str == *pat)
str++, pat++;
@@ -1051,11 +1051,11 @@ matchs(str, pat)
static int
getsel(al, ar, dol)
int *al, *ar;
register int *al, *ar;
int dol;
{
int c = getC(0);
int i;
register int c = getC(0);
register int i;
bool first = *al < 0;
switch (c) {
@@ -1139,9 +1139,9 @@ static struct wordent *
gethent(sc)
int sc;
{
struct Hist *hp;
Char *np;
int c;
register struct Hist *hp;
register Char *np;
register int c;
int event;
bool back = 0;
@@ -1187,7 +1187,7 @@ gethent(sc)
}
np = lhsb;
event = 0;
while (!cmap(c, _ESC | _META | _QF | _QB) && !any("^$*-%{}:", c)) {
while (!cmap(c, _ESC | _META | _QF | _QB) && !any("${}:", c)) {
if (event != -1 && Isdigit(c))
event = event * 10 + c - '0';
else
@@ -1258,12 +1258,12 @@ findev(cp, anyarg)
Char *cp;
bool anyarg;
{
struct Hist *hp;
register struct Hist *hp;
for (hp = Histlist.Hnext; hp; hp = hp->Hnext) {
Char *dp;
Char *p, *q;
struct wordent *lp = hp->Hlex.next;
register Char *p, *q;
register struct wordent *lp = hp->Hlex.next;
int argno = 0;
/*
@@ -1307,7 +1307,7 @@ findev(cp, anyarg)
static void
setexclp(cp)
Char *cp;
register Char *cp;
{
if (cp && cp[0] == '\n')
return;
@@ -1325,7 +1325,7 @@ int
readc(wanteof)
bool wanteof;
{
int c;
register int c;
static sincereal;
aret = F_SEEK;
@@ -1440,10 +1440,10 @@ reread:
static int
bgetc()
{
int buf, off, c;
register int buf, off, c;
#ifdef FILEC
int numleft = 0, roomleft;
register int numleft = 0, roomleft;
Char ttyline[BUFSIZ];
#endif
char tbuf[BUFSIZ + 1];
@@ -1474,7 +1474,7 @@ bgetc()
again:
buf = (int) fseekp / BUFSIZ;
if (buf >= fblocks) {
Char **nfbuf =
register Char **nfbuf =
(Char **) xcalloc((size_t) (fblocks + 2),
sizeof(Char **));
@@ -1505,7 +1505,7 @@ again:
goto again;
}
if (c > 0)
memmove(fbuf[buf] + off, ttyline, c * sizeof(Char));
bcopy(ttyline, fbuf[buf] + off, c * sizeof(Char));
numleft = 0;
}
else {
@@ -1549,7 +1549,7 @@ again:
static void
bfree()
{
int sb, i;
register int sb, i;
if (cantell)
return;
+34 -34
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: misc.c,v 1.3 1996/09/28 14:32:01 bde Exp $
* $Id$
*/
#ifndef lint
@@ -53,8 +53,8 @@ static int renum __P((int, int));
int
any(s, c)
char *s;
int c;
register char *s;
register int c;
{
if (!s)
return (0); /* Check for nil pointer */
@@ -77,10 +77,10 @@ setzero(cp, i)
char *
strsave(s)
char *s;
register char *s;
{
char *n;
char *p;
register char *p;
if (s == NULL)
s = "";
@@ -94,7 +94,7 @@ strsave(s)
Char **
blkend(up)
Char **up;
register Char **up;
{
while (*up)
@@ -106,7 +106,7 @@ blkend(up)
void
blkpr(fp, av)
FILE *fp;
Char **av;
register Char **av;
{
for (; *av; av++) {
@@ -118,9 +118,9 @@ blkpr(fp, av)
int
blklen(av)
Char **av;
register Char **av;
{
int i = 0;
register int i = 0;
while (*av++)
i++;
@@ -130,9 +130,9 @@ blklen(av)
Char **
blkcpy(oav, bv)
Char **oav;
Char **bv;
register Char **bv;
{
Char **av = oav;
register Char **av = oav;
while ((*av++ = *bv++) != NULL)
continue;
@@ -152,7 +152,7 @@ void
blkfree(av0)
Char **av0;
{
Char **av = av0;
register Char **av = av0;
if (!av0)
return;
@@ -163,9 +163,9 @@ blkfree(av0)
Char **
saveblk(v)
Char **v;
register Char **v;
{
Char **newv =
register Char **newv =
(Char **) xcalloc((size_t) (blklen(v) + 1), sizeof(Char **));
Char **onewv = newv;
@@ -177,11 +177,11 @@ saveblk(v)
#ifdef NOTUSED
char *
strstr(s, t)
char *s, *t;
register char *s, *t;
{
do {
char *ss = s;
char *tt = t;
register char *ss = s;
register char *tt = t;
do
if (*tt == '\0')
@@ -199,7 +199,7 @@ strspl(cp, dp)
char *cp, *dp;
{
char *ep;
char *p, *q;
register char *p, *q;
if (!cp)
cp = "";
@@ -221,9 +221,9 @@ strspl(cp, dp)
Char **
blkspl(up, vp)
Char **up, **vp;
register Char **up, **vp;
{
Char **wp =
register Char **wp =
(Char **) xcalloc((size_t) (blklen(up) + blklen(vp) + 1),
sizeof(Char **));
@@ -233,7 +233,7 @@ blkspl(up, vp)
Char
lastchr(cp)
Char *cp;
register Char *cp;
{
if (!cp)
@@ -252,9 +252,9 @@ lastchr(cp)
void
closem()
{
int f, flimit;
register int f;
for (f = 0, flimit = getdtablesize(); f < flimit; f++)
for (f = 0; f < NOFILE; f++)
if (f != SHIN && f != SHOUT && f != SHERR && f != OLDSTD &&
f != FSHTTY)
(void) close(f);
@@ -277,7 +277,7 @@ donefds()
*/
int
dmove(i, j)
int i, j;
register int i, j;
{
if (i == j || i < 0)
@@ -296,7 +296,7 @@ dmove(i, j)
int
dcopy(i, j)
int i, j;
register int i, j;
{
if (i == j || i < 0 || (j < 0 && i > 2))
@@ -311,9 +311,9 @@ dcopy(i, j)
static int
renum(i, j)
int i, j;
register int i, j;
{
int k = dup(i);
register int k = dup(i);
if (k < 0)
return (-1);
@@ -334,10 +334,10 @@ renum(i, j)
*/
void
lshift(v, c)
Char **v;
int c;
register Char **v;
register int c;
{
Char **u;
register Char **u;
for (u = v; *u && --c >= 0; u++)
xfree((ptr_t) *u);
@@ -363,7 +363,7 @@ number(cp)
Char **
copyblk(v)
Char **v;
register Char **v;
{
Char **nv = (Char **) xcalloc((size_t) (blklen(v) + 1), sizeof(Char **));
@@ -373,7 +373,7 @@ copyblk(v)
#ifndef SHORT_STRINGS
char *
strend(cp)
char *cp;
register char *cp;
{
if (!cp)
return (cp);
@@ -388,7 +388,7 @@ Char *
strip(cp)
Char *cp;
{
Char *dp = cp;
register Char *dp = cp;
if (!cp)
return (cp);
@@ -408,7 +408,7 @@ udvar(name)
int
prefix(sub, str)
Char *sub, *str;
register Char *sub, *str;
{
for (;;) {
+37 -37
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: parse.c,v 1.3 1995/05/30 00:06:37 rgrimes Exp $
* $Id$
*/
#ifndef lint
@@ -52,19 +52,19 @@ static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93";
static void asyntax __P((struct wordent *, struct wordent *));
static void asyn0 __P((struct wordent *, struct wordent *));
static void asyn3 __P((struct wordent *, struct wordent *));
static struct wordent
static struct wordent
*freenod __P((struct wordent *, struct wordent *));
static struct command
static struct command
*syn0 __P((struct wordent *, struct wordent *, int));
static struct command
static struct command
*syn1 __P((struct wordent *, struct wordent *, int));
static struct command
static struct command
*syn1a __P((struct wordent *, struct wordent *, int));
static struct command
static struct command
*syn1b __P((struct wordent *, struct wordent *, int));
static struct command
static struct command
*syn2 __P((struct wordent *, struct wordent *, int));
static struct command
static struct command
*syn3 __P((struct wordent *, struct wordent *, int));
#define ALEFT 21 /* max of 20 alias expansions */
@@ -79,7 +79,7 @@ static int aleft;
extern int hleft;
void
alias(lex)
struct wordent *lex;
register struct wordent *lex;
{
jmp_buf osetexit;
@@ -99,7 +99,7 @@ alias(lex)
static void
asyntax(p1, p2)
struct wordent *p1, *p2;
register struct wordent *p1, *p2;
{
while (p1 != p2)
if (any(";&\n", p1->word[0]))
@@ -113,10 +113,10 @@ asyntax(p1, p2)
static void
asyn0(p1, p2)
struct wordent *p1;
struct wordent *p2;
register struct wordent *p2;
{
struct wordent *p;
int l = 0;
register struct wordent *p;
register int l = 0;
for (p = p1; p != p2; p = p->next)
switch (p->word[0]) {
@@ -153,11 +153,11 @@ asyn0(p1, p2)
static void
asyn3(p1, p2)
struct wordent *p1;
struct wordent *p2;
register struct wordent *p2;
{
struct varent *ap;
register struct varent *ap;
struct wordent alout;
bool redid;
register bool redid;
if (p1 == p2)
return;
@@ -203,9 +203,9 @@ asyn3(p1, p2)
static struct wordent *
freenod(p1, p2)
struct wordent *p1, *p2;
register struct wordent *p1, *p2;
{
struct wordent *retp = p1->prev;
register struct wordent *retp = p1->prev;
while (p1 != p2) {
xfree((ptr_t) p1->word);
@@ -229,7 +229,7 @@ freenod(p1, p2)
*/
struct command *
syntax(p1, p2, flags)
struct wordent *p1, *p2;
register struct wordent *p1, *p2;
int flags;
{
@@ -251,8 +251,8 @@ syn0(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p;
struct command *t, *t1;
register struct wordent *p;
register struct command *t, *t1;
int l;
l = 0;
@@ -319,8 +319,8 @@ syn1(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p;
struct command *t;
register struct wordent *p;
register struct command *t;
int l;
l = 0;
@@ -360,9 +360,9 @@ syn1a(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p;
struct command *t;
int l = 0;
register struct wordent *p;
register struct command *t;
register int l = 0;
for (p = p1; p != p2; p = p->next)
switch (p->word[0]) {
@@ -401,9 +401,9 @@ syn1b(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p;
struct command *t;
int l = 0;
register struct wordent *p;
register struct command *t;
register int l = 0;
for (p = p1; p != p2; p = p->next)
switch (p->word[0]) {
@@ -441,9 +441,9 @@ syn2(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p, *pn;
struct command *t;
int l = 0;
register struct wordent *p, *pn;
register struct command *t;
register int l = 0;
int f;
for (p = p1; p != p2; p = p->next)
@@ -492,10 +492,10 @@ syn3(p1, p2, flags)
struct wordent *p1, *p2;
int flags;
{
struct wordent *p;
register struct wordent *p;
struct wordent *lp, *rp;
struct command *t;
int l;
register struct command *t;
register int l;
Char **av;
int n, c;
bool specp = 0;
@@ -668,9 +668,9 @@ again:
void
freesyn(t)
struct command *t;
register struct command *t;
{
Char **v;
register Char **v;
if (t == 0)
return;
+2 -2
View File
@@ -1,4 +1,4 @@
/*-
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
* $Id: pathnames.h,v 1.2 1994/09/24 02:54:12 davidg Exp $
* $Id$
*/
#define _PATH_BIN "/bin"
+53 -55
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: proc.c,v 1.2.8.2 1998/01/31 17:06:15 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -82,11 +82,10 @@ void
pchild(notused)
int notused;
{
struct process *pp;
struct process *fp;
int pid;
register struct process *pp;
register struct process *fp;
register int pid;
extern int insource;
int save_errno = errno;
union wait w;
int jobflags;
struct rusage ru;
@@ -102,7 +101,6 @@ loop:
goto loop;
}
pnoprocesses = pid == -1;
errno = save_errno;
return;
}
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
@@ -203,9 +201,9 @@ found:
void
pnote()
{
struct process *pp;
register struct process *pp;
int flags;
int omask;
sigset_t omask;
neednote = 0;
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) {
@@ -227,8 +225,8 @@ pnote()
void
pwait()
{
struct process *fp, *pp;
int omask;
register struct process *fp, *pp;
sigset_t omask;
/*
* Here's where dead procs get flushed.
@@ -255,11 +253,11 @@ pwait()
*/
void
pjwait(pp)
struct process *pp;
register struct process *pp;
{
struct process *fp;
register struct process *fp;
int jobflags, reason;
int omask;
sigset_t omask;
while (pp->p_pid != pp->p_jobid)
pp = pp->p_friends;
@@ -347,8 +345,8 @@ dowait(v, t)
Char **v;
struct command *t;
{
struct process *pp;
int omask;
register struct process *pp;
sigset_t omask;
pjobs++;
omask = sigblock(sigmask(SIGCHLD));
@@ -356,7 +354,7 @@ loop:
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
pp->p_flags & PRUNNING) {
(void) sigpause(0);
(void) sigpause((sigset_t) 0);
goto loop;
}
(void) sigsetmask(omask);
@@ -369,7 +367,7 @@ loop:
static void
pflushall()
{
struct process *pp;
register struct process *pp;
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next)
if (pp->p_pid)
@@ -383,10 +381,10 @@ pflushall()
*/
static void
pflush(pp)
struct process *pp;
register struct process *pp;
{
struct process *np;
int idx;
register struct process *np;
register int idx;
if (pp->p_pid == 0) {
(void) fprintf(csherr, "BUG: process flushed twice");
@@ -417,7 +415,7 @@ pflush(pp)
*/
static void
pclrcurr(pp)
struct process *pp;
register struct process *pp;
{
if (pp == pcurrent)
@@ -445,9 +443,9 @@ static Char *cmdp;
void
palloc(pid, t)
int pid;
struct command *t;
register struct command *t;
{
struct process *pp;
register struct process *pp;
int i;
pp = (struct process *) xcalloc(1, (size_t) sizeof(struct process));
@@ -511,7 +509,7 @@ palloc(pid, t)
static void
padd(t)
struct command *t;
register struct command *t;
{
Char **argp;
@@ -572,7 +570,7 @@ static void
pads(cp)
Char *cp;
{
int i;
register int i;
/*
* Avoid the Quoted Space alias hack! Reported by:
@@ -628,7 +626,7 @@ prestjob()
void
pendjob()
{
struct process *pp, *tp;
register struct process *pp, *tp;
if (pcurrjob && (pcurrjob->p_flags & (PFOREGND | PSTOPPED)) == 0) {
pp = pcurrjob;
@@ -650,10 +648,10 @@ pendjob()
*/
static int
pprint(pp, flag)
struct process *pp;
register struct process *pp;
bool flag;
{
int status, reason;
register status, reason;
struct process *tp;
int jobflags, pstatus;
bool hadnl = 1; /* did we just have a newline */
@@ -816,13 +814,13 @@ prcomd:
static void
ptprint(tp)
struct process *tp;
register struct process *tp;
{
struct timeval tetime, diff;
static struct timeval ztime;
struct rusage ru;
static struct rusage zru;
struct process *pp = tp;
register struct process *pp = tp;
ru = zru;
tetime = ztime;
@@ -844,8 +842,8 @@ dojobs(v, t)
Char **v;
struct command *t;
{
struct process *pp;
int flag = NUMBER | NAME | REASON;
register struct process *pp;
register int flag = NUMBER | NAME | REASON;
int i;
if (chkstop)
@@ -874,7 +872,7 @@ dofg(v, t)
Char **v;
struct command *t;
{
struct process *pp;
register struct process *pp;
okpcntl();
++v;
@@ -894,7 +892,7 @@ dofg1(v, t)
Char **v;
struct command *t;
{
struct process *pp;
register struct process *pp;
okpcntl();
pp = pfind(v[0]);
@@ -911,7 +909,7 @@ dobg(v, t)
Char **v;
struct command *t;
{
struct process *pp;
register struct process *pp;
okpcntl();
++v;
@@ -930,7 +928,7 @@ dobg1(v, t)
Char **v;
struct command *t;
{
struct process *pp;
register struct process *pp;
pp = pfind(v[0]);
pstart(pp, 0);
@@ -957,8 +955,8 @@ dokill(v, t)
Char **v;
struct command *t;
{
int signum = SIGTERM;
char *name;
register int signum = SIGTERM;
register char *name;
v++;
if (v[0] && v[0][0] == '-') {
@@ -1000,10 +998,10 @@ pkill(v, signum)
Char **v;
int signum;
{
struct process *pp, *np;
int jobflags = 0;
register struct process *pp, *np;
register int jobflags = 0;
int pid, err1 = 0;
int omask;
sigset_t omask;
Char *cp;
omask = sigmask(SIGCHLD);
@@ -1083,11 +1081,11 @@ cont:
*/
void
pstart(pp, foregnd)
struct process *pp;
register struct process *pp;
int foregnd;
{
struct process *np;
int omask;
register struct process *np;
sigset_t omask;
long jobflags = 0;
omask = sigblock(sigmask(SIGCHLD));
@@ -1117,7 +1115,7 @@ void
panystop(neednl)
bool neednl;
{
struct process *pp;
register struct process *pp;
chkstop = 2;
for (pp = proclist.p_next; pp; pp = pp->p_next)
@@ -1129,7 +1127,7 @@ struct process *
pfind(cp)
Char *cp;
{
struct process *pp, *np;
register struct process *pp, *np;
if (cp == 0 || cp[1] == 0 || eq(cp, STRcent2) || eq(cp, STRcentplus)) {
if (pcurrent == NULL)
@@ -1153,7 +1151,7 @@ pfind(cp)
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_pid == pp->p_jobid) {
if (cp[1] == '?') {
Char *dp;
register Char *dp;
for (dp = pp->p_command; *dp; dp++) {
if (*dp != cp[2])
@@ -1171,7 +1169,7 @@ pfind(cp)
}
if (np)
return (np);
stderror(ERR_NAME | (cp[1] == '?' ? ERR_JOBPAT : ERR_NOSUCHJOB));
stderror(ERR_NAME | cp[1] == '?' ? ERR_JOBPAT : ERR_NOSUCHJOB);
/* NOTREACHED */
return (0);
}
@@ -1182,10 +1180,10 @@ pfind(cp)
*/
static struct process *
pgetcurr(pp)
struct process *pp;
register struct process *pp;
{
struct process *np;
struct process *xp = NULL;
register struct process *np;
register struct process *xp = NULL;
for (np = proclist.p_next; np; np = np->p_next)
if (np != pcurrent && np != pp && np->p_pid &&
@@ -1207,7 +1205,7 @@ donotify(v, t)
Char **v;
struct command *t;
{
struct process *pp;
register struct process *pp;
pp = pfind(*++v);
pp->p_flags |= PNOTIFY;
@@ -1230,10 +1228,10 @@ pfork(t, wanttty)
struct command *t; /* command we are forking for */
int wanttty;
{
int pid;
register int pid;
bool ignint = 0;
int pgrp;
int omask;
sigset_t omask;
/*
* A child will be uninterruptible only under very special conditions.
@@ -1330,7 +1328,7 @@ void
pgetty(wanttty, pgrp)
int wanttty, pgrp;
{
int omask = 0;
sigset_t omask = 0;
/*
* christos: I am blocking the tty signals till I've set things
+15 -15
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sem.c,v 1.3.6.1 1997/08/24 21:41:38 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -62,7 +62,7 @@ static void chkclob __P((char *));
void
execute(t, wanttty, pipein, pipeout)
struct command *t;
register struct command *t;
int wanttty, *pipein, *pipeout;
{
bool forked = 0;
@@ -70,9 +70,9 @@ execute(t, wanttty, pipein, pipeout)
int pid = 0;
int pv[2];
static int csigmask;
static sigset_t csigmask;
static int ocsigmask;
static sigset_t ocsigmask;
static int onosigchld = 0;
static int nosigchld = 0;
@@ -226,7 +226,7 @@ execute(t, wanttty, pipein, pipeout)
else {
int ochild, osetintr, ohaderr, odidfds;
int oSHIN, oSHOUT, oSHERR, oOLDSTD, otpgrp;
int omask;
sigset_t omask;
/*
* Prepare for the vfork by saving everything that the child
@@ -438,7 +438,7 @@ execute(t, wanttty, pipein, pipeout)
}
/*
* Fall through for all breaks from switch
*
*
* If there will be no more executions of this command, flush all file
* descriptors. Places that turn on the F_REPEAT bit are responsible for
* doing donefds after the last re-execution
@@ -451,7 +451,7 @@ static void
vffree(i)
int i;
{
Char **v;
register Char **v;
if ((v = gargv) != NULL) {
gargv = 0;
@@ -476,12 +476,12 @@ int i;
*
* I don't know what is best to do. I think that Ambiguous is better
* than restructuring the command vector, because the user can get
* unexpected results. In any case, the command vector restructuring
* unexpected results. In any case, the command vector restructuring
* code is present and the user can choose it by setting noambiguous
*/
static Char *
splicepipe(t, cp)
struct command *t;
register struct command *t;
Char *cp; /* word after < or > */
{
Char *blk[2];
@@ -524,12 +524,12 @@ splicepipe(t, cp)
*/
static void
doio(t, pipein, pipeout)
struct command *t;
register struct command *t;
int *pipein, *pipeout;
{
int fd;
Char *cp;
int flags = t->t_dflg;
register int fd;
register Char *cp;
register int flags = t->t_dflg;
if (didfds || (flags & F_REPEAT))
return;
@@ -620,7 +620,7 @@ doio(t, pipein, pipeout)
void
mypipe(pv)
int *pv;
register int *pv;
{
if (pipe(pv) < 0)
@@ -635,7 +635,7 @@ oops:
static void
chkclob(cp)
char *cp;
register char *cp;
{
struct stat stb;
+47 -49
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: set.c,v 1.4.2.1 1997/08/24 21:41:38 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -47,7 +47,6 @@ static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
#else
# include <varargs.h>
#endif
#include <unistd.h>
#include "csh.h"
#include "extern.h"
@@ -76,7 +75,7 @@ doset(v, t)
Char **v;
struct command *t;
{
Char *p;
register Char *p;
Char *vp, op;
Char **vecp;
bool hadsub;
@@ -117,7 +116,7 @@ doset(v, t)
if (op && op != '=')
stderror(ERR_NAME | ERR_SYNTAX);
if (eq(p, STRLparen)) {
Char **e = v;
register Char **e = v;
if (hadsub)
stderror(ERR_NAME | ERR_SYNTAX);
@@ -144,7 +143,7 @@ doset(v, t)
dohash(NULL, NULL);
}
else if (eq(vp, STRhistchars)) {
Char *pn = value(STRhistchars);
register Char *pn = value(STRhistchars);
HIST = *pn++;
HISTSUB = *pn;
@@ -159,7 +158,7 @@ doset(v, t)
else if (eq(vp, STRterm))
Setenv(STRTERM, value(vp));
else if (eq(vp, STRhome)) {
Char *cp;
register Char *cp;
cp = Strsave(value(vp)); /* get the old value back */
@@ -185,8 +184,8 @@ doset(v, t)
static Char *
getinx(cp, ip)
Char *cp;
int *ip;
register Char *cp;
register int *ip;
{
*ip = 0;
@@ -204,7 +203,7 @@ asx(vp, subscr, p)
int subscr;
Char *p;
{
struct varent *v = getvx(vp, subscr);
register struct varent *v = getvx(vp, subscr);
xfree((ptr_t) v->vec[subscr - 1]);
v->vec[subscr - 1] = globone(p, G_APPEND);
@@ -215,7 +214,7 @@ getvx(vp, subscr)
Char *vp;
int subscr;
{
struct varent *v = adrof(vp);
register struct varent *v = adrof(vp);
if (v == 0)
udvar(vp);
@@ -230,7 +229,7 @@ dolet(v, t)
Char **v;
struct command *t;
{
Char *p;
register Char *p;
Char *vp, c, op;
bool hadsub;
int subscr;
@@ -315,7 +314,7 @@ static Char *
xset(cp, vp)
Char *cp, ***vp;
{
Char *dp;
register Char *dp;
if (*cp) {
dp = Strsave(cp);
@@ -333,9 +332,9 @@ operate(op, vp, p)
{
Char opr[2];
Char *vec[5];
Char **v = vec;
register Char **v = vec;
Char **vecp = v;
int i;
register int i;
if (op != '=') {
if (*vp)
@@ -358,7 +357,7 @@ static Char *putp;
Char *
putn(n)
int n;
register int n;
{
int num;
static Char number[15];
@@ -391,7 +390,7 @@ putn(n)
static void
putn1(n)
int n;
register int n;
{
if (n > 9)
putn1(n / 10);
@@ -400,9 +399,9 @@ putn1(n)
int
getn(cp)
Char *cp;
register Char *cp;
{
int n;
register int n;
int sign;
sign = 0;
@@ -427,7 +426,7 @@ value1(var, head)
Char *var;
struct varent *head;
{
struct varent *vp;
register struct varent *vp;
vp = adrof1(var, head);
return (vp == 0 || vp->vec[0] == 0 ? STRNULL : vp->vec[0]);
@@ -436,9 +435,9 @@ value1(var, head)
static struct varent *
madrof(pat, vp)
Char *pat;
struct varent *vp;
register struct varent *vp;
{
struct varent *vp1;
register struct varent *vp1;
for (; vp; vp = vp->v_right) {
if (vp->v_left && (vp1 = madrof(pat, vp->v_left)))
@@ -451,10 +450,10 @@ madrof(pat, vp)
struct varent *
adrof1(name, v)
Char *name;
struct varent *v;
register Char *name;
register struct varent *v;
{
int cmp;
register cmp;
v = v->v_left;
while (v && ((cmp = *name - *v->v_name) ||
@@ -473,7 +472,7 @@ void
set(var, val)
Char *var, *val;
{
Char **vec = (Char **) xmalloc((size_t) (2 * sizeof(Char **)));
register Char **vec = (Char **) xmalloc((size_t) (2 * sizeof(Char **)));
vec[0] = val;
vec[1] = 0;
@@ -485,7 +484,7 @@ set1(var, vec, head)
Char *var, **vec;
struct varent *head;
{
Char **oldv = vec;
register Char **oldv = vec;
gflag = 0;
tglob(oldv);
@@ -506,10 +505,10 @@ set1(var, vec, head)
void
setq(name, vec, p)
Char *name, **vec;
struct varent *p;
register struct varent *p;
{
struct varent *c;
int f;
register struct varent *c;
register f;
f = 0; /* tree hangs off the header's left link */
while ((c = p->v_link[f]) != NULL) {
@@ -552,11 +551,11 @@ unset(v, t)
void
unset1(v, head)
Char *v[];
register Char *v[];
struct varent *head;
{
struct varent *vp;
int cnt;
register struct varent *vp;
register int cnt;
while (*++v) {
cnt = 0;
@@ -571,7 +570,7 @@ void
unsetv(var)
Char *var;
{
struct varent *vp;
register struct varent *vp;
if ((vp = adrof1(var, &shvhed)) == 0)
udvar(var);
@@ -580,10 +579,10 @@ unsetv(var)
static void
unsetv1(p)
struct varent *p;
register struct varent *p;
{
struct varent *c, *pp;
int f;
register struct varent *c, *pp;
register f;
/*
* Free associated memory first to avoid complications.
@@ -634,8 +633,8 @@ shift(v, t)
Char **v;
struct command *t;
{
struct varent *argv;
Char *name;
register struct varent *argv;
register Char *name;
v++;
name = *v;
@@ -665,8 +664,7 @@ exportpath(val)
"Warning: ridiculously long PATH truncated\n");
break;
}
if (**val != '/' && (euid == 0 || uid == 0) &&
(intact || (intty && isatty(SHOUT))))
if ((**val != '/' || **val == '\0') && (euid == 0 || uid == 0))
(void) fprintf(csherr,
"Warning: exported path contains relative components.\n");
(void) Strcat(exppath, *val++);
@@ -718,16 +716,16 @@ rright(p)
*/
static void
balance(p, f, d)
struct varent *p;
int f, d;
register struct varent *p;
register int f, d;
{
struct varent *pp;
register struct varent *pp;
#ifndef lint
struct varent *t; /* used by the rotate macros */
register struct varent *t; /* used by the rotate macros */
#endif
int ff;
register ff;
/*
* Ok, from here on, p is the node we're operating on; pp is it's parent; f
@@ -813,13 +811,13 @@ balance(p, f, d)
void
plist(p)
struct varent *p;
register struct varent *p;
{
struct varent *c;
int len;
register struct varent *c;
register len;
if (setintr)
(void) sigsetmask(sigblock(0) & ~sigmask(SIGINT));
(void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
for (;;) {
while (p->v_left)
+40 -40
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: str.c,v 1.3 1995/05/30 00:06:39 rgrimes Exp $
* $Id$
*/
#ifndef lint
@@ -59,10 +59,10 @@ static char sccsid[] = "@(#)str.c 8.1 (Berkeley) 5/31/93";
Char **
blk2short(src)
char **src;
register char **src;
{
size_t n;
Char **sdst, **dst;
register Char **sdst, **dst;
/*
* Count
@@ -79,10 +79,10 @@ blk2short(src)
char **
short2blk(src)
Char **src;
register Char **src;
{
size_t n;
char **sdst, **dst;
register char **sdst, **dst;
/*
* Count
@@ -99,11 +99,11 @@ short2blk(src)
Char *
str2short(src)
char *src;
register char *src;
{
static Char *sdst;
static size_t dstsize = 0;
Char *dst, *edst;
register Char *dst, *edst;
if (src == NULL)
return (NULL);
@@ -131,11 +131,11 @@ str2short(src)
char *
short2str(src)
Char *src;
register Char *src;
{
static char *sdst = NULL;
static size_t dstsize = 0;
char *dst, *edst;
register char *dst, *edst;
if (src == NULL)
return (NULL);
@@ -162,9 +162,9 @@ short2str(src)
Char *
s_strcpy(dst, src)
Char *dst, *src;
register Char *dst, *src;
{
Char *sdst;
register Char *sdst;
sdst = dst;
while ((*dst++ = *src++) != '\0')
@@ -174,10 +174,10 @@ s_strcpy(dst, src)
Char *
s_strncpy(dst, src, n)
Char *dst, *src;
size_t n;
register Char *dst, *src;
register size_t n;
{
Char *sdst;
register Char *sdst;
if (n == 0)
return(dst);
@@ -195,9 +195,9 @@ s_strncpy(dst, src, n)
Char *
s_strcat(dst, src)
Char *dst, *src;
register Char *dst, *src;
{
short *sdst;
register short *sdst;
sdst = dst;
while (*dst++)
@@ -211,10 +211,10 @@ s_strcat(dst, src)
#ifdef NOTUSED
Char *
s_strncat(dst, src, n)
Char *dst, *src;
size_t n;
register Char *dst, *src;
register size_t n;
{
Char *sdst;
register Char *sdst;
if (n == 0)
return (dst);
@@ -239,7 +239,7 @@ s_strncat(dst, src, n)
Char *
s_strchr(str, ch)
Char *str;
register Char *str;
int ch;
{
do
@@ -251,10 +251,10 @@ s_strchr(str, ch)
Char *
s_strrchr(str, ch)
Char *str;
register Char *str;
int ch;
{
Char *rstr;
register Char *rstr;
rstr = NULL;
do
@@ -266,9 +266,9 @@ s_strrchr(str, ch)
size_t
s_strlen(str)
Char *str;
register Char *str;
{
size_t n;
register size_t n;
for (n = 0; *str++; n++)
continue;
@@ -277,7 +277,7 @@ s_strlen(str)
int
s_strcmp(str1, str2)
Char *str1, *str2;
register Char *str1, *str2;
{
for (; *str1 && *str1 == *str2; str1++, str2++)
continue;
@@ -298,8 +298,8 @@ s_strcmp(str1, str2)
int
s_strncmp(str1, str2, n)
Char *str1, *str2;
size_t n;
register Char *str1, *str2;
register size_t n;
{
if (n == 0)
return (0);
@@ -327,10 +327,10 @@ s_strncmp(str1, str2, n)
Char *
s_strsave(s)
Char *s;
register Char *s;
{
Char *n;
Char *p;
register Char *p;
if (s == 0)
s = STRNULL;
@@ -347,7 +347,7 @@ s_strspl(cp, dp)
Char *cp, *dp;
{
Char *ep;
Char *p, *q;
register Char *p, *q;
if (!cp)
cp = STRNULL;
@@ -368,7 +368,7 @@ s_strspl(cp, dp)
Char *
s_strend(cp)
Char *cp;
register Char *cp;
{
if (!cp)
return (cp);
@@ -379,11 +379,11 @@ s_strend(cp)
Char *
s_strstr(s, t)
Char *s, *t;
register Char *s, *t;
{
do {
Char *ss = s;
Char *tt = t;
register Char *ss = s;
register Char *tt = t;
do
if (*tt == '\0')
@@ -396,11 +396,11 @@ s_strstr(s, t)
char *
short2qstr(src)
Char *src;
register Char *src;
{
static char *sdst = NULL;
static size_t dstsize = 0;
char *dst, *edst;
register char *dst, *edst;
if (src == NULL)
return (NULL);
@@ -449,21 +449,21 @@ vis_str(cp)
if (cp == NULL)
return (NULL);
for (dp = cp; *dp++;)
continue;
n = ((dp - cp) << 2) + 1; /* 4 times + NULL */
if (dstsize < n) {
sdst = (char *) (dstsize ?
sdst = (char *) (dstsize ?
xrealloc(sdst, (size_t) n * sizeof(char)) :
xmalloc((size_t) n * sizeof(char)));
dstsize = n;
}
/*
/*
* XXX: When we are in AsciiOnly we want all characters >= 0200 to
* be encoded, but currently there is no way in vis to do that.
*/
(void) strvis(sdst, short2str(cp), VIS_NOSLASH);
return (sdst);
}
+13 -13
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: time.c,v 1.5 1995/05/30 00:06:40 rgrimes Exp $
* $Id$
*/
#ifndef lint
@@ -92,7 +92,7 @@ donice(v, t)
Char **v;
struct command *t;
{
Char *cp;
register Char *cp;
int nval = 0;
v++, cp = *v++;
@@ -105,7 +105,7 @@ donice(v, t)
void
ruadd(ru, ru2)
struct rusage *ru, *ru2;
register struct rusage *ru, *ru2;
{
tvadd(&ru->ru_utime, &ru2->ru_utime);
tvadd(&ru->ru_stime, &ru2->ru_stime);
@@ -129,17 +129,17 @@ ruadd(ru, ru2)
void
prusage(r0, r1, e, b)
struct rusage *r0, *r1;
register struct rusage *r0, *r1;
struct timeval *e, *b;
{
time_t t =
register time_t t =
(r1->ru_utime.tv_sec - r0->ru_utime.tv_sec) * 100 +
(r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 10000 +
(r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 100 +
(r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 10000;
char *cp;
long i;
struct varent *vp = adrof(STRtime);
register char *cp;
register long i;
register struct varent *vp = adrof(STRtime);
int ms =
(e->tv_sec - b->tv_sec) * 100 + (e->tv_usec - b->tv_usec) / 10000;
@@ -180,7 +180,7 @@ prusage(r0, r1, e, b)
break;
case 'X': /* (average) shared text size */
(void) fprintf(cshout, "%ld", t == 0 ? 0L :
(void) fprintf(cshout, "%ld", t == 0 ? 0L :
(r1->ru_ixrss - r0->ru_ixrss) / t);
break;
@@ -246,7 +246,7 @@ pdeltat(t1, t0)
struct timeval td;
tvsub(&td, t1, t0);
(void) fprintf(cshout, "%ld.%01ld", td.tv_sec, td.tv_usec / 100000L);
(void) fprintf(cshout, "%d.%01d", td.tv_sec, td.tv_usec / 100000);
}
void
@@ -256,7 +256,7 @@ tvadd(tsum, t0)
tsum->tv_sec += t0->tv_sec;
tsum->tv_usec += t0->tv_usec;
if (tsum->tv_usec >= 1000000)
if (tsum->tv_usec > 1000000)
tsum->tv_sec++, tsum->tv_usec -= 1000000;
}
@@ -277,7 +277,7 @@ void
psecs(l)
long l;
{
int i;
register int i;
i = l / 3600;
if (i) {
@@ -298,7 +298,7 @@ void
pcsecs(l) /* PWP: print mm:ss.dd, l is in sec*100 */
long l;
{
int i;
register int i;
i = l / 360000;
if (i) {
+2 -3
View File
@@ -1,9 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.2 1994/09/24 02:54:33 davidg Exp $
# $Id$
PROG= date
SRCS= date.c netdate.c vary.c
CFLAGS+=-Wall
SRCS= date.c netdate.c
DPADD= ${LIBUTIL}
LDADD= -lutil
+21 -113
View File
@@ -32,8 +32,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\" $Id: date.1,v 1.8.2.8 1998/06/30 06:42:44 charnier Exp $
.\" @(#)date.1 8.2 (Berkeley) 11/17/93
.\" $Id$
.\"
.Dd November 17, 1993
.Dt DATE 1
@@ -43,14 +43,12 @@
.Nd display or set date and time
.Sh SYNOPSIS
.Nm date
.Op Fl nu
.Op Fl d Ar dst
.Op Fl r Ar seconds
.Op Fl t Ar minutes_west
.Op Fl v Ns Ar [+|-]val Ns Op ymwdHM
.Ar ...
.Op Fl f Ar fmt Ar date | [[[[yy]mm]dd]HH]MM[\&.ss]
.Op Fl nu
.Op Cm + Ns Ar format
.Op [yy[mm[dd[hh]]]]mm[\&.ss]
.Sh DESCRIPTION
.Nm Date
displays the current date and time when invoked without arguments.
@@ -69,14 +67,6 @@ to
.Xr gettimeofday 2
will return a non-zero
.Ql tz_dsttime .
.It Fl f
Use
.Ar fmt
as the format string to parse the date provided rather than using
the default
.Ar [[[[yy]mm]dd]HH]MM[.ss]
format. Parsing is done using
.Xr strptime 3 .
.It Fl n
The utility
.Xr timed 8
@@ -84,12 +74,12 @@ is used to synchronize the clocks on groups of machines.
By default, if
.Xr timed
is running,
.Nm
.Nm date
will set the time on all of the machines in the local group.
The
.Fl n
option stops
.Nm
.Nm date
from setting the time for other than the current machine.
.It Fl r
Print out the date and time in
@@ -107,40 +97,6 @@ by future calls to
Display or set the date in
.Tn UCT
(universal) time.
.It Fl v
Adjust the minute, hour, month day, week day, month or year according to
.Ar val .
If
.Ar val
is preceded with a plus or minus sign, the date is adjusted forwards
or backwards according to the remaining string, otherwise the relevant
part of the date is set. The date can be adjusted as many times as
required using these flags. Flags are processed in the order given.
.Pp
Minutes are in the range 0-59, hours are in the range 1-12, month days
are in the range 1-31, week days are in the range 0-6 (Sun-Sat), months
are in the range 1-12 (Jan-Dec) and years are in the range 80-38 or
1980-2038.
.Pp
If
.Ar val
is numeric, one of either
.Ar y ,
.Ar m ,
.Ar w ,
.Ar d ,
.Ar H
or
.Ar M
must be used to specify which part of the date is to be adjusted.
.Pp
The week day or month may be specified using a name rather than a
number. If a name is used with the plus (or minus) sign, the date
will be put forwards (or backwards) to the next (previous) date that
matches the given week day or month. This will not adjust the date
if the given week day or month is the same as the current one.
.Pp
Refer to the examples below for further details.
.El
.Pp
An operand with a leading plus (``+'') sign signals a user-defined format
@@ -149,11 +105,9 @@ The format string may contain any of the conversion specifications described
in the
.Xr strftime 3
manual page, as well as any arbitrary text.
A <newline> character is always output after the characters specified by
the format string.
The format string for the default display is:
.Bd -literal -offset indent
``+%+''
``%a %b %e %H:%M:%S %Z %Y%n''.
.Ed
.Pp
If an operand does not have a leading plus sign, it is interpreted as
@@ -162,18 +116,18 @@ The canonical representation for setting the date and time is:
.Pp
.Bl -tag -width Ds -compact -offset indent
.It Ar yy
Year in abbreviated form (e.g. 89 for 1989, 06 for 2006).
Year in abbreviated form (.e.g 89 for 1989).
.It Ar mm
Numeric month.
A number from 1 to 12.
.It Ar dd
Day, a number from 1 to 31.
.It Ar HH
.It Ar hh
Hour, a number from 0 to 23.
.It Ar MM
.It Ar mm
Minutes, a number from 0 to 59.
.It Ar .ss
Seconds, a number from 0 to 61 (59 plus a maximum of two leap seconds).
Seconds, a number from 0 to 61 (59 plus a a maximum of two leap seconds).
.El
.Pp
Everything but the minutes is optional.
@@ -183,51 +137,17 @@ and years are handled automatically.
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
date "+DATE: 19%y-%m-%d%nTIME: %H:%M:%S"
date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S%n''
.Ed
.Pp
will display:
.Bd -literal -offset indent
DATE: 1987-11-21
DATE: 11/21/87
TIME: 13:36:16
.Ed
.Pp
The command:
.Bd -literal -offset indent
date -v1m -v+1y
.Ed
.Pp
will display:
.Bd -literal -offset indent
Sun Jan 4 03:15:24 GMT 1998
.Ed
.Pp
(where it is currently Mon Aug 4 04:15:24 BST 1997).
.Pp
The command:
.Bd -literal -offset indent
date -v1d -v3m -v0y -v-1d
.Ed
.Pp
will display the last day of February in the year 2000:
.Bd -literal -offset indent
Tue Feb 29 03:18:00 GMT 2000
.Ed
.Pp
The command:
.Bd -literal -offset indent
date -v1d -v+1m -v-1d -v-fri
.Ed
.Pp
will display the last Friday of the month:
.Bd -literal -offset indent
Fri Aug 29 04:31:11 BST 1997
.Ed
.Pp
(where it is currently Mon Aug 4 04:31:11 BST 1997).
.Pp
The command:
.Bd -literal -offset indent
date 8506131627
.Ed
.Pp
@@ -242,18 +162,12 @@ date 1432
sets the time to
.Li "2:32 PM" ,
without modifying the date.
.Sh ENVIRONMENT
The execution of
.Nm
is affected by the following environment variables:
.Sh ENVIRONMENTAL VARIABLES
The following environment variables affect the execution of
.Nm date :
.Bl -tag -width Ds
.It Ev TZ
The timezone to use when displaying dates.
The normal format is a pathname relative to
.Pa /usr/share/zoneinfo .
For example, the command
.Dq TZ=America/Los_Angeles date
displays the current time in California.
See
.Xr environ 7
for more information.
@@ -261,14 +175,13 @@ for more information.
.Sh FILES
.Bl -tag -width /var/log/messages -compact
.It Pa /var/log/wtmp
a record of date resets and time changes
A record of date resets and time changes.
.It Pa /var/log/messages
a record of the user setting the time
A record of the user setting the time.
.El
.Sh SEE ALSO
.Xr gettimeofday 2 ,
.Xr strftime 3 ,
.Xr strptime 3 ,
.Xr utmp 5 ,
.Xr timed 8
.Rs
@@ -285,14 +198,14 @@ Occasionally, when
synchronizes the time on many hosts, the setting of a new time value may
require more than a few seconds.
On these occasions,
.Nm
.Nm date
prints:
.Ql Network time being set .
The message
.Ql Communication error with timed
occurs when the communication
between
.Nm
.Nm date
and
.Xr timed
fails.
@@ -313,11 +226,6 @@ will be running on
.Tn GMT .
.Sh STANDARDS
The
.Nm
.Nm date
command is expected to be compatible with
.St -p1003.2 .
.Sh HISTORY
A
.Nm
command appeared in
.At v1 .
+80 -124
View File
@@ -30,17 +30,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: date.c,v 1.7.2.6 1997/10/03 12:54:30 danny Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1985, 1987, 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
static char sccsid[] = "@(#)date.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include <sys/param.h>
@@ -54,15 +54,13 @@ static char const sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <locale.h>
#include "extern.h"
#include "vary.h"
time_t tval;
int retval, nflag;
static void setthetime __P((const char *, const char *));
static void setthetime __P((char *));
static void badformat __P((void));
static void usage __P((void));
@@ -78,28 +76,13 @@ main(argc, argv)
struct timezone tz;
int ch, rflag;
char *format, buf[1024];
char *endptr, *fmt;
int set_timezone;
struct vary *v;
const struct vary *badv;
struct tm lt;
v = NULL;
fmt = NULL;
(void) setlocale(LC_TIME, "");
tz.tz_dsttime = tz.tz_minuteswest = 0;
rflag = 0;
set_timezone = 0;
while ((ch = getopt(argc, argv, "d:f:nr:t:uv:")) != -1)
while ((ch = getopt(argc, argv, "d:nr:ut:")) != EOF)
switch((char)ch) {
case 'd': /* daylight savings time */
tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
if (endptr == optarg || *endptr != '\0')
usage();
set_timezone = 1;
break;
case 'f':
fmt = optarg;
tz.tz_dsttime = atoi(optarg) ? 1 : 0;
break;
case 'n': /* don't set network */
nflag = 1;
@@ -108,19 +91,16 @@ main(argc, argv)
rflag = 1;
tval = atol(optarg);
break;
case 't': /* minutes west of GMT */
/* error check; don't allow "PST" */
tz.tz_minuteswest = strtol(optarg, &endptr, 10);
if (endptr == optarg || *endptr != '\0')
usage();
set_timezone = 1;
break;
case 'u': /* do everything in GMT */
(void)setenv("TZ", "GMT0", 1);
break;
case 'v':
v = vary_append(v, optarg);
break;
case 't': /* minutes west of GMT */
/* error check; don't allow "PST" */
if (isdigit(*optarg)) {
tz.tz_minuteswest = atoi(optarg);
break;
}
/* FALLTHROUGH */
default:
usage();
}
@@ -129,15 +109,16 @@ main(argc, argv)
/*
* If -d or -t, set the timezone or daylight savings time; this
* doesn't belong here; the kernel should not know about either.
* doesn't belong here, there kernel should not know about either.
*/
if (set_timezone && settimeofday((struct timeval *)NULL, &tz))
err(1, "settimeofday (timezone)");
if ((tz.tz_minuteswest || tz.tz_dsttime) &&
settimeofday(NULL, &tz))
err(1, "settimeofday");
if (!rflag && time(&tval) == -1)
err(1, "time");
format = "%+";
format = "%a %b %e %H:%M:%S %Z %Y\n";
/* allow the operands in any order */
if (*argv && **argv == '+') {
@@ -146,117 +127,93 @@ main(argc, argv)
}
if (*argv) {
setthetime(fmt, *argv);
setthetime(*argv);
++argv;
} else if (fmt != NULL)
usage();
}
if (*argv && **argv == '+')
format = *argv + 1;
lt = *localtime(&tval);
badv = vary_apply(v, &lt);
if (badv) {
fprintf(stderr, "%s: Cannot apply date adjustment\n",
badv->arg);
vary_destroy(v);
usage();
}
vary_destroy(v);
(void)strftime(buf, sizeof(buf), format, &lt);
(void)printf("%s\n", buf);
(void)strftime(buf, sizeof(buf), format, localtime(&tval));
(void)printf("%s", buf);
exit(retval);
}
#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
void
setthetime(fmt, p)
const char *fmt;
register const char *p;
setthetime(p)
register char *p;
{
register struct tm *lt;
struct timeval tv;
const char *dot, *t;
char *dot, *t;
if (fmt != NULL) {
lt = localtime(&tval);
t = strptime(p, fmt, lt);
if (t == NULL) {
fprintf(stderr, "Failed conversion of ``%s''"
" using format ``%s''\n", p, fmt);
lt = localtime(&tval);
return;
} else if (*t != '\0')
fprintf(stderr, "Warning: Ignoring %ld extraneous"
" characters in date string (%s)\n",
(long) strlen(t), t);
} else {
for (t = p, dot = NULL; *t; ++t) {
if (isdigit(*t))
continue;
if (*t == '.' && dot == NULL) {
dot = t;
continue;
}
badformat();
for (t = p, dot = NULL; *t; ++t) {
if (isdigit(*t))
continue;
if (*t == '.' && dot == NULL) {
dot = t;
continue;
}
badformat();
}
lt = localtime(&tval);
lt = localtime(&tval);
if (dot != NULL) { /* .ss */
dot++; /* *dot++ = '\0'; */
if (strlen(dot) != 2)
badformat();
lt->tm_sec = ATOI2(dot);
if (lt->tm_sec > 61)
badformat();
} else
lt->tm_sec = 0;
/* if p has a ".ss" field then let's pretend it's not there */
switch (strlen(p) - ((dot != NULL) ? 3 : 0)) {
case 10: /* yy */
lt->tm_year = ATOI2(p);
if (lt->tm_year < 69) /* hack for 2000 ;-} */
lt->tm_year += 100;
/* FALLTHROUGH */
case 8: /* mm */
lt->tm_mon = ATOI2(p);
if (lt->tm_mon > 12)
badformat();
--lt->tm_mon; /* time struct is 0 - 11 */
/* FALLTHROUGH */
case 6: /* dd */
lt->tm_mday = ATOI2(p);
if (lt->tm_mday > 31)
badformat();
/* FALLTHROUGH */
case 4: /* HH */
lt->tm_hour = ATOI2(p);
if (lt->tm_hour > 23)
badformat();
/* FALLTHROUGH */
case 2: /* MM */
lt->tm_min = ATOI2(p);
if (lt->tm_min > 59)
badformat();
break;
default:
if (dot != NULL) { /* .ss */
*dot++ = '\0';
if (strlen(dot) != 2)
badformat();
}
lt->tm_sec = ATOI2(dot);
if (lt->tm_sec > 61)
badformat();
} else
lt->tm_sec = 0;
switch (strlen(p)) {
case 10: /* yy */
lt->tm_year = ATOI2(p);
if (lt->tm_year < 69) /* hack for 2000 ;-} */
lt->tm_year += 100;
/* FALLTHROUGH */
case 8: /* mm */
lt->tm_mon = ATOI2(p);
if (lt->tm_mon > 12)
badformat();
--lt->tm_mon; /* time struct is 0 - 11 */
/* FALLTHROUGH */
case 6: /* dd */
lt->tm_mday = ATOI2(p);
if (lt->tm_mday > 31)
badformat();
/* FALLTHROUGH */
case 4: /* hh */
lt->tm_hour = ATOI2(p);
if (lt->tm_hour > 23)
badformat();
/* FALLTHROUGH */
case 2: /* mm */
lt->tm_min = ATOI2(p);
if (lt->tm_min > 59)
badformat();
break;
default:
badformat();
}
/* convert broken-down time to GMT clock time */
if ((tval = mktime(lt)) == -1)
errx(1, "nonexistent time");
badformat();
/* set the time */
if (nflag || netsettime(tval)) {
logwtmp("|", "date", "");
tv.tv_sec = tval;
tv.tv_usec = 0;
if (settimeofday(&tv, (struct timezone *)NULL))
err(1, "settimeofday (timeval)");
if (settimeofday(&tv, NULL)) {
perror("date: settimeofday");
exit(1);
}
logwtmp("{", "date", "");
}
@@ -275,9 +232,8 @@ badformat()
static void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: date [-nu] [-d dst] [-r seconds] [-t west] "
"[-v[+|-]val[ymwdHM]] ... ",
" [-f fmt date | [[[[yy]mm]dd]HH]MM[.ss]] [+format]");
(void)fprintf(stderr,
"usage: date [-nu] [-d dst] [-r seconds] [-t west] [+format]\n");
(void)fprintf(stderr, " [yy[mm[dd[hh]]]]mm[.ss]]\n");
exit(1);
}
+4 -5
View File
@@ -30,11 +30,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: netdate.c,v 1.3.6.1 1997/03/10 19:51:16 guido Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)netdate.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)netdate.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include <sys/param.h>
@@ -116,8 +116,7 @@ netsettime(tval)
warn("gethostname");
goto bad;
}
(void)strncpy(msg.tsp_name, hostname, sizeof(msg.tsp_name) - 1);
msg.tsp_name[sizeof(msg.tsp_name) - 1] = '\0';
(void)strncpy(msg.tsp_name, hostname, sizeof(hostname));
msg.tsp_seq = htons((u_short)0);
msg.tsp_time.tv_sec = htonl((u_long)tval);
msg.tsp_time.tv_usec = htonl((u_long)0);
@@ -170,7 +169,7 @@ loop:
(void)close(s);
return (0);
default:
warnx("wrong ack received from timed: %s",
warnx("wrong ack received from timed: %s",
tsptype[msg.tsp_type]);
timed_ack = -1;
break;
-412
View File
@@ -1,412 +0,0 @@
/*-
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*
* $Id$
*/
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include "vary.h"
struct trans {
int val;
char *str;
};
static struct trans trans_mon[] = {
{ 1, "january" }, { 2, "february" }, { 3, "march" }, { 4, "april" },
{ 6, "june" }, { 7, "july" }, { 8, "august" }, { 9, "september" },
{ 10, "october" }, { 11, "november" }, { 12, "december" },
{ -1, NULL }
};
static struct trans trans_wday[] = {
{ 0, "sunday" }, { 1, "monday" }, { 2, "tuesday" }, { 3, "wednesday" },
{ 4, "thursday" }, { 5, "friday" }, { 6, "saturday" },
{ -1, NULL }
};
static char digits[] = "0123456789";
static int
trans(const struct trans t[], const char *arg)
{
int f;
for (f = 0; t[f].val != -1; f++)
if (!strncasecmp(t[f].str, arg, 3) ||
!strncasecmp(t[f].str, arg, strlen(t[f].str)))
return t[f].val;
return -1;
}
struct vary *
vary_append(struct vary *v, char *arg)
{
struct vary *result, **nextp;
if (v) {
result = v;
while (v->next)
v = v->next;
nextp = &v->next;
} else
nextp = &result;
*nextp = (struct vary *)malloc(sizeof(struct vary));
(*nextp)->arg = arg;
(*nextp)->next = NULL;
return result;
}
static int mdays[12] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static int
daysinmonth(const struct tm *t)
{
int year;
year = t->tm_year + 1900;
if (t->tm_mon == 1)
if (!(year % 400))
return 29;
else if (!(year % 100))
return 28;
else if (!(year % 4))
return 29;
else
return 28;
else if (t->tm_mon >= 0 && t->tm_mon < 12)
return mdays[t->tm_mon];
return 0;
}
static int
adjyear(struct tm *t, char type, int val)
{
switch (type) {
case '+':
t->tm_year += val;
break;
case '-':
t->tm_year -= val;
break;
default:
t->tm_year = val;
if (t->tm_year < 69)
t->tm_year += 100; /* as per date.c */
else if (t->tm_year > 1900)
t->tm_year -= 1900; /* struct tm holds years since 1900 */
break;
}
return mktime(t) != -1;
}
static int
adjmon(struct tm *t, char type, int val, int istext)
{
if (val < 0)
return 0;
switch (type) {
case '+':
if (istext)
if (val <= t->tm_mon)
val += 11 - t->tm_mon; /* early next year */
else
val -= t->tm_mon + 1; /* later this year */
if (!adjyear(t, '+', (t->tm_mon + val) / 12))
return 0;
val %= 12;
t->tm_mon += val;
if (t->tm_mon > 11)
t->tm_mon -= 12;
break;
case '-':
if (istext)
if (val-1 > t->tm_mon)
val = 13 - val + t->tm_mon; /* later last year */
else
val = t->tm_mon - val + 1; /* early this year */
if (!adjyear(t, '-', val / 12))
return 0;
val %= 12;
if (val > t->tm_mon) {
if (!adjyear(t, '-', 1))
return 0;
val -= 12;
}
t->tm_mon -= val;
break;
default:
if (val > 12 || val < 1)
return 0;
t->tm_mon = --val;
}
return mktime(t) != -1;
}
static int
adjday(struct tm *t, char type, int val)
{
int mdays;
switch (type) {
case '+':
while (val) {
mdays = daysinmonth(t);
if (val > mdays - t->tm_mday) {
val -= mdays - t->tm_mday + 1;
t->tm_mday = 1;
if (!adjmon(t, '+', 1, 0))
return 0;
} else {
t->tm_mday += val;
val = 0;
}
}
break;
case '-':
while (val)
if (val >= t->tm_mday) {
val -= t->tm_mday;
t->tm_mday = 1;
if (!adjmon(t, '-', 1, 0))
return 0;
t->tm_mday = daysinmonth(t);
} else {
t->tm_mday -= val;
val = 0;
}
break;
default:
if (val > 0 && val <= daysinmonth(t))
t->tm_mday = val;
else
return 0;
break;
}
return mktime(t) != -1;
}
static int
adjwday(struct tm *t, char type, int val, int istext)
{
if (val < 0)
return 0;
switch (type) {
case '+':
if (istext)
if (val < t->tm_wday)
val = 7 - t->tm_wday + val; /* early next week */
else
val -= t->tm_wday; /* later this week */
else
val *= 7; /* "-W +5" == "5 weeks in the future" */
return adjday(t, '+', val);
case '-':
if (istext)
if (val > t->tm_wday)
val = 7 - val + t->tm_wday; /* later last week */
else
val = t->tm_wday - val; /* early this week */
else
val *= 7; /* "-W -5" == "5 weeks ago" */
return adjday(t, '-', val);
default:
if (val < t->tm_wday)
return adjday(t, '-', t->tm_wday - val);
else if (val > 6)
return 0;
else if (val > t->tm_wday)
return adjday(t, '+', val - t->tm_wday);
}
return 1;
}
static int
adjhour(struct tm *t, char type, int val)
{
if (val < 0)
return 0;
switch (type) {
case '+':
if (!adjday(t, '+', (t->tm_hour + val) / 24))
return 0;
val %= 24;
t->tm_hour += val;
if (t->tm_hour > 23)
t->tm_hour -= 24;
break;
case '-':
if (!adjday(t, '-', val / 24))
return 0;
val %= 24;
if (val > t->tm_hour) {
if (!adjday(t, '-', 1))
return 0;
val -= 24;
}
t->tm_hour -= val;
break;
default:
if (val > 23)
return 0;
t->tm_hour = val;
}
return mktime(t) != -1;
}
static int
adjmin(struct tm *t, char type, int val)
{
if (val < 0)
return 0;
switch (type) {
case '+':
if (!adjhour(t, '+', (t->tm_min + val) / 60))
return 0;
val %= 60;
t->tm_min += val;
if (t->tm_min > 59)
t->tm_min -= 60;
break;
case '-':
if (!adjhour(t, '-', val / 60))
return 0;
val %= 60;
if (val > t->tm_min) {
if (!adjhour(t, '-', 1))
return 0;
val -= 60;
}
t->tm_min -= val;
break;
default:
if (val > 59)
return 0;
t->tm_min = val;
}
return mktime(t) != -1;
}
const struct vary *
vary_apply(const struct vary *v, struct tm *t)
{
char type;
char which;
char *arg;
int len;
int val;
for (; v; v = v->next) {
type = *v->arg;
arg = v->arg;
if (type == '+' || type == '-')
arg++;
else
type = '\0';
len = strlen(arg);
if (len < 2)
return v;
if (strspn(arg, digits) != len-1) {
val = trans(trans_wday, arg);
if (val != -1) {
if (!adjwday(t, type, val, 1))
return v;
} else {
val = trans(trans_mon, arg);
if (val != -1) {
if (!adjmon(t, type, val, 1))
return v;
} else
return v;
}
} else {
val = atoi(arg);
which = arg[len-1];
switch (which) {
case 'M':
if (!adjmin(t, type, val))
return v;
break;
case 'H':
if (!adjhour(t, type, val))
return v;
break;
case 'd':
if (!adjday(t, type, val))
return v;
break;
case 'w':
if (!adjwday(t, type, val, 0))
return v;
break;
case 'm':
if (!adjmon(t, type, val, 0))
return v;
break;
case 'y':
if (!adjyear(t, type, val))
return v;
break;
default:
return v;
}
}
}
return 0;
}
void
vary_destroy(struct vary *v)
{
struct vary *n;
while (v) {
n = v->next;
free(v);
v = n;
}
}
-36
View File
@@ -1,36 +0,0 @@
/*-
* Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
* 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
*
* $Id$
*/
struct vary {
char *arg;
struct vary *next;
};
extern struct vary *vary_append(struct vary *v, char *arg);
extern const struct vary *vary_apply(const struct vary *v, struct tm *t);
extern void vary_destroy(struct vary *v);
+3 -6
View File
@@ -34,11 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: args.c,v 1.3.8.2 1997/08/24 21:45:26 jkh Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/types.h>
@@ -100,9 +100,7 @@ jcl(argv)
in.dbsz = out.dbsz = 512;
while ((oper = *++argv) != NULL) {
if ((oper = strdup(oper)) == NULL)
errx(1, "unable to allocate space for the argument \"%s\"", *argv);
while ((oper = *++argv)) {/* JEAG */
if ((arg = strchr(oper, '=')) == NULL)
errx(1, "unknown operand %s", oper);
*arg++ = '\0';
@@ -284,7 +282,6 @@ static struct conv {
{ "oldebcdic", C_EBCDIC, C_ASCII, a2e_32V },
{ "oldibm", C_EBCDIC, C_ASCII, a2ibm_32V },
{ "osync", C_OSYNC, C_BS, NULL },
{ "sparse", C_SPARSE, 0, NULL },
{ "swab", C_SWAB, 0, NULL },
{ "sync", C_SYNC, 0, NULL },
{ "ucase", C_UCASE, C_LCASE, NULL },
+6 -6
View File
@@ -34,11 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: conv.c,v 1.3.8.1 1996/11/21 16:30:30 phk Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/param.h>
@@ -61,7 +61,7 @@ def()
int cnt;
u_char *inp, *t;
if ((t = ctab) != NULL)
if ((t = ctab))
for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp)
*inp = t[*inp];
@@ -105,6 +105,7 @@ block()
int ch, cnt, maxlen;
u_char *inp, *outp, *t;
ch = 0;
/*
* Record truncation can cross block boundaries. If currently in a
* truncation state, keep tossing characters until reach a newline.
@@ -129,10 +130,9 @@ block()
* Copy records (max cbsz size chunks) into the output buffer. The
* translation is done as we copy into the output buffer.
*/
ch = 0;
for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
maxlen = MIN(cbsz, in.dbcnt);
if ((t = ctab) != NULL)
if ((t = ctab))
for (cnt = 0;
cnt < maxlen && (ch = *inp++) != '\n'; ++cnt)
*outp++ = t[ch];
@@ -216,7 +216,7 @@ unblock()
u_char *inp, *t;
/* Translation and case conversion. */
if ((t = ctab) != NULL)
if ((t = ctab))
for (cnt = in.dbrcnt, inp = in.dbp; cnt--;)
*--inp = t[*inp];
/*
+70 -4
View File
@@ -34,11 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: conv_tab.c,v 1.3 1995/01/17 23:04:28 ache Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include <sys/types.h>
@@ -71,10 +71,76 @@ static char const sccsid[] = "@(#)conv_tab.c 8.1 (Berkeley) 5/31/93";
*/
/* Lower-case to upper-case */
u_char l2u[256];
u_char l2u[] = {
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, /* 0000 */
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017, /* 0010 */
0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, /* 0020 */
0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, /* 0030 */
0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047, /* 0040 */
0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057, /* 0050 */
0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067, /* 0060 */
0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077, /* 0070 */
0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, /* 0100 */
0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, /* 0110 */
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, /* 0120 */
0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, /* 0130 */
0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, /* 0140 */
0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, /* 0150 */
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, /* 0160 */
0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, /* 0170 */
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, /* 0200 */
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, /* 0210 */
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, /* 0220 */
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, /* 0230 */
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, /* 0240 */
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, /* 0250 */
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, /* 0260 */
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, /* 0270 */
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, /* 0300 */
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, /* 0310 */
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, /* 0320 */
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, /* 0330 */
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, /* 0340 */
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, /* 0350 */
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, /* 0360 */
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377, /* 0370 */
};
/* Upper-case to lower-case */
u_char u2l[256];
u_char u2l[] = {
0000, 0001, 0002, 0003, 0004, 0005, 0006, 0007, /* 0000 */
0010, 0011, 0012, 0013, 0014, 0015, 0016, 0017, /* 0010 */
0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, /* 0020 */
0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, /* 0030 */
0040, 0041, 0042, 0043, 0044, 0045, 0046, 0047, /* 0040 */
0050, 0051, 0052, 0053, 0054, 0055, 0056, 0057, /* 0050 */
0060, 0061, 0062, 0063, 0064, 0065, 0066, 0067, /* 0060 */
0070, 0071, 0072, 0073, 0074, 0075, 0076, 0077, /* 0070 */
0100, 0141, 0142, 0143, 0144, 0145, 0146, 0147, /* 0100 */
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, /* 0110 */
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, /* 0120 */
0170, 0171, 0172, 0133, 0134, 0135, 0136, 0137, /* 0130 */
0140, 0141, 0142, 0143, 0144, 0145, 0146, 0147, /* 0140 */
0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, /* 0150 */
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, /* 0160 */
0170, 0171, 0172, 0173, 0174, 0175, 0176, 0177, /* 0170 */
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, /* 0200 */
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, /* 0210 */
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, /* 0220 */
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, /* 0230 */
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, /* 0240 */
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, /* 0250 */
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, /* 0260 */
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, /* 0270 */
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, /* 0300 */
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, /* 0310 */
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, /* 0320 */
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, /* 0330 */
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, /* 0340 */
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, /* 0350 */
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, /* 0360 */
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377, /* 0370 */
};
/* EBCDIC to ASCII -- 32V compatible. */
u_char e2a_32V[] = {
+10 -17
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
.\" $Id: dd.1,v 1.2.8.3 1998/02/15 11:04:28 jkh Exp $
.\" $Id$
.\"
.Dd January 13, 1994
.Dt DD 1
@@ -52,7 +52,7 @@ Input data is read and written in 512-byte blocks.
If input reads are short, input from multiple reads are aggregated
to form the output block.
When finished,
.Nm
.Nm dd
displays the number of complete and partial input and output blocks
and truncated input records to the standard error output.
.Pp
@@ -148,7 +148,7 @@ is one of the symbols from the following list.
The same as the
.Cm unblock
value except that characters are translated from
.Tn EBCDIC
.Tn ECBDIC
to
.Tn ASCII
before the
@@ -237,7 +237,7 @@ will be positioned past the block in which the error occurred using
Do not truncate the output file.
This will preserve any blocks in the output file not explicitly written
by
.Nm Ns .
.Nm dd .
The
.Cm notrunc
value is not supported for tapes.
@@ -250,13 +250,6 @@ regularly sized blocks to be written.
This option is incompatible with use of the
.Cm bs= Ns Ar n
block size specification.
.It Cm sparse
If one or more output blocks would consist solely of
.Tn NUL
bytes, try to seek the output file by the required space instead of
filling them with
.Tn NULs ,
resulting in a sparse file.
.It Cm swab
Swap every pair of input bytes.
If an input buffer has an odd number of bytes, the last byte will be
@@ -287,7 +280,7 @@ in an integer, respectively.
Two or more numbers may be separated by an ``x'' to indicate a product.
.Pp
When finished,
.Nm
.Nm dd
displays the number of complete and partial input and output blocks,
truncated input records and odd-length byte-swapping blocks to the
standard error output.
@@ -310,7 +303,7 @@ This means that the final output block may be shorter than the output
block size.
.Pp
If
.Nm
.Nm dd
receives a
.Dv SIGINFO
(see the ``status'' argument for
@@ -319,17 +312,17 @@ signal, the current input and output block counts will
be written to the standard error output
in the same format as the standard completion message.
If
.Nm
.Nm dd
receives a
.Dv SIGINT
signal, the current input and output block counts will
be written to the standard error output
in the same format as the standard completion message and
.Nm
.Nm dd
will exit.
.Pp
The
.Nm
.Nm dd
utility exits 0 on success and >0 if an error occurred.
.Sh SEE ALSO
.Xr cp 1 ,
@@ -337,7 +330,7 @@ utility exits 0 on success and >0 if an error occurred.
.Xr tr 1
.Sh STANDARDS
The
.Nm
.Nm dd
utility is expected to be a superset of the
.St -p1003.2
standard.
+23 -72
View File
@@ -34,17 +34,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: dd.c,v 1.5.2.4 1998/01/09 09:13:06 joerg Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1991, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/param.h>
@@ -56,7 +56,6 @@ static char const sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -75,7 +74,6 @@ IO in, out; /* input/output state */
STAT st; /* statistics */
void (*cfunc) __P((void)); /* conversion function */
u_long cpy_cnt; /* # of blocks to copy */
u_long pending = 0; /* pending seek if sparse */
u_int ddflags; /* conversion options */
u_int cbsz; /* conversion block size */
u_int files_cnt = 1; /* # of files to copy */
@@ -86,7 +84,6 @@ main(argc, argv)
int argc;
char *argv[];
{
(void)setlocale(LC_CTYPE, "");
jcl(argv);
setup();
@@ -106,7 +103,6 @@ static void
setup()
{
u_int cnt;
struct timeval tv;
if (in.name == NULL) {
in.name = "stdin";
@@ -170,7 +166,7 @@ setup()
* Truncate the output file; ignore errors because it fails on some
* kinds of output files, tapes, for example.
*/
if ((ddflags & (C_OF | C_SEEK | C_NOTRUNC)) == (C_OF | C_SEEK))
if (ddflags & (C_OF | C_SEEK | C_NOTRUNC) == (C_OF | C_SEEK))
(void)ftruncate(out.fd, (off_t)out.offset * out.dbsz);
/*
@@ -181,42 +177,27 @@ setup()
if (ddflags & (C_LCASE|C_UCASE))
if (ddflags & C_ASCII)
if (ddflags & C_LCASE) {
for (cnt = 0; cnt <= 0377; ++cnt)
for (cnt = 0; cnt < 0377; ++cnt)
if (isupper(ctab[cnt]))
ctab[cnt] = tolower(ctab[cnt]);
} else {
for (cnt = 0; cnt <= 0377; ++cnt)
for (cnt = 0; cnt < 0377; ++cnt)
if (islower(ctab[cnt]))
ctab[cnt] = toupper(ctab[cnt]);
}
else if (ddflags & C_EBCDIC)
if (ddflags & C_LCASE) {
for (cnt = 0; cnt <= 0377; ++cnt)
for (cnt = 0; cnt < 0377; ++cnt)
if (isupper(cnt))
ctab[cnt] = ctab[tolower(cnt)];
} else {
for (cnt = 0; cnt <= 0377; ++cnt)
for (cnt = 0; cnt < 0377; ++cnt)
if (islower(cnt))
ctab[cnt] = ctab[toupper(cnt)];
}
else {
else
ctab = ddflags & C_LCASE ? u2l : l2u;
if (ddflags & C_LCASE) {
for (cnt = 0; cnt <= 0377; ++cnt)
if (isupper(cnt))
ctab[cnt] = tolower(cnt);
else
ctab[cnt] = cnt;
} else {
for (cnt = 0; cnt <= 0377; ++cnt)
if (islower(cnt))
ctab[cnt] = toupper(cnt);
else
ctab[cnt] = cnt;
}
}
(void)gettimeofday(&tv, (struct timezone *)NULL);
st.start = tv.tv_sec + tv.tv_usec * 1e-6;
(void)time(&st.start); /* Statistics timestamp. */
}
static void
@@ -237,18 +218,19 @@ getfdtype(io)
static void
dd_in()
{
int n;
int flags, n;
for (;;) {
for (flags = ddflags;;) {
if (cpy_cnt && (st.in_full + st.in_part) >= cpy_cnt)
return;
/*
* Zero the buffer first if sync; If doing block operations
* Zero the buffer first if trying to recover from errors so
* lose the minimum amount of data. If doing block operations
* use spaces.
*/
if (ddflags & C_SYNC)
if (ddflags & (C_BLOCK|C_UNBLOCK))
if ((flags & (C_NOERROR|C_SYNC)) == (C_NOERROR|C_SYNC))
if (flags & (C_BLOCK|C_UNBLOCK))
memset(in.dbp, ' ', in.dbsz);
else
memset(in.dbp, 0, in.dbsz);
@@ -265,7 +247,7 @@ dd_in()
* If noerror not specified, die. POSIX requires that
* the warning message be followed by an I/O display.
*/
if (!(ddflags & C_NOERROR))
if (!(flags & C_NOERROR))
err(1, "%s", in.name);
warn("%s", in.name);
summary();
@@ -316,7 +298,7 @@ dd_in()
}
if (ddflags & C_SWAB) {
if ((n = in.dbrcnt) & 1) {
if ((n = in.dbcnt) & 1) {
++st.swab;
--n;
}
@@ -341,14 +323,11 @@ dd_close()
block_close();
else if (cfunc == unblock)
unblock_close();
if (ddflags & C_OSYNC && out.dbcnt && out.dbcnt < out.dbsz) {
if (ddflags & (C_BLOCK|C_UNBLOCK))
memset(out.dbp, ' ', out.dbsz - out.dbcnt);
else
memset(out.dbp, 0, out.dbsz - out.dbcnt);
if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) {
memset(out.dbp, 0, out.dbsz - out.dbcnt);
out.dbcnt = out.dbsz;
}
if (out.dbcnt || pending)
if (out.dbcnt)
dd_out(1);
}
@@ -357,7 +336,7 @@ dd_out(force)
int force;
{
static int warned;
int cnt, n, nw, i, sparse;
int cnt, n, nw;
u_char *outp;
/*
@@ -379,35 +358,7 @@ dd_out(force)
outp = out.db;
for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
for (cnt = n;; cnt -= nw) {
sparse = 0;
if (ddflags & C_SPARSE) {
sparse = 1; /* Is buffer sparse? */
for (i = 0; i < cnt; i++)
if (outp[i] != 0) {
sparse = 0;
break;
}
}
if (sparse && !force) {
pending += cnt;
nw = cnt;
} else {
if (pending != 0) {
if (force)
pending--;
if (lseek (out.fd, pending, SEEK_CUR) == -1)
err(2, "%s: seek error creating sparse file",
out.name);
if (force)
write(out.fd, outp, 1);
pending = 0;
}
if (cnt)
nw = write(out.fd, outp, cnt);
else
return;
}
nw = write(out.fd, outp, cnt);
if (nw <= 0) {
if (nw == 0)
errx(1, "%s: end of device", out.name);
+3 -4
View File
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)dd.h 8.3 (Berkeley) 4/2/94
* $Id: dd.h,v 1.2.8.2 1998/02/11 02:24:40 asami Exp $
* $Id$
*/
/* Input/output stream state. */
@@ -69,8 +69,8 @@ typedef struct {
u_long out_part; /* # of partial output blocks */
u_long trunc; /* # of truncated records */
u_long swab; /* # of odd-length swab blocks */
u_int64_t bytes; /* # of bytes written */
double start; /* start time of dd */
u_long bytes; /* # of bytes written */
time_t start; /* start time of dd */
} STAT;
/* Flags (in ddflags). */
@@ -95,4 +95,3 @@ typedef struct {
#define C_UCASE 0x40000
#define C_UNBLOCK 0x80000
#define C_OSYNC 0x100000
#define C_SPARSE 0x200000
+10 -17
View File
@@ -34,18 +34,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: misc.c,v 1.2.8.4 1998/02/15 11:04:30 jkh Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -58,14 +56,12 @@ static char const sccsid[] = "@(#)misc.c 8.3 (Berkeley) 4/2/94";
void
summary()
{
struct timeval tv;
double secs;
time_t secs;
char buf[100];
(void)gettimeofday(&tv, (struct timezone *)NULL);
secs = tv.tv_sec + tv.tv_usec * 1e-6 - st.start;
if (secs < 1e-6)
secs = 1e-6;
(void)time(&secs);
if ((secs -= st.start) == 0)
secs = 1;
/* Use snprintf(3) so that we don't reenter stdio(3). */
(void)snprintf(buf, sizeof(buf),
"%u+%u records in\n%u+%u records out\n",
@@ -82,7 +78,7 @@ summary()
(void)write(STDERR_FILENO, buf, strlen(buf));
}
(void)snprintf(buf, sizeof(buf),
"%qu bytes transferred in %.6f secs (%.0f bytes/sec)\n",
"%u bytes transferred in %u secs (%u bytes/sec)\n",
st.bytes, secs, st.bytes / secs);
(void)write(STDERR_FILENO, buf, strlen(buf));
}
@@ -92,18 +88,15 @@ void
summaryx(notused)
int notused;
{
int save_errno = errno;
summary();
errno = save_errno;
}
/* ARGSUSED */
void
terminate(sig)
int sig;
terminate(notused)
int notused;
{
/* XXX exit() shouldn't call exit() from a signal handler. */
exit(sig == 0 ? 0 : 1);
exit(0);
}
+3 -3
View File
@@ -34,11 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: position.c,v 1.2 1994/09/24 02:55:03 davidg Exp $
* $Id$
*/
#ifndef lint
static char const sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)position.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/types.h>
@@ -67,7 +67,7 @@ pos_in()
/* If not a character, pipe or tape device, try to seek on it. */
if (!(in.flags & (ISCHR|ISPIPE|ISTAPE))) {
if (lseek(in.fd, (off_t)in.offset * in.dbsz, SEEK_CUR) == -1)
if (lseek(in.fd, (off_t)(in.offset * in.dbsz), SEEK_CUR) == -1)
err(1, "%s", in.name);
return;
}
+24 -34
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)df.1 8.2 (Berkeley) 1/13/94
.\" $Id: df.1,v 1.4.2.3 1998/02/15 11:06:23 jkh Exp $
.\" $Id$
.\"
.Dd January 13, 1994
.Dt DF 1
@@ -40,7 +40,7 @@
.Nd display free disk space
.Sh SYNOPSIS
.Nm df
.Op Fl ikn
.Op Fl ink
.Op Fl t Ar type
.Op Ar file | Ar filesystem ...
.Sh DESCRIPTION
@@ -72,40 +72,31 @@ This option should be used if it is possible that one or more
filesystems are in a state such that they will not be able to provide
statistics without a long delay.
When this option is specified,
.Nm
.Nm df
will not request new statistics from the filesystems, but will respond
with the possibly stale statistics that were previously obtained.
.It Fl t
Only print out statistics for filesystems of the specified types.
More than one type may be specified in a comma separated list.
The list of filesystem types can be prefixed with
.Dq no
to specify the filesystem types for which action should
.Em not
be taken.
For example, the
.Nm
command:
.Bd -literal -offset indent
df -t nonfs,mfs
.Ed
.Pp
lists all filesystems except those of type
.Tn NFS
and
.Tn MFS .
The
.Xr sysctl 8
command can be used to find out the types of filesystems
that are available on the system:
.Bd -literal -offset indent
sysctl vfs
.Ed
The recognized types are:
ufs, nfs, mfs, lfs, msdos, fdesc, portal, kernfs, procfs, afs and isofs.
along with the aggregates:
all (the default),
local (ufs, mfs, lfs, msdos, isofs),
and misc (fdesc, portal, kernfs, procfs).
The string ``no'' may be prepending to a type to get its complement
(e.g. ``nonfs'' to get non-NFS filesystems). The first
.Fl t
option overrides the default, additional such options will add to
(or subtract from) the current set of types; e.g. either
``df -t ufs -t lfs''
or
``df -t local -t nomfs''
will display statistics for UFS and LFS filesystems.
.El
.Sh ENVIRONMENT
.Sh ENVIRONMENTAL VARIABLES
.Bl -tag -width BLOCKSIZE
.It Ev BLOCKSIZE
If the environment variable
If the environmental variable
.Ev BLOCKSIZE
is set, the block counts will be displayed in units of that size block.
.El
@@ -117,16 +108,15 @@ and
flags are ignored if a file or filesystem is specified.
.Sh SEE ALSO
.Xr quota 1 ,
.Xr statfs 2 ,
.Xr fstatfs 2 ,
.Xr getfsstat 2 ,
.Xr statfs 2 ,
.Xr getmntinfo 3 ,
.Xr fstab 5 ,
.Xr mount 8 ,
.Xr quot 8 ,
.Xr sysctl 8
.Xr quot 8
.Sh HISTORY
A
.Nm
.Nm df
command appeared in
.At v1 .
.At v6 .
+28 -29
View File
@@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: df.c,v 1.8.2.1 1996/12/13 17:15:11 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -76,32 +76,29 @@ struct typetab {
char *str;
long types;
} typetab[] = {
{"ufs", MT(MOUNT_UFS)},
{"local", MT_LOCAL},
{"all", MT_ALL},
{"nfs", MT(MOUNT_NFS)},
{"mfs", MT(MOUNT_MFS)},
{"lfs", MT(MOUNT_LFS)},
{"msdos", MT(MOUNT_MSDOS)},
{"fdesc", MT(MOUNT_FDESC)},
{"portal", MT(MOUNT_PORTAL)},
"ufs", MT(MOUNT_UFS),
"local", MT_LOCAL,
"all", MT_ALL,
"nfs", MT(MOUNT_NFS),
"mfs", MT(MOUNT_MFS),
"lfs", MT(MOUNT_LFS),
"msdos", MT(MOUNT_MSDOS),
"fdesc", MT(MOUNT_FDESC),
"portal", MT(MOUNT_PORTAL),
#if 0
/* return fsid of underlying FS */
{"lofs", MT(MOUNT_LOFS)},
{"null", MT(MOUNT_NULL)},
{"umap", MT(MOUNT_UMAP)},
"lofs", MT(MOUNT_LOFS),
"null", MT(MOUNT_NULL),
"umap", MT(MOUNT_UMAP),
#endif
{"kernfs", MT(MOUNT_KERNFS)},
{"procfs", MT(MOUNT_PROCFS)},
{"afs", MT(MOUNT_AFS)},
{"iso9660fs", MT(MOUNT_CD9660)},
{"isofs", MT(MOUNT_CD9660)},
{"cd9660", MT(MOUNT_CD9660)},
{"cdfs", MT(MOUNT_CD9660)},
{"misc", MT(MOUNT_LOFS)|MT(MOUNT_FDESC)|MT(MOUNT_PORTAL)|
MT(MOUNT_KERNFS)|MT(MOUNT_PROCFS)},
{NULL, 0}
"kernfs", MT(MOUNT_KERNFS),
"procfs", MT(MOUNT_PROCFS),
"afs", MT(MOUNT_AFS),
"iso9660fs", MT(MOUNT_CD9660),
"cdfs", MT(MOUNT_CD9660),
"misc", MT(MOUNT_LOFS)|MT(MOUNT_FDESC)|MT(MOUNT_PORTAL)|
MT(MOUNT_KERNFS)|MT(MOUNT_PROCFS),
NULL, 0
};
long addtype __P((long, char *));
@@ -127,9 +124,8 @@ main(argc, argv)
char *mntpt;
iflag = nflag = tflag = 0;
fsmask = MT_NONE;
while ((ch = getopt(argc, argv, "iknt:")) != -1)
while ((ch = getopt(argc, argv, "iknt:")) != EOF)
switch (ch) {
case 'i':
iflag = 1;
@@ -338,7 +334,7 @@ prtstat(sfsp, maxwidth)
used = inodes - sfsp->f_ffree;
(void)printf(" %7ld %7ld %5.0f%% ", used, sfsp->f_ffree,
inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0);
} else
} else
(void)printf(" ");
(void)printf(" %s\n", sfsp->f_mntonname);
}
@@ -388,7 +384,10 @@ ufs_df(file, maxwidth)
sfsp->f_blocks = sblock.fs_dsize;
sfsp->f_bfree = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag +
sblock.fs_cstotal.cs_nffree;
sfsp->f_bavail = freespace(&sblock, sblock.fs_minfree);
sfsp->f_bavail = (sblock.fs_dsize * (100 - sblock.fs_minfree) / 100) -
(sblock.fs_dsize - sfsp->f_bfree);
if (sfsp->f_bavail < 0)
sfsp->f_bavail = 0;
sfsp->f_files = sblock.fs_ncg * sblock.fs_ipg;
sfsp->f_ffree = sblock.fs_cstotal.cs_nifree;
sfsp->f_fsid.val[0] = 0;
@@ -423,7 +422,7 @@ bread(off, buf, cnt)
void
usage()
{
fprintf(stderr,
fprintf(stderr,
"usage: df [-ikn] [-t fstype] [file | file_system ...]\n");
exit(1);
}
+4 -4
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)hostname.1 8.1 (Berkeley) 5/31/93
.\" $Id: domainname.1,v 1.2.6.1 1997/08/24 21:48:26 jkh Exp $
.\" $Id$
.\"
.Dd September 18, 1994
.Dt DOMAINNAME 1
@@ -42,11 +42,11 @@
.Nm domainname
.Op Ar ypdomain
.Sh DESCRIPTION
.Nm Domainname
.Nm domainname
prints the name of the current YP/NIS domain. The super-user can
set the domain name by supplying an argument; this is usually done in the
network initialization script
.Pa /etc/rc.network ,
.Pa /etc/netstart ,
normally run at boot
time.
.Sh NOTA BENE
@@ -55,7 +55,7 @@ domain name does not necessarily have anything to do with the Domain
Name System domain name, although they are often set equal for administrative
convenience.
.Sh SEE ALSO
.Xr getdomainname 3
.Xr getdomainname 2
.Sh HISTORY
The
.Nm
+3 -22
View File
@@ -40,7 +40,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "From: @(#)hostname.c 8.1 (Berkeley) 5/31/93"; */
static const char rcsid[] =
"$Id: domainname.c,v 1.5 1995/03/19 13:28:17 joerg Exp $";
"$Id: domainname.c,v 1.3 1994/09/21 22:30:55 bde Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -51,26 +51,14 @@ static const char rcsid[] =
#include <string.h>
#include <unistd.h>
void usage __P((void));
int
main(argc,argv)
int argc;
char *argv[];
{
int ch;
char domainname[MAXHOSTNAMELEN];
char *p, domainname[MAXHOSTNAMELEN];
while ((ch = getopt(argc, argv, "")) != -1)
switch (ch) {
default:
usage();
}
argc -= optind;
argv += optind;
if (argc > 1)
usage();
argc--, argv++;
if (*argv) {
if (setdomainname(*argv, strlen(*argv)))
@@ -82,10 +70,3 @@ main(argc,argv)
}
exit(0);
}
void
usage()
{
(void)fprintf(stderr, "usage: domainname [ypdomain]\n");
exit(1);
}
+5 -7
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)echo.1 8.1 (Berkeley) 7/22/93
.\" $Id: echo.1,v 1.3 1995/08/31 17:25:54 jkh Exp $
.\" $Id$
.\"
.Dd July 22, 1993
.Dt ECHO 1
@@ -47,7 +47,7 @@
.Op "string ..."
.Sh DESCRIPTION
The
.Nm
.Nm echo
utility writes any specified operands, separated by single blank (`` '')
characters and followed by a newline (``\en'') character, to the standard
output.
@@ -55,19 +55,17 @@ output.
The following option is available:
.Bl -tag -width flag
.It Fl n
Do not print the trailing newline character. This may also be
achieved by appending `\ec' to the end of the string, as is done
by iBCS2 compatible systems.
Do not print the trailing newline character.
.El
.Pp
The
.Nm
.Nm echo
utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr printf 1
.Sh STANDARDS
The
.Nm
.Nm echo
utility is expected to be
.St -p1003.2
compatible.
+3 -9
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: echo.c,v 1.2 1994/09/24 02:55:18 davidg Exp $
* $Id$
*/
#ifndef lint
@@ -62,14 +62,8 @@ main(argc, argv)
else
nflag = 0;
while (argv[0]) {
int len = strlen(argv[0]);
if (len >= 2 && !argv[1] && argv[0][len - 2] == '\\' && argv[0][len - 1] == 'c') {
argv[0][len - 2] = '\0';
nflag = 1;
}
(void)printf("%s", argv[0]);
while (*argv) {
(void)printf("%s", *argv);
if (*++argv)
putchar(' ');
}
+7 -8
View File
@@ -1,15 +1,14 @@
# $Id: Makefile,v 1.13 1995/10/22 20:14:13 ache Exp $
# $Id: Makefile,v 1.8 1994/09/24 02:55:20 davidg Exp $
PROG= ed
SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c
LINKS= ${BINDIR}/ed ${BINDIR}/red
MLINKS= ed.1 red.1
SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c
LINKS= ${BINDIR}/ed ${BINDIR}/red
MLINKS= ed.1 red.1
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE)
DISTRIBUTION=des
.if !defined(NOCRYPT)
CFLAGS+=-DDES
LDADD+= -L${CIPHEROBJDIR} -lcipher
DPADD+= ${CIPHEROBJDIR}/libcipher.a
LDADD+= -lcrypt
DPADD+= ${LIBCRYPT}
.endif
.include <bsd.prog.mk>
+7 -19
View File
@@ -24,15 +24,11 @@
* 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.
*
* $Id$
*/
#ifndef lint
#if 0
static char * const rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp";
#else
static char * const rcsid =
"$Id: buf.c,v 1.15 1997/12/31 12:25:33 helbig Exp $";
#endif
static char *rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp";
#endif /* not lint */
#include <sys/file.h>
@@ -202,18 +198,14 @@ char sfn[15] = ""; /* scratch file name */
int
open_sbuf()
{
int fd = -1;
int u;
isbinary = newline_added = 0;
u = umask(077);
strcpy(sfn, "/tmp/ed.XXXXXX");
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
if (fd != -1)
close(fd);
perror(sfn);
strcpy(errmsg, "cannot open temp file");
if (mktemp(sfn) == NULL || (sfp = fopen(sfn, "w+")) == NULL) {
fprintf(stderr, "%s: %s\n", sfn, strerror(errno));
sprintf(errmsg, "cannot open temp file");
umask(u);
return ERR;
}
@@ -261,17 +253,13 @@ init_buffers()
{
int i = 0;
/* Read stdin one character at a time to avoid i/o contention
/* Read stdin one character at a time to avoid i/o contention
with shell escapes invoked by nonterminal input, e.g.,
ed - <<EOF
!cat
hello, world
EOF */
setbuffer(stdin, stdinbuf, 1);
/* Ensure stdout is line buffered. This avoids bogus delays
of output if stdout is piped through utilities to a terminal. */
setvbuf(stdout, NULL, _IOLBF, 0);
if (open_sbuf() < 0)
quit(2);
REQUE(&buffer_head, &buffer_head);
+3 -8
View File
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)bdes.c 5.5 (Berkeley) 6/27/91
* $Id: cbc.c,v 1.5 1995/03/19 13:28:24 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -43,6 +43,7 @@ static char *rcsid = "@(#)cbc.c,v 1.2 1994/02/01 00:34:36 alm Exp";
#endif /* not lint */
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <pwd.h>
@@ -114,7 +115,7 @@ init_des_cipher()
des_ct = des_n = 0;
/* initialize the initialization vector */
/* initialize the initialization vctor */
MEMZERO(ivec, 8);
/* intialize the padding vector */
@@ -136,8 +137,6 @@ get_des_char(fp)
des_ct = cbc_decode(des_buf, fp);
}
return (des_ct > 0) ? des_buf[des_n++] : EOF;
#else
return (getc(fp));
#endif
}
@@ -154,8 +153,6 @@ put_des_char(c, fp)
des_n = 0;
}
return (des_ct >= 0) ? (des_buf[des_n++] = c) : EOF;
#else
return (fputc(c, fp));
#endif
}
@@ -171,8 +168,6 @@ flush_des_file(fp)
des_n = 0;
}
return (des_ct >= 0 && cbc_encode(des_buf, des_n, fp) >= 0) ? 0 : EOF;
#else
return (fflush(fp));
#endif
}
+549 -446
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -25,9 +25,10 @@
* SUCH DAMAGE.
*
* @(#)ed.h,v 1.5 1994/02/01 00:34:39 alm Exp
* $Id: ed.h,v 1.8 1994/11/03 21:46:55 davidg Exp $
* $Id: ed.h,v 1.7 1994/09/24 02:55:25 davidg Exp $
*/
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
#include <errno.h>
#if defined(sun) || defined(__NetBSD__)
+5 -5
View File
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: glbl.c,v 1.3 1995/03/19 13:28:27 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -132,8 +132,8 @@ exec_global(interact, gflag)
for (; *ibufp;)
if ((status = extract_addr_range()) < 0 ||
(status = exec_command()) < 0 ||
(status > 0 && (status = display_lines(
current_addr, current_addr, status)) < 0))
status > 0 && (status = display_lines(
current_addr, current_addr, status)) < 0)
return status;
}
return 0;
@@ -158,7 +158,7 @@ set_active_node(lp)
#if defined(sun) || defined(NO_REALLOC_NULL)
if (active_list != NULL) {
#endif
if ((ts = (line_t **) realloc(active_list,
if ((ts = (line_t **) realloc(active_list,
(ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
sprintf(errmsg, "out of memory");
@@ -167,7 +167,7 @@ set_active_node(lp)
}
#if defined(sun) || defined(NO_REALLOC_NULL)
} else {
if ((ts = (line_t **) malloc((ti += MINBUFSZ) *
if ((ts = (line_t **) malloc((ti += MINBUFSZ) *
sizeof(line_t **))) == NULL) {
fprintf(stderr, "%s\n", strerror(errno));
sprintf(errmsg, "out of memory");
+6 -6
View File
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: io.c,v 1.4 1995/03/19 13:28:32 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -58,7 +58,7 @@ read_file(fn, n)
sprintf(errmsg, "cannot close input file");
return ERR;
}
fprintf(stdout, !scripted ? "%lu\n" : "", size);
fprintf(stderr, !scripted ? "%lu\n" : "", size);
return current_addr - n;
}
@@ -106,7 +106,7 @@ read_stream(fp, n)
return ERR;
if (appended && size && o_isbinary && o_newline_added)
fputs("newline inserted\n", stderr);
else if (newline_added && (!appended || (!isbinary && !o_isbinary)))
else if (newline_added && (!appended || !isbinary && !o_isbinary))
fputs("newline appended\n", stderr);
if (isbinary && newline_added && !appended)
size += 1;
@@ -128,8 +128,8 @@ get_stream_line(fp)
register int c;
register int i = 0;
while (((c = des ? get_des_char(fp) : getc(fp)) != EOF || (!feof(fp) &&
!ferror(fp))) && c != '\n') {
while (((c = des ? get_des_char(fp) : getc(fp)) != EOF || !feof(fp) &&
!ferror(fp)) && c != '\n') {
REALLOC(sbuf, sbufsz, i + 1, ERR);
if (!(sbuf[i++] = c))
isbinary = 1;
@@ -173,7 +173,7 @@ write_file(fn, mode, n, m)
sprintf(errmsg, "cannot close output file");
return ERR;
}
fprintf(stdout, !scripted ? "%lu\n" : "", size);
fprintf(stderr, !scripted ? "%lu\n" : "", size);
return n ? m - n + 1 : 0;
}
+39 -48
View File
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: main.c,v 1.6.2.1 1997/08/24 21:50:21 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -42,7 +42,7 @@ static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
* CREDITS
*
* This program is based on the editor algorithm described in
* Brian W. Kernighan and P. J. Plauger's book "Software Tools
* Brian W. Kernighan and P. J. Plauger's book "Software Tools
* in Pascal," Addison-Wesley, 1981.
*
* The buffering algorithm is attributed to Rodney Ruddock of
@@ -57,9 +57,8 @@ static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <ctype.h>
#include <locale.h>
#include <pwd.h>
#include <setjmp.h>
#include <pwd.h>
#include "ed.h"
@@ -100,6 +99,10 @@ char *dps = "*"; /* default command-line prompt */
char *usage = "usage: %s [-] [-sx] [-p string] [name]\n";
extern char errmsg[];
extern int optind;
extern char *optarg;
/* ed: line editor */
int
main(argc, argv)
@@ -108,17 +111,10 @@ main(argc, argv)
{
int c, n;
long status = 0;
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &argc;
(void) &argv;
#endif
(void)setlocale(LC_ALL, "");
red = (n = strlen(argv[0])) > 2 && argv[0][n - 3] == 'r';
top:
while ((c = getopt(argc, argv, "p:sx")) != -1)
while ((c = getopt(argc, argv, "p:sx")) != EOF)
switch(c) {
case 'p': /* set prompt */
prompt = optarg;
@@ -158,9 +154,9 @@ top:
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, signal_int);
#ifdef _POSIX_SOURCE
if ((status = sigsetjmp(env, 1)))
if (status = sigsetjmp(env, 1))
#else
if ((status = setjmp(env)))
if (status = setjmp(env))
#endif
{
fputs("\n?\n", stderr);
@@ -196,7 +192,7 @@ top:
fputs("?\n", stderr);
sprintf(errmsg, "warning: file modified");
if (!isatty(0)) {
fprintf(stderr, garrulous ?
fprintf(stderr, garrulous ?
"script, line %d: %s\n" :
"", lineno, errmsg);
quit(2);
@@ -217,7 +213,7 @@ top:
isglobal = 0;
if ((status = extract_addr_range()) >= 0 &&
(status = exec_command()) >= 0)
if (!status ||
if (!status || status &&
(status = display_lines(current_addr, current_addr,
status)) >= 0)
continue;
@@ -229,16 +225,16 @@ top:
fputs("?\n", stderr); /* give warning */
sprintf(errmsg, "warning: file modified");
if (!isatty(0)) {
fprintf(stderr, garrulous ?
"script, line %d: %s\n" :
fprintf(stderr, garrulous ?
"script, line %d: %s\n" :
"", lineno, errmsg);
quit(2);
}
break;
case FATAL:
if (!isatty(0))
fprintf(stderr, garrulous ?
"script, line %d: %s\n" : "",
fprintf(stderr, garrulous ?
"script, line %d: %s\n" : "",
lineno, errmsg);
else
fprintf(stderr, garrulous ? "%s\n" : "",
@@ -247,7 +243,7 @@ top:
default:
fputs("?\n", stderr);
if (!isatty(0)) {
fprintf(stderr, garrulous ?
fprintf(stderr, garrulous ?
"script, line %d: %s\n" : "",
lineno, errmsg);
quit(2);
@@ -260,7 +256,7 @@ top:
long first_addr, second_addr, addr_cnt;
/* extract_addr_range: get line addresses from the command buffer until an
/* extract_addr_range: get line addresses from the command buffer until an
illegal address is seen; return status */
int
extract_addr_range()
@@ -284,7 +280,7 @@ extract_addr_range()
}
#define SKIP_BLANKS() while (isspace((unsigned char)*ibufp) && *ibufp != '\n') ibufp++
#define SKIP_BLANKS() while (isspace(*ibufp) && *ibufp != '\n') ibufp++
#define MUST_BE_FIRST() \
if (!first) { sprintf(errmsg, "invalid address"); return ERR; }
@@ -309,10 +305,10 @@ next_addr()
case '^':
ibufp++;
SKIP_BLANKS();
if (isdigit((unsigned char)*ibufp)) {
if (isdigit(*ibufp)) {
STRTOL(n, ibufp);
addr += (c == '-' || c == '^') ? -n : n;
} else if (!isspace((unsigned char)c))
} else if (!isspace(c))
addr += (c == '-' || c == '^') ? -1 : 1;
break;
case '0': case '1': case '2':
@@ -494,7 +490,7 @@ exec_command()
if (addr_cnt > 0) {
sprintf(errmsg, "unexpected address");
return ERR;
} else if (!isspace((unsigned char)*ibufp)) {
} else if (!isspace(*ibufp)) {
sprintf(errmsg, "unexpected command suffix");
return ERR;
} else if ((fnp = get_filename()) == NULL)
@@ -524,7 +520,7 @@ exec_command()
if (addr_cnt > 0) {
sprintf(errmsg, "unexpected address");
return ERR;
} else if (!isspace((unsigned char)*ibufp)) {
} else if (!isspace(*ibufp)) {
sprintf(errmsg, "unexpected command suffix");
return ERR;
} else if ((fnp = get_filename()) == NULL)
@@ -548,11 +544,11 @@ exec_command()
return ERR;
else if (build_active_list(c == 'g' || c == 'G') < 0)
return ERR;
else if ((n = (c == 'G' || c == 'V')))
else if (n = (c == 'G' || c == 'V'))
GET_COMMAND_SUFFIX();
isglobal++;
if (exec_global(n, gflag) < 0)
return ERR;
return ERR;
break;
case 'h':
if (addr_cnt > 0) {
@@ -655,7 +651,7 @@ exec_command()
gflag = (modified && !scripted && c == 'q') ? EMOD : EOF;
break;
case 'r':
if (!isspace((unsigned char)*ibufp)) {
if (!isspace(*ibufp)) {
sprintf(errmsg, "unexpected command suffix");
return ERR;
} else if (addr_cnt == 0)
@@ -695,7 +691,7 @@ exec_command()
sflags |= SGR;
ibufp++;
break;
case '0': case '1': case '2': case '3': case '4':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
STRTOL(sgnum, ibufp);
sflags |= SGF;
@@ -788,7 +784,7 @@ exec_command()
gflag = EOF;
ibufp++;
}
if (!isspace((unsigned char)*ibufp)) {
if (!isspace(*ibufp)) {
sprintf(errmsg, "unexpected command suffix");
return ERR;
} else if ((fnp = get_filename()) == NULL)
@@ -806,7 +802,7 @@ exec_command()
return ERR;
}
#endif
if ((addr = write_file(*fnp ? fnp : old_filename,
if ((addr = write_file(*fnp ? fnp : old_filename,
(c == 'W') ? "a" : "w", first_addr, second_addr)) < 0)
return ERR;
else if (addr == addr_last)
@@ -844,7 +840,7 @@ exec_command()
break;
case '=':
GET_COMMAND_SUFFIX();
printf("%ld\n", addr_cnt ? second_addr : addr_last);
printf("%d\n", addr_cnt ? second_addr : addr_last);
break;
case '!':
if (addr_cnt > 0) {
@@ -892,7 +888,7 @@ check_addr_range(n, m)
}
/* get_matching_node_addr: return the address of the next line matching a
/* get_matching_node_addr: return the address of the next line matching a
pattern in a given direction. wrap around begin/end of editor buffer if
necessary */
long
@@ -906,7 +902,7 @@ get_matching_node_addr(pat, dir)
if (!pat) return ERR;
do {
if ((n = dir ? INC_MOD(n, addr_last) : DEC_MOD(n, addr_last))) {
if (n = dir ? INC_MOD(n, addr_last) : DEC_MOD(n, addr_last)) {
lp = get_addressed_line_node(n);
if ((s = get_sbuf_line(lp)) == NULL)
return ERR;
@@ -914,7 +910,7 @@ get_matching_node_addr(pat, dir)
NUL_TO_NEWLINE(s, lp->len);
if (!regexec(pat, s, 0, NULL, 0))
return n;
}
}
} while (n != current_addr);
sprintf(errmsg, "no match");
return ERR;
@@ -1152,7 +1148,7 @@ move_lines(addr)
REQUE(b2, b1->q_forw);
REQUE(a1->q_back, a2);
REQUE(b1, a1);
current_addr = addr + ((addr < first_addr) ?
current_addr = addr + ((addr < first_addr) ?
second_addr - first_addr + 1 : 0);
}
if (isglobal)
@@ -1264,7 +1260,7 @@ mark_line_node(lp, n)
line_t *lp;
int n;
{
if (!islower((unsigned char)n)) {
if (!islower(n)) {
sprintf(errmsg, "invalid mark character");
return ERR;
} else if (mark[n - 'a'] == NULL)
@@ -1279,7 +1275,7 @@ long
get_marked_node_addr(n)
int n;
{
if (!islower((unsigned char)n)) {
if (!islower(n)) {
sprintf(errmsg, "invalid mark character");
return ERR;
}
@@ -1343,7 +1339,7 @@ strip_escapes(s)
REALLOC(file, filesz, MAXPATHLEN + 1, NULL);
/* assert: no trailing escape */
while ((file[i++] = (*s == '\\') ? *++s : *s))
while (file[i++] = (*s == '\\') ? *++s : *s)
s++;
return file;
}
@@ -1355,8 +1351,7 @@ signal_hup(signo)
{
if (mutex)
sigflags |= (1 << (signo - 1));
else
handle_hup(signo);
else handle_hup(signo);
}
@@ -1366,8 +1361,7 @@ signal_int(signo)
{
if (mutex)
sigflags |= (1 << (signo - 1));
else
handle_int(signo);
else handle_int(signo);
}
@@ -1417,8 +1411,6 @@ void
handle_winch(signo)
int signo;
{
int save_errno = errno;
struct winsize ws; /* window size structure */
sigflags &= ~(1 << (signo - 1));
@@ -1426,7 +1418,6 @@ handle_winch(signo)
if (ws.ws_row > 2) rows = ws.ws_row - 2;
if (ws.ws_col > 8) cols = ws.ws_col - 8;
}
errno = save_errno;
}
+3 -3
View File
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: re.c,v 1.9 1995/03/19 13:28:36 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -39,7 +39,7 @@ extern int patlock;
char errmsg[MAXPATHLEN + 40] = "";
/* get_compiled_pattern: return pointer to compiled pattern from command
/* get_compiled_pattern: return pointer to compiled pattern from command
buffer */
pattern_t *
get_compiled_pattern()
@@ -67,7 +67,7 @@ get_compiled_pattern()
return NULL;
}
patlock = 0;
if ((n = regcomp(exp, exps, 0))) {
if (n = regcomp(exp, exps, 0)) {
regerror(n, exp, errmsg, sizeof errmsg);
free(exp);
return exp = NULL;
+6 -10
View File
@@ -1,4 +1,4 @@
/* sub.c: This file contains the substitution routines for the ed
/* sub.c: This file contains the substitution routines for the ed
line editor */
/*-
* Copyright (c) 1993 Andrew Moore, Talke Studio.
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sub.c,v 1.5 1995/03/19 13:28:38 joerg Exp $
* $Id$
*/
#ifndef lint
@@ -97,7 +97,7 @@ extract_subst_template()
;
else if (!isglobal) {
while ((n = get_tty_line()) == 0 ||
(n > 0 && ibuf[n - 1] != '\n'))
n > 0 && ibuf[n - 1] != '\n')
clearerr(stdin);
if (n < 0)
return NULL;
@@ -124,7 +124,6 @@ search_and_replace(pat, gflag, kth)
char *txt;
char *eot;
long lc;
long xa = current_addr;
int nsubs = 0;
line_t *lp;
int len;
@@ -155,10 +154,8 @@ search_and_replace(pat, gflag, kth)
} while (txt != eot);
SPL0();
nsubs++;
xa = current_addr;
}
}
current_addr = xa;
if (nsubs == 0 && !(gflag & GLB)) {
sprintf(errmsg, "no match");
return ERR;
@@ -188,7 +185,7 @@ substitute_matching_text(pat, lp, gflag, kth)
if ((txt = get_sbuf_line(lp)) == NULL)
return ERR;
if (isbinary)
if (isbinary)
NUL_TO_NEWLINE(txt, lp->len);
eot = txt + lp->len;
if (!regexec(pat, txt, SE_MAX, rm, 0)) {
@@ -213,9 +210,8 @@ substitute_matching_text(pat, lp, gflag, kth)
off += i;
}
txt += rm[0].rm_eo;
} while (*txt &&
(!changed || ((gflag & GSG) && rm[0].rm_eo)) &&
!regexec(pat, txt, SE_MAX, rm, REG_NOTBOL));
} while (*txt && (!changed || (gflag & GSG) && rm[0].rm_eo) &&
!regexec(pat, txt, SE_MAX, rm, REG_NOTBOL));
i = eot - txt;
REALLOC(rbuf, rbufsz, off + i + 2, ERR);
if (i > 0 && !rm[0].rm_eo && (gflag & GSG)) {
+2 -2
View File
@@ -1,7 +1,7 @@
# $Id: Makefile,v 1.5 1994/09/24 02:55:35 davidg Exp $
# $Id$
SHELL= /bin/sh
ED= ${.OBJDIR}/ed
ED= ../obj/ed
all: check
@:
-2
View File
@@ -1,5 +1,3 @@
# $Id$
The files in this directory with suffixes `.t', `.d', `.r' and `.err' are
used for testing ed. To run the tests, set the ED variable in the Makefile
for the path name of the program to be tested (e.g., /bin/ed), and type
-2
View File
@@ -2,8 +2,6 @@
# This script runs the .ed scripts generated by mkscripts.sh
# and compares their output against the .r files, which contain
# the correct output
#
# $Id$
PATH="/bin:/usr/bin:/usr/local/bin/:."
ED=$1
-2
View File
@@ -1,7 +1,5 @@
#!/bin/sh -
# This script generates ed test scripts (.ed) from .t files
#
# $Id$
PATH="/bin:/usr/bin:/usr/local/bin/:."
ED=$1
+10 -4
View File
@@ -1,7 +1,13 @@
# $Id: Makefile,v 1.10 1996/06/02 17:05:48 phk Exp $
# /b/source/CVS/src/bin/expr/Makefile,v 1.5 1993/06/14 19:56:06 jtc Exp
# $Id$
PROG= expr
SRCS= expr.y
YFLAGS=
PROG= expr
SRCS= expr.c
CLEANFILES+= expr.c y.tab.h
expr.c:
${YACC} -d ${.IMPSRC}
mv y.tab.c expr.c
.include <bsd.prog.mk>
+14 -14
View File
@@ -15,7 +15,7 @@
.\" must display the following acknowledgement:
.\" This product includes software developed by Winning Strategies, Inc.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission
.\" derived from this software withough specific prior written permission
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Id: expr.1,v 1.4 1996/01/29 22:53:24 mpp Exp $
.\" $Id: expr.1,v 1.2 1993/10/04 22:07:27 jtc Exp $
.\"
.Dd July 3, 1993
.Dt EXPR 1
@@ -41,40 +41,40 @@
.Ar expression
.Sh DESCRIPTION
The
.Nm
.Nm expr
utility evaluates
.Ar expression
and writes the result on standard output.
.Pp
All operators are separate arguments to the
.Nm
.Nm expr
utility.
Characters special to the command interpreter must be escaped.
.Pp
Operators are listed below in order of increasing precedence.
Operators with equal precedence are grouped within { } symbols.
Operators are listed below in order of increasing precidence.
Operators with equal precidence are grouped within { } symbols.
.Bl -tag -width indent
.It Ar expr1 Li | Ar expr2
Return the evaluation of
Returns the evaluation of
.Ar expr1
if it is neither an empty string nor zero;
otherwise, returns the evaluation of
.Ar expr2 .
.It Ar expr1 Li & Ar expr2
Return the evaluation of
Returns the evaluation of
.Ar expr1
if neither expression evaluates to an empty string or zero;
otherwise, returns zero.
.It Ar expr1 Li "{=, >, >=, <, <=, !=}" Ar expr2
Return the results of integer comparison if both arguments are integers;
Returns the results of integer comparision if both arguments are integers;
otherwise, returns the results of string comparison using the locale-specific
collation sequence.
The result of each comparison is 1 if the specified relation is true,
or 0 if the relation is false.
.It Ar expr1 Li "{+, -}" Ar expr2
Return the results of addition or subtraction of integer-valued arguments.
Returns the results of addition or subtraction of integer-valued arguments.
.It Ar expr1 Li "{*, /, %}" Ar expr2
Return the results of multiplication, integer division, or remainder of integer-valued arguments.
Returns the results of multiplication, integer division, or remainder of integer-valued arguments.
.It Ar expr1 Li : Ar expr2
The
.Dq \:
@@ -115,9 +115,9 @@ The following example returns the number of characters in variable a.
.El
.Sh DIAGNOSTICS
The
.Nm
.Nm expr
utility exits with one of the following values:
.Bl -tag -width indent -compact
.Bl -tag -width Ds -compact
.It 0
the expression is neither an empty string nor 0.
.It 1
@@ -127,6 +127,6 @@ the expression is invalid.
.El
.Sh STANDARDS
The
.Nm
.Nm expr
utility conforms to
.St -p1003.2 .
+32 -43
View File
@@ -4,7 +4,7 @@
*
* Largely rewritten by J.T. Conklin ([email protected])
*
* $Id: expr.y,v 1.10 1995/08/04 17:08:07 joerg Exp $
* $Id$
*/
#include <stdio.h>
@@ -15,7 +15,7 @@
#include <err.h>
enum valtype {
integer, numeric_string, string
integer, string
} ;
struct val {
@@ -56,6 +56,7 @@ char **av;
%left <val> '+' '-'
%left <val> '*' '/' '%'
%left <val> ':'
%left UNARY
%token <val> TOKEN
%type <val> start expr
@@ -93,7 +94,7 @@ int i;
vp = (struct val *) malloc (sizeof (*vp));
if (vp == NULL) {
errx (2, "malloc() failed");
err (2, NULL);
}
vp->type = integer;
@@ -106,26 +107,13 @@ make_str (s)
char *s;
{
struct val *vp;
int i, isint;
vp = (struct val *) malloc (sizeof (*vp));
if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
errx (2, "malloc() failed");
err (2, NULL);
}
for(i = 1, isint = isdigit(s[0]) || s[0] == '-';
isint && i < strlen(s);
i++)
{
if(!isdigit(s[i]))
isint = 0;
}
if (isint)
vp->type = numeric_string;
else
vp->type = string;
vp->type = string;
return vp;
}
@@ -134,7 +122,7 @@ void
free_value (vp)
struct val *vp;
{
if (vp->type == string || vp->type == numeric_string)
if (vp->type == string)
free (vp->u.s);
}
@@ -143,19 +131,34 @@ int
to_integer (vp)
struct val *vp;
{
char *s;
int neg;
int i;
if (vp->type == integer)
return 1;
if (vp->type == string)
return 0;
s = vp->u.s;
i = 0;
neg = (*s == '-');
if (neg)
s++;
for (;*s; s++) {
if (!isdigit (*s))
return 0;
i *= 10;
i += *s - '0';
}
/* vp->type == numeric_string, make it numeric */
i = atoi(vp->u.s);
free (vp->u.s);
vp->u.i = i;
if (neg)
i *= -1;
vp->type = integer;
vp->u.i = i;
return 1;
}
@@ -165,12 +168,12 @@ struct val *vp;
{
char *tmp;
if (vp->type == string || vp->type == numeric_string)
if (vp->type == string)
return;
tmp = malloc (25);
if (tmp == NULL) {
errx (2, "malloc() failed");
err (2, NULL);
}
sprintf (tmp, "%d", vp->u.i);
@@ -183,7 +186,6 @@ int
isstring (vp)
struct val *vp;
{
/* only TRUE if this string is not a valid integer */
return (vp->type == string);
}
@@ -191,6 +193,7 @@ struct val *vp;
int
yylex ()
{
struct val *vp;
char *p;
if (*av == NULL)
@@ -225,9 +228,7 @@ struct val *vp;
/* NOTREACHED */
}
int yyparse ();
int
void
main (argc, argv)
int argc;
char **argv;
@@ -243,7 +244,7 @@ char **argv;
else
printf ("%s\n", result->u.s);
return (is_zero_or_null (result));
exit (is_zero_or_null (result));
}
int
@@ -292,8 +293,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) == 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r = make_integer (a->u.i == b->u.i);
}
@@ -313,8 +312,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) > 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r= make_integer (a->u.i > b->u.i);
}
@@ -334,8 +331,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) < 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r = make_integer (a->u.i < b->u.i);
}
@@ -355,8 +350,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) >= 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r = make_integer (a->u.i >= b->u.i);
}
@@ -376,8 +369,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) <= 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r = make_integer (a->u.i <= b->u.i);
}
@@ -397,8 +388,6 @@ struct val *a, *b;
to_string (b);
r = make_integer (strcoll (a->u.s, b->u.s) != 0);
} else {
(void)to_integer(a);
(void)to_integer(b);
r = make_integer (a->u.i != b->u.i);
}
+8 -8
View File
@@ -29,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)hostname.1 8.2 (Berkeley) 4/28/95
.\" $Id: hostname.1,v 1.3.2.3 1998/06/30 06:43:13 charnier Exp $
.\" @(#)hostname.1 8.1 (Berkeley) 5/31/93
.\" $Id$
.\"
.Dd April 28, 1995
.Dd May 31, 1993
.Dt HOSTNAME 1
.Os BSD 4.2
.Sh NAME
@@ -41,26 +41,26 @@
.Sh SYNOPSIS
.Nm hostname
.Op Fl s
.Op Ar name-of-host
.Op Ar nameofhost
.Sh DESCRIPTION
.Nm Hostname
prints the name of the current host. The super-user can
set the hostname by supplying an argument; this is usually done in the
network initialization script
.Pa /etc/rc.network ,
.Pa /etc/netstart ,
normally run at boot
time.
.Pp
Options:
.Bl -tag -width flag
.It Fl s
Trim off any domain information from the printed
Trims off any domain information from the printed
name.
.El
.Sh SEE ALSO
.Xr gethostname 3
.Xr gethostname 2
.Sh HISTORY
The
.Nm
.Nm hostname
command appeared in
.Bx 4.2 .
+8 -18
View File
@@ -30,17 +30,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: hostname.c,v 1.2 1994/09/24 02:55:40 davidg Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1988, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
#include <sys/param.h>
@@ -51,32 +51,30 @@ static char const sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
#include <string.h>
#include <unistd.h>
void usage __P((void));
int
main(argc,argv)
int argc;
char *argv[];
{
extern int optind;
int ch, sflag;
char *p, hostname[MAXHOSTNAMELEN];
sflag = 0;
while ((ch = getopt(argc, argv, "s")) != -1)
while ((ch = getopt(argc, argv, "s")) != EOF)
switch (ch) {
case 's':
sflag = 1;
break;
case '?':
default:
usage();
(void)fprintf(stderr,
"usage: hostname [-s] [hostname]\n");
exit(1);
}
argc -= optind;
argv += optind;
if (argc > 1)
usage();
if (*argv) {
if (sethostname(*argv, strlen(*argv)))
err(1, "sethostname");
@@ -89,11 +87,3 @@ main(argc,argv)
}
exit(0);
}
void
usage()
{
(void)fprintf(stderr, "usage: hostname [-s] [name-of-host]\n");
exit(1);
}
+31 -55
View File
@@ -32,10 +32,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)kill.1 8.2 (Berkeley) 4/28/95
.\" $Id: kill.1,v 1.3.2.2 1998/05/22 10:50:26 jkoshy Exp $
.\" @(#)kill.1 8.1 (Berkeley) 5/31/93
.\" $Id$
.\"
.Dd April 28, 1995
.Dd May 31, 1993
.Dt KILL 1
.Os
.Sh NAME
@@ -43,98 +43,74 @@
.Nd terminate or signal a process
.Sh SYNOPSIS
.Nm kill
.Op Fl s Ar signal_name
.Op Fl signal_name
.Ar pid
\&...
.Nm kill
.Fl l
.Op Ar exit_status
.Nm kill
.Fl signal_name
.Op Fl signal_number
.Ar pid
\&...
.Nm kill
.Fl signal_number
.Ar pid
\&...
.Op Fl l
.Sh DESCRIPTION
The
.Nm
utility sends a signal to the processes specified by the pid operand(s).
The kill utility sends the
.Dv TERM
signal to the processes specified
by the pid operand(s).
.Pp
Only the super-user may send signals to other users' processes.
.Pp
The options are as follows:
.Pp
.Bl -tag -width Ds
.It Fl s Ar signal_name
A symbolic signal name specifying the signal to be sent instead of the
default
.Dv TERM .
.It Fl l Op Ar exit_status
If no operand is given, list the signal names; otherwise, write
the signal name corresponding to
.Ar exit_status .
.It Fl l
List the signal names.
.It Fl signal_name
A symbolic signal name specifying the signal to be sent instead of the
default
.Dv TERM .
The
.Fl l
option displays the signal names.
.It Fl signal_number
A non-negative decimal integer, specifying the signal to be sent instead
of the default
.Dv TERM .
.El
.Pp
The following pids have special meanings:
.Bl -tag -width Ds -compact
.It -1
If superuser, broadcast the signal to all processes; otherwise broadcast
to all processes belonging to the user.
.El
.Pp
Some of the more commonly used signals:
.Bl -tag -width Ds -compact
.It 1
HUP (hang up)
.It 2
INT (interrupt)
.It 3
QUIT (quit)
.It 6
ABRT (abort)
.It 9
KILL (non-catchable, non-ignorable kill)
.It 14
ALRM (alarm clock)
.It 15
TERM (software termination signal)
.Bd -ragged -offset indent -compact
.Bl -column XXX TERM
.It -1 -1 (super-user broadcast to all processes, or user broadcast
to user's processes)
.It 0 0 (sh(1) only, signals all members of process group)
.It 2 INT (interrupt)
.It 3 QUIT (quit)
.It 6 ABRT (abort)
.It 9 KILL (non-catchable, non-ignorable kill)
.It 14 ALRM (alarm clock)
.It 15 TERM (software termination signal)
.El
.Ed
.Pp
.Nm Kill
is a built-in to
.Xr csh 1 ;
it allows job specifiers of the form ``%...'' as arguments
so process id's are not as often used as
.Nm
.Nm kill
arguments.
See
.Xr csh 1
.Xr csh 1
for details.
.Sh SEE ALSO
.Xr csh 1 ,
.Xr killall 1 ,
.Xr ps 1 ,
.Xr kill 2 ,
.Xr sigaction 2
.Sh STANDARDS
The
.Nm
function is expected to be
.St -p1003.2
compatible.
.Xr sigvec 2
.Sh HISTORY
A
.Nm
.Nm kill
command appeared in
.At v6 .
.Sh BUGS
+31 -74
View File
@@ -34,13 +34,13 @@
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1988, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
static char sccsid[] = "@(#)kill.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
#include <ctype.h>
@@ -52,8 +52,7 @@ static char const sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
#include <string.h>
void nosig __P((char *));
void printsignals __P((FILE *));
int signame_to_signum __P((char *));
void printsig __P((FILE *));
void usage __P((void));
int
@@ -61,70 +60,48 @@ main(argc, argv)
int argc;
char *argv[];
{
const char *const *p;
int errors, numsig, pid;
char *ep;
if (argc < 2)
usage();
numsig = SIGTERM;
argc--, argv++;
if (!strcmp(*argv, "-l")) {
argc--, argv++;
if (argc > 1)
usage();
if (argc == 1) {
if (!isdigit(**argv))
usage();
numsig = strtol(*argv, &ep, 10);
if (!**argv || *ep)
errx(1, "illegal signal number: %s", *argv);
if (numsig >= 128)
numsig -= 128;
if (numsig <= 0 || numsig >= NSIG)
nosig(*argv);
printf("%s\n", sys_signame[numsig]);
exit(0);
}
printsignals(stdout);
if (!strcmp(*++argv, "-l")) {
printsig(stdout);
exit(0);
}
if (!strcmp(*argv, "-s")) {
argc--, argv++;
if (argc < 1) {
warnx("option requires an argument -- s");
usage();
}
if (strcmp(*argv, "0")) {
if ((numsig = signame_to_signum(*argv)) < 0)
nosig(*argv);
} else
numsig = 0;
argc--, argv++;
} else if (**argv == '-') {
numsig = SIGTERM;
if (**argv == '-') {
++*argv;
if (isalpha(**argv)) {
if ((numsig = signame_to_signum(*argv)) < 0)
if (!strncasecmp(*argv, "sig", 3))
*argv += 3;
for (numsig = NSIG, p = sys_signame + 1; --numsig; ++p)
if (!strcasecmp(*p, *argv)) {
numsig = p - sys_signame;
break;
}
if (!numsig)
nosig(*argv);
} else if (isdigit(**argv)) {
numsig = strtol(*argv, &ep, 10);
if (!**argv || *ep)
if (!*argv || *ep)
errx(1, "illegal signal number: %s", *argv);
if (numsig < 0 || numsig >= NSIG)
if (numsig <= 0 || numsig > NSIG)
nosig(*argv);
} else
nosig(*argv);
argc--, argv++;
++argv;
}
if (argc == 0)
if (!*argv)
usage();
for (errors = 0; argc; argc--, argv++) {
for (errors = 0; *argv; ++argv) {
pid = strtol(*argv, &ep, 10);
if (!**argv || *ep) {
if (!*argv || *ep) {
warnx("illegal process id: %s", *argv);
errors = 1;
} else if (kill(pid, numsig) == -1) {
@@ -132,58 +109,38 @@ main(argc, argv)
errors = 1;
}
}
exit(errors);
}
int
signame_to_signum(sig)
char *sig;
{
int n;
if (!strncasecmp(sig, "sig", 3))
sig += 3;
for (n = 1; n < NSIG; n++) {
if (!strcasecmp(sys_signame[n], sig))
return (n);
}
return (-1);
}
void
nosig(name)
char *name;
{
warnx("unknown signal %s; valid signals:", name);
printsignals(stderr);
printsig(stderr);
exit(1);
}
void
printsignals(fp)
printsig(fp)
FILE *fp;
{
int n;
const char *const *p;
int cnt;
for (n = 1; n < NSIG; n++) {
(void)fprintf(fp, "%s", sys_signame[n]);
if (n == (NSIG / 2) || n == (NSIG - 1))
for (cnt = NSIG, p = sys_signame + 1; --cnt; ++p) {
(void)fprintf(fp, "%s ", *p);
if (cnt == NSIG / 2)
(void)fprintf(fp, "\n");
else
(void)fprintf(fp, " ");
}
(void)fprintf(fp, "\n");
}
void
usage()
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: kill [-s signal_name] pid ...",
" kill -l [exit_status]",
" kill -signal_name pid ...",
" kill -signal_number pid ...");
(void)fprintf(stderr, "usage: kill [-l] [-sig] pid ...\n");
exit(1);
}
+7 -7
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ln.1 8.2 (Berkeley) 12/30/93
.\" $Id: ln.1,v 1.3 1996/08/29 18:05:55 wosch Exp $
.\" $Id$
.\"
.Dd December 30, 1993
.Dt LN 1
@@ -52,7 +52,7 @@
.Op target_dir
.Sh DESCRIPTION
The
.Nm
.Nm ln
utility creates a new directory entry (linked file) which has the
same modes as the original file.
It is useful for maintaining multiple copies of a file in many places
@@ -75,7 +75,7 @@ Create a symbolic link.
.El
.Pp
By default
.Nm
.Nm ln
makes
.Em hard
links.
@@ -99,7 +99,7 @@ call may be used to read the contents of a symbolic link.
Symbolic links may span file systems and may refer to directories.
.Pp
Given one or two arguments,
.Nm
.Nm ln
creates a link to an existing file
.Ar source_file .
If
@@ -113,7 +113,7 @@ to the last component of
.Ar source_file .
.Pp
Given more than two arguments,
.Nm
.Nm ln
makes links in
.Ar target_dir
to all the named source files.
@@ -127,6 +127,6 @@ The links made will have the same name as the files being linked to.
.Xr symlink 7
.Sh HISTORY
A
.Nm
.Nm ln
command appeared in
.At v1 .
.At v6 .
+15 -13
View File
@@ -30,17 +30,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ln.c,v 1.6.2.1 1997/06/06 16:07:40 charnier Exp $
* $Id$
*/
#ifndef lint
static char const copyright[] =
static char copyright[] =
"@(#) Copyright (c) 1987, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char const sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
static char sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
#endif /* not lint */
#include <sys/param.h>
@@ -53,6 +53,7 @@ static char const sccsid[] = "@(#)ln.c 8.2 (Berkeley) 3/31/94";
#include <string.h>
#include <unistd.h>
int dirflag; /* Undocumented directory flag. */
int fflag; /* Unlink existing files. */
int sflag; /* Symbolic, not hard, link. */
/* System link call. */
@@ -71,8 +72,11 @@ main(argc, argv)
int ch, exitval;
char *sourcedir;
while ((ch = getopt(argc, argv, "fs")) != -1)
while ((ch = getopt(argc, argv, "Ffs")) != EOF)
switch (ch) {
case 'F':
dirflag = 1; /* XXX: deliberately undocumented. */
break;
case 'f':
fflag = 1;
break;
@@ -123,10 +127,9 @@ linkit(target, source, isdir)
warn("%s", target);
return (1);
}
/* Only symbolic links to directories. */
if (S_ISDIR(sb.st_mode)) {
errno = EISDIR;
warn("%s", target);
/* Only symbolic links to directories, unless -F option used. */
if (!dirflag && (sb.st_mode & S_IFMT) == S_IFDIR) {
warnx("%s: is a directory", target);
return (1);
}
}
@@ -139,9 +142,9 @@ linkit(target, source, isdir)
++p;
(void)snprintf(path, sizeof(path), "%s/%s", source, p);
source = path;
exists = !lstat(source, &sb);
exists = !stat(source, &sb);
} else
exists = !lstat(source, &sb);
exists = !stat(source, &sb);
/*
* If the file exists, and -f was specified, unlink it.
@@ -157,8 +160,7 @@ linkit(target, source, isdir)
void
usage()
{
(void)fprintf(stderr, "%s\n%s\n",
"usage: ln [-fs] file1 file2",
" ln [-fs] file ... directory");
(void)fprintf(stderr,
"usage:\tln [-fs] file1 file2\n\tln [-fs] file ... directory\n");
exit(1);
}
+34 -31
View File
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)symlink.7 8.3 (Berkeley) 3/31/94
.\" $Id: symlink.7,v 1.2.8.2 1997/06/19 01:09:09 jdp Exp $
.\" $Id$
.\"
.Dd March 31, 1994
.Dt SYMLINK 7
@@ -106,10 +106,9 @@ the system call
would return a file descriptor to the file
.Dq afile .
.Pp
There are five system calls that do not follow links, and which operate
There are four system calls that do not follow links, and which operate
on the symbolic link itself.
They are:
.Xr lchown 2 ,
.Xr lstat 2 ,
.Xr readlink 2 ,
.Xr rename 2 ,
@@ -121,22 +120,23 @@ is an alias for
.Xr unlink 2 ,
it also does not follow symbolic links.
.Pp
The owner and group of an existing symbolic link can be changed by
means of the
.Xr lchown 2
system call.
The other file attributes, such as the modification time and access
permissions, are not used by the system and cannot be changed.
Unlike other filesystem objects, symbolic links do not have an owner,
group, permissions, access and modification times, etc.
The only attributes returned from an
.Xr lstat 2
that refer to the symbolic link itself are the file type (S_IFLNK),
size, blocks, and link count (always 1).
The other attributes are filled in from the directory that contains
the link.
For portability reasons, you should be aware that other implementations
(including historic implementations of 4BSD), implement symbolic links
such that they have the same attributes as any other file.
.Pp
The
.Bx 4.4
system differs from historical 4BSD systems in that the system call
.Xr chown 2
has been changed to follow symbolic links. The
.Xr lchown 2
system call was added later when the limitations of the new
.Xr chown 2
became apparent.
has been changed to follow symbolic links.
.Ss Commands not traversing a file tree.
The second area is symbolic links, specified as command line file
name arguments, to commands which are not traversing a file tree.
@@ -200,8 +200,6 @@ option is not specified),
the
.Nm ls
command follows symbolic links named as arguments if the
.Fl H
or
.Fl L
option is specified,
or if the
@@ -209,13 +207,16 @@ or if the
.Fl d
or
.Fl l
options are not specified. (The
.Nm ls
command is the only command where the
.Fl H
and
options are not specified.
(If the
.Fl L
options affect its behavior even though it is not doing a walk of
option is specified,
.Nm ls
always follows symbolic links.
.Nm Ls
is the only command where the
.Fl L
option affects its behavior even though it is not doing a walk of
a file tree.)
.Pp
The
@@ -393,19 +394,23 @@ options.
To maintain compatibility with historic systems,
the
.Nm ls
command acts a little differently. If you do not specify the
.Fl F ,
.Fl d or
.Fl l
options,
.Nm ls
will follow symbolic links specified on the command line. If the
command never follows symbolic links unless the
.Fl L
flag is specified.
If the
.Fl L
flag is specified,
.Nm ls
follows all symbolic links,
regardless of their type,
whether specified on the command line or encountered in the tree walk.
The
.Nm ls
command does not support the
.Fl H
or
.Fl P
options.
.Sh SEE ALSO
.Xr chflags 1 ,
.Xr chgrp 1 ,
@@ -419,11 +424,9 @@ whether specified on the command line or encountered in the tree walk.
.Xr pax 1 ,
.Xr rm 1 ,
.Xr tar 1 ,
.Xr lchown 2 ,
.Xr lstat 2 ,
.Xr readlink 2 ,
.Xr rename 2 ,
.Xr symlink 2 ,
.Xr unlink 2 ,
.Xr fts 3 ,
.Xr remove 3 ,
+3 -3
View File
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cmp.c,v 1.2 1994/09/24 02:55:52 davidg Exp $
* $Id$
*/
#ifndef lint
@@ -53,14 +53,14 @@ int
namecmp(a, b)
const FTSENT *a, *b;
{
return (strcoll(a->fts_name, b->fts_name));
return (strcmp(a->fts_name, b->fts_name));
}
int
revnamecmp(a, b)
const FTSENT *a, *b;
{
return (strcoll(b->fts_name, a->fts_name));
return (strcmp(b->fts_name, a->fts_name));
}
int
+1 -3
View File
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 5/31/93
* $Id: extern.h,v 1.2 1994/09/24 02:55:52 davidg Exp $
* $Id$
*/
int acccmp __P((const FTSENT *, const FTSENT *));
@@ -49,5 +49,3 @@ void printcol __P((DISPLAY *));
void printlong __P((DISPLAY *));
void printscol __P((DISPLAY *));
void usage __P((void));
int len_octal __P((char *, int));
int prn_octal __P((char *));
+29 -90
View File
@@ -13,7 +13,7 @@
.\" 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 acknowledgment:
.\" 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
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ls.1 8.6 (Berkeley) 4/18/94
.\" $Id: ls.1,v 1.5.2.6 1998/07/15 02:01:34 jkh Exp $
.\" $Id$
.\"
.Dd April 18, 1994
.Dt LS 1
@@ -43,20 +43,20 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm ls
.Op Fl ABCFHLPRTabcdfgikloqrstu1
.Op Fl ACFLRTacdfiloqrstu1
.Op Ar file ...
.Sh DESCRIPTION
For each operand that names a
.Ar file
of a type other than
directory,
.Nm
.Nm ls
displays its name as well as any requested,
associated information.
For each operand that names a
.Ar file
of type directory,
.Nm
.Nm ls
displays the names of files contained
within that directory, as well as any requested, associated
information.
@@ -76,40 +76,18 @@ List all entries except for
and
.Ql \&.. .
Always set for the super-user.
.It Fl B
Force printing of non-graphic characters in file names as \\xxx,
where xxx is the numeric value of the character in octal.
.It Fl C
Force multi-column output; this is the default when output is to a terminal.
.It Fl F
Display a slash (/) immediately after each pathname
that is a directory, an asterisk (*) after each that is
executable,
an at sign (@) after each symbolic link,
an equals sign (=) after each socket,
a percent sign (%) after each whiteout,
and a vertical bar (|) after each that is a
.Tn FIFO .
.It Fl H
Symbolic links on the command line are followed. This option is assumed if
none of the
.Fl F ,
.Fl d ,
or
.Fl l
options are specified.
and an at sign (@) after each symbolic link.
.\" and a vertical bar (|) after each that is a
.\" .Tn FIFO .
.It Fl L
If argument is a symbolic link, list the file or directory the link references
rather than the link itself. This option cancels the
.Fl P
option.
.It Fl P
If argument is a symbolic link, list the link itself rather than the
object the link references. This option cancels the
.Fl H
and
.Fl L
options.
rather than the link itself.
.It Fl R
Recursively list subdirectories encountered.
.It Fl T
@@ -118,30 +96,18 @@ month, day, hour, minute, second, and year.
.It Fl a
Include directory entries whose names begin with a
dot (.).
.It Fl b
As
.Fl B ,
but use C escape codes whenever possible.
.It Fl c
Use time when file status was last changed for sorting or printing.
.It Fl d
Directories are listed as plain files (not searched recursively).
Directories are listed as plain files (not searched recursively) and
symbolic links in the argument list are not indirected through.
.It Fl f
Output is not sorted.
.It Fl g
This option is deprecated and is only available for compatibility
with
.Bx 4.3 ;
it was used to display the group name in the long
.Pq Fl l
format output.
.It Fl i
For each file, print the file's file serial number (inode number).
.It Fl k
If the
.Fl s
option is specified, print the file size allocation in kilobytes,
not blocks. This option overrides the environment variable BLOCKSIZE.
If the 's' option is specified, print the file size allocation in kilobytes,
not blocks.
.It Fl l
(The lowercase letter ``ell.'') List in long format. (See below.)
If the output is to a terminal, a total sum for all the file
@@ -149,7 +115,7 @@ sizes is output on a line before the long listing.
.It Fl o
Include the file flags in a long
.Pq Fl l
output.
output
.It Fl q
Force printing of non-graphic characters in file names as
the character `?'; this is the default when output is to a terminal.
@@ -160,8 +126,7 @@ lexicographical order or the oldest entries first.
Display the number of file system blocks actually used by each file, in units
of 512 bytes, where partial units are rounded up to the next integer value.
If the output is to a terminal, a total sum for all the file
sizes is output on a line before the listing. The environment variable
BLOCKSIZE overrides the unit size of 512 bytes.
sizes is output on a line before the listing.
.It Fl t
Sort by time modified (most recently modified
first) before sorting the operands by lexicographical
@@ -189,30 +154,14 @@ options all override each other; the last one specified determines
the format used.
.Pp
The
.Fl c
.Fl c ,
and
.Fl u
options override each other; the last one specified determines
the file time used.
.Pp
The
.Fl B ,
.Fl b
and
.Fl q
options all override each other; the last one specified determines
the format used for non-printable characters.
.Pp
The
.Fl H,
.Fl L
and
.Fl P
options all override each other (either partially or fully); they
are applied in the order specified.
.Pp
By default,
.Nm
.Nm ls
lists one entry per line to standard
output; the exceptions are to terminals or when the
.Fl C
@@ -241,10 +190,6 @@ number of 512-byte blocks used by the files in the directory is displayed
on a line by itself immediately before the information for the files in the
directory.
.Pp
If the modification time of the file is more than 6 months
in the past or future, then the year of the last modification
is displayed in place of the hour and minute fields.
.Pp
If the owner or group names are not a known user or group name
the numeric ID's are displayed.
.Pp
@@ -254,9 +199,7 @@ in the size field. If the file is a symbolic link the pathname of the
linked-to file is preceded by
.Dq \-> .
.Pp
The file mode printed under the
.Fl l
option consists of the
The file mode printed under the -l option consists of the
entry type, owner permissions, and group permissions.
The entry type character describes the type of file, as
follows:
@@ -272,8 +215,8 @@ Directory.
Symbolic link.
.It Sy s
Socket link.
.It Sy p
.Tn FIFO .
.\" .It Sy p
.\" .Tn FIFO .
.It Sy \-
Regular file.
.El
@@ -314,7 +257,7 @@ and setgroup-ID mode is set.
The file is executable or the directory is
searchable.
.It Sy \-
The file is neither readable, writable, executable,
The file is neither readable, writeable, executable,
nor set-user-ID nor set-group-ID mode, nor sticky. (See below.)
.El
.Pp
@@ -341,14 +284,14 @@ or
.El
.Pp
The
.Nm
.Nm ls
utility exits 0 on success, and >0 if an error occurs.
.Sh ENVIRONMENT
.Sh ENVIRONMENTAL VARIABLES
The following environment variables affect the execution of
.Nm Ns :
.Nm ls :
.Bl -tag -width BLOCKSIZE
.It Ev BLOCKSIZE
If the environment variable
If the environmental variable
.Ev BLOCKSIZE
is set, the block counts
(see
@@ -360,7 +303,7 @@ decimal integer, it is used as the
column position width for displaying
multiple-text-column output.
The
.Nm
.Nm ls
utility calculates how
many pathname text columns to display
based on the width provided.
@@ -383,16 +326,12 @@ specification.
.Xr sticky 8
.Sh HISTORY
An
.Nm
.Nm ls
command appeared in
.At v1 .
.At v6 .
.Sh STANDARDS
The
.Nm
.Nm ls
function is expected to be a superset of the
.St -p1003.2
specification.
.Sh BUGS
To maintain backward compatibility, the relationships between the many
options is quite complex.
+18 -52
View File
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ls.c,v 1.10.2.2 1998/07/15 02:01:34 jkh Exp $
* $Id$
*/
#ifndef lint
@@ -58,7 +58,6 @@ static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <locale.h>
#include "ls.h"
#include "extern.h"
@@ -82,21 +81,19 @@ int f_kblocks; /* print size in kilobytes */
int f_listdir; /* list actual directory, not contents */
int f_listdot; /* list files beginning with . */
int f_longform; /* long listing format */
int f_newline; /* if precede with newline */
int f_nonprint; /* show unprintables as ? */
int f_nosort; /* don't sort output */
int f_octal; /* show unprintables as \xxx */
int f_octal_escape; /* like f_octal but use C escapes if possible */
int f_recursive; /* ls subdirectories also */
int f_reversesort; /* reverse whatever sort is used */
int f_sectime; /* print the real time for all files */
int f_singlecol; /* use single column output */
int f_size; /* list size in short listing */
int f_statustime; /* use time of last mode change */
int f_dirname; /* if precede with directory name */
int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
int rval;
int
main(argc, argv)
int argc;
@@ -107,8 +104,6 @@ main(argc, argv)
int ch, fts_options, notused;
char *p;
(void) setlocale(LC_ALL, "");
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
if (isatty(STDOUT_FILENO)) {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 ||
@@ -119,19 +114,15 @@ main(argc, argv)
else
termwidth = win.ws_col;
f_column = f_nonprint = 1;
} else {
} else
f_singlecol = 1;
/* retrieve environment variable, in case of explicit -C */
if ((p = getenv("COLUMNS")))
termwidth = atoi(p);
}
/* Root is -A automatically. */
if (!getuid())
f_listdot = 1;
fts_options = FTS_PHYSICAL;
while ((ch = getopt(argc, argv, "1ABCFHLPRTabcdfgikloqrstu")) != -1) {
while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
@@ -141,11 +132,6 @@ main(argc, argv)
f_singlecol = 1;
f_column = f_longform = 0;
break;
case 'B':
f_nonprint = 0;
f_octal = 1;
f_octal_escape = 0;
break;
case 'C':
f_column = 1;
f_longform = f_singlecol = 0;
@@ -166,18 +152,10 @@ main(argc, argv)
case 'F':
f_type = 1;
break;
case 'H':
fts_options |= FTS_COMFOLLOW;
break;
case 'L':
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
break;
case 'P':
fts_options &= ~FTS_COMFOLLOW;
fts_options &= ~FTS_LOGICAL;
fts_options |= FTS_PHYSICAL;
break;
case 'R':
f_recursive = 1;
break;
@@ -208,8 +186,6 @@ main(argc, argv)
break;
case 'q':
f_nonprint = 1;
f_octal = 0;
f_octal_escape = 0;
break;
case 'r':
f_reversesort = 1;
@@ -223,11 +199,6 @@ main(argc, argv)
case 't':
f_timesort = 1;
break;
case 'b':
f_nonprint = 0;
f_octal = 0;
f_octal_escape = 1;
break;
default:
case '?':
usage();
@@ -252,12 +223,10 @@ main(argc, argv)
/* If -l or -s, figure out block size. */
if (f_longform || f_size) {
(void)getbsize(&notused, &blocksize);
blocksize /= 512;
if (f_kblocks)
blocksize = 2;
else {
(void)getbsize(&notused, &blocksize);
blocksize /= 512;
}
blocksize *= 2;
}
/* Select a sort function. */
@@ -293,7 +262,7 @@ main(argc, argv)
traverse(argc, argv, fts_options);
else
traverse(1, dotav, fts_options);
exit(rval);
exit(0);
}
static int output; /* If anything output. */
@@ -335,7 +304,6 @@ traverse(argc, argv, options)
case FTS_DNR:
case FTS_ERR:
warnx("%s: %s", p->fts_name, strerror(p->fts_errno));
rval = 1;
break;
case FTS_D:
if (p->fts_level != FTS_ROOTLEVEL &&
@@ -399,14 +367,12 @@ display(p, list)
btotal = maxblock = maxinode = maxlen = maxnlink = 0;
bcfile = 0;
maxuser = maxgroup = maxflags = 0;
flags = NULL;
maxsize = 0;
for (cur = list, entries = 0; cur; cur = cur->fts_link) {
if (cur->fts_info == FTS_ERR || cur->fts_info == FTS_NS) {
warnx("%s: %s",
cur->fts_name, strerror(cur->fts_errno));
cur->fts_number = NO_PRINT;
rval = 1;
continue;
}
@@ -431,10 +397,6 @@ display(p, list)
prcopy(cur->fts_name, cur->fts_name, cur->fts_namelen);
if (cur->fts_namelen > maxlen)
maxlen = cur->fts_namelen;
if (f_octal || f_octal_escape) {
int t = len_octal(cur->fts_name, cur->fts_namelen);
if (t > maxlen) maxlen = t;
}
if (needstats) {
sp = cur->fts_statp;
if (sp->st_blocks > maxblock)
@@ -537,12 +499,16 @@ mastercmp(a, b)
if (a_info == FTS_NS || b_info == FTS_NS)
return (namecmp(*a, *b));
if (a_info != b_info &&
(*a)->fts_level == FTS_ROOTLEVEL && !f_listdir) {
if (a_info == b_info)
return (sortfcn(*a, *b));
if ((*a)->fts_level == FTS_ROOTLEVEL)
if (a_info == FTS_D)
return (1);
if (b_info == FTS_D)
else if (b_info == FTS_D)
return (-1);
}
return (sortfcn(*a, *b));
else
return (sortfcn(*a, *b));
else
return (sortfcn(*a, *b));
}
+1 -4
View File
@@ -1,4 +1,3 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -35,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)ls.h 8.1 (Berkeley) 5/31/93
* $Id: ls.h,v 1.2 1994/09/24 02:55:55 davidg Exp $
* $Id$
*/
#define NO_PRINT 1
@@ -46,8 +45,6 @@ extern int f_accesstime; /* use time of last access */
extern int f_flags; /* show flags associated with a file */
extern int f_inode; /* print inode */
extern int f_longform; /* long listing format */
extern int f_octal; /* print unprintables in octal */
extern int f_octal_escape; /* like f_octal but use C escapes if possible */
extern int f_sectime; /* print the real time for all files */
extern int f_size; /* list size in short listing */
extern int f_statustime; /* use time of last mode change */
+16 -28
View File
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: print.c,v 1.8 1996/01/20 10:31:14 mpp Exp $
* $Id$
*/
#ifndef lint
@@ -52,7 +52,9 @@ static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <tzfile.h>
#include <unistd.h>
#include <utmp.h>
#include "ls.h"
#include "extern.h"
@@ -95,7 +97,7 @@ printlong(dp)
continue;
sp = p->fts_statp;
if (f_inode)
(void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino);
(void)printf("%*lu ", dp->s_inode, sp->st_ino);
if (f_size)
(void)printf("%*qd ",
dp->s_block, howmany(sp->st_blocks, blocksize));
@@ -107,12 +109,8 @@ printlong(dp)
if (f_flags)
(void)printf("%-*s ", dp->s_flags, np->flags);
if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
if (minor(sp->st_rdev) > 255)
(void)printf("%3d, 0x%08x ",
major(sp->st_rdev), minor(sp->st_rdev));
else
(void)printf("%3d, %3d ",
major(sp->st_rdev), minor(sp->st_rdev));
(void)printf("%3d, %3d ",
major(sp->st_rdev), minor(sp->st_rdev));
else if (dp->bcfile)
(void)printf("%*s%*qd ",
8 - dp->s_size, "", dp->s_size, sp->st_size);
@@ -124,8 +122,7 @@ printlong(dp)
printtime(sp->st_ctime);
else
printtime(sp->st_mtime);
if (f_octal || f_octal_escape) (void)prn_octal(p->fts_name);
else (void)printf("%s", p->fts_name);
(void)printf("%s", p->fts_name);
if (f_type)
(void)printtype(sp->st_mode);
if (S_ISLNK(sp->st_mode))
@@ -191,7 +188,7 @@ printcol(dp)
dp->s_block);
if ((base += numrows) >= num)
break;
while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){
while ((cnt = (chcnt + TAB & ~(TAB - 1))) <= endcol) {
(void)putchar('\t');
chcnt = cnt;
}
@@ -216,12 +213,11 @@ printaname(p, inodefield, sizefield)
sp = p->fts_statp;
chcnt = 0;
if (f_inode)
chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino);
chcnt += printf("%*lu ", (int)inodefield, sp->st_ino);
if (f_size)
chcnt += printf("%*qd ",
(int)sizefield, howmany(sp->st_blocks, blocksize));
chcnt += (f_octal || f_octal_escape) ? prn_octal(p->fts_name)
: printf("%s", p->fts_name);
chcnt += printf("%s", p->fts_name);
if (f_type)
chcnt += printtype(sp->st_mode);
return (chcnt);
@@ -232,21 +228,17 @@ printtime(ftime)
time_t ftime;
{
int i;
char longstring[80];
static time_t now;
char *longstring;
if (now == 0)
now = time(NULL);
strftime(longstring, sizeof(longstring), "%c", localtime(&ftime));
longstring = ctime(&ftime);
for (i = 4; i < 11; ++i)
(void)putchar(longstring[i]);
#define SIXMONTHS ((365 / 2) * 86400)
#define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
if (f_sectime)
for (i = 11; i < 24; i++)
(void)putchar(longstring[i]);
else if (ftime + SIXMONTHS > now && ftime < now + SIXMONTHS)
else if (ftime + SIXMONTHS > time(NULL))
for (i = 11; i < 16; ++i)
(void)putchar(longstring[i]);
else {
@@ -291,7 +283,7 @@ printlink(p)
if (p->fts_level == FTS_ROOTLEVEL)
(void)snprintf(name, sizeof(name), "%s", p->fts_name);
else
else
(void)snprintf(name, sizeof(name),
"%s/%s", p->fts_parent->fts_accpath, p->fts_name);
if ((lnklen = readlink(name, path, sizeof(path) - 1)) == -1) {
@@ -299,9 +291,5 @@ printlink(p)
return;
}
path[lnklen] = '\0';
if (f_octal || f_octal_escape) {
(void)printf(" -> ");
(void)prn_octal(path);
}
else (void)printf(" -> %s", path);
(void)printf(" -> %s", path);
}
+1 -9
View File
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: stat_flags.c,v 1.2 1994/09/24 02:55:57 davidg Exp $
* $Id$
*/
#ifndef lint
@@ -69,8 +69,6 @@ flags_to_string(flags, def)
SAPPEND("uappnd");
if (flags & UF_IMMUTABLE)
SAPPEND("uchg");
if (flags & UF_NOUNLINK)
SAPPEND("uunlnk");
if (flags & UF_NODUMP)
SAPPEND("nodump");
if (flags & SF_APPEND)
@@ -79,8 +77,6 @@ flags_to_string(flags, def)
SAPPEND("arch");
if (flags & SF_IMMUTABLE)
SAPPEND("schg");
if (flags & SF_NOUNLINK)
SAPPEND("sunlnk");
return (prefix == NULL && def != NULL ? def : string);
}
@@ -138,8 +134,6 @@ string_to_flags(stringp, setp, clrp)
TEST(p, "schg", SF_IMMUTABLE);
TEST(p, "schange", SF_IMMUTABLE);
TEST(p, "simmutable", SF_IMMUTABLE);
TEST(p, "sunlnk", SF_NOUNLINK);
TEST(p, "sunlink", SF_NOUNLINK);
return (1);
case 'u':
TEST(p, "uappnd", UF_APPEND);
@@ -147,8 +141,6 @@ string_to_flags(stringp, setp, clrp)
TEST(p, "uchg", UF_IMMUTABLE);
TEST(p, "uchange", UF_IMMUTABLE);
TEST(p, "uimmutable", UF_IMMUTABLE);
TEST(p, "uunlnk", UF_NOUNLINK);
TEST(p, "uunlink", UF_NOUNLINK);
/* FALLTHROUGH */
default:
return (1);
+3 -90
View File
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: util.c,v 1.5.2.2 1998/07/15 02:01:36 jkh Exp $
* $Id: util.c,v 1.3 1994/09/24 02:55:58 davidg Exp $
*/
#ifndef lint
@@ -57,7 +57,7 @@ prcopy(src, dest, len)
char *src, *dest;
int len;
{
unsigned char ch;
int ch;
while (len--) {
ch = *src++;
@@ -65,96 +65,9 @@ prcopy(src, dest, len)
}
}
/*
* The fts system makes it difficult to replace fts_name with a different-
* sized string, so we just calculate the real length here and do the
* conversion in prn_octal()
*
* XXX when using f_octal_escape (-b) rather than f_octal (-B), the
* length computed by len_octal may be too big. I just can't be buggered
* to fix this as an efficient fix would involve a lookup table. Same goes
* for the rather inelegant code in prn_octal.
*
* DES 1998/04/23
*/
int
len_octal(s, len)
char *s;
int len;
{
int r = 0;
while (len--)
if (isprint((unsigned char)*s++)) r++; else r += 4;
return r;
}
int
prn_octal(s)
char *s;
{
unsigned char ch;
int len = 0;
while ((ch = *s++))
{
if (isprint(ch) && (ch != '\"') && (ch != '\\'))
putchar(ch), len++;
else if (f_octal_escape) {
putchar('\\');
switch (ch) {
case '\\':
putchar('\\');
break;
case '\"':
putchar('"');
break;
case '\a':
putchar('a');
break;
case '\b':
putchar('b');
break;
case '\f':
putchar('f');
break;
case '\n':
putchar('n');
break;
case '\r':
putchar('r');
break;
case '\t':
putchar('t');
break;
case '\v':
putchar('v');
break;
default:
putchar('0' + (ch >> 6));
putchar('0' + ((ch >> 3) & 3));
putchar('0' + (ch & 3));
len += 2;
break;
}
len += 2;
}
else {
putchar('\\');
putchar('0' + (ch >> 6));
putchar('0' + ((ch >> 3) & 3));
putchar('0' + (ch & 3));
len += 4;
}
}
return len;
}
void
usage()
{
(void)fprintf(stderr, "usage: ls [-ACFHLPRTacdfgikloqrstu1]"
" [file ...]\n");
(void)fprintf(stderr, "usage: ls [-1ACFLRTacdfiklqrstu] [file ...]\n");
exit(1);
}
+2 -7
View File
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mkdir.1 8.2 (Berkeley) 1/25/94
.\" $Id: mkdir.1,v 1.3.2.2 1998/06/30 06:42:30 charnier Exp $
.\" $Id$
.\"
.Dd January 25, 1994
.Dt MKDIR 1
@@ -87,12 +87,7 @@ exits 0 if successful, and >0 if an error occurred.
.Xr rmdir 1
.Sh STANDARDS
The
.Nm
.Nm mkdir
utility is expected to be
.St -p1003.2
compatible.
.Sh HISTORY
A
.Nm
command appeared in
.At v1 .
Loaded 100 of 14514 files, more files were not shown because too many files have changed in this diff. Show more