diff options
Diffstat (limited to 'gnu/usr.bin/rcs/rcstest')
-rwxr-xr-x | gnu/usr.bin/rcs/rcstest | 193 |
1 files changed, 68 insertions, 125 deletions
diff --git a/gnu/usr.bin/rcs/rcstest b/gnu/usr.bin/rcs/rcstest index 6eca1f55f1ca..7363a6d26602 100755 --- a/gnu/usr.bin/rcs/rcstest +++ b/gnu/usr.bin/rcs/rcstest @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # Test RCS's functions. # The RCS commands are searched for in the PATH as usual; @@ -18,7 +18,7 @@ # $Id: rcstest,v 1.1.1.1 1993/06/18 04:22:10 jkh Exp $ -# Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert +# Copyright 1990, 1991 by Paul Eggert # Distributed under license by the Free Software Foundation, Inc. # # This file is part of RCS. @@ -34,23 +34,13 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with RCS; see the file COPYING. -# If not, write to the Free Software Foundation, -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with RCS; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # Report problems and direct all questions to: # # rcs-bugs@cs.purdue.edu -# The Makefile overrides the following defaults. -: ${ALL_CFLAGS=-Dhas_conf_h} -: ${CC=cc} -: ${DIFF=diff} -# : ${LDFLAGS=} ${LIBS=} tickles old shell bug - -CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out" -L=$LIBS - RCSINIT=-x export RCSINIT @@ -65,26 +55,26 @@ case $1 in *) echo >&2 "$0: usage: $0 [-v]"; exit 2 esac -if test -d RCS -then rmdir=: -else rmdir=rmdir; mkdir RCS || exit -fi +test -d RCS || { + echo >&2 "$0: RCS: not a directory; please \`mkdir RCS' first." + exit 1 +} rm -f a.* $RCSfile $RCS_alt $lockfile && echo 1.1 >a.11 && echo 1.1.1.1 >a.3x1 && echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; } -case "`$DIFF -c a.11 a.3x1`" in -*!\ 1.1.1.1) - diff="$DIFF -c";; +case `diff -c a.11 a.3x1` in +*'! 1.1.1.1') + diff='diff -c';; *) - echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic" - diff=$DIFF + echo "#warning: diff -c does not work, so diagnostics may be cryptic" + diff=diff esac rcs -i -L -ta.11 $q a.c && -test -r $RCSfile || { +<$RCSfile || { echo "#rcs -i -L failed; perhaps RCS is not properly installed." exit 1 } @@ -94,7 +84,7 @@ rm -f $RCSfile || exit 2 cp a.11 a.c && ci -ta.11 -mm $q a.c && -test -r $RCSfile && +<$RCSfile && rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; } test ! -f a.c || { echo "#ci did not remove working file"; exit 1; } for l in '' '-l' @@ -109,7 +99,6 @@ ci -mm $q a.c && co $q a.c && $diff a.12 a.c || { echo "#ci+co failed"; exit 1; } -rm -f a.c && co -r1.1 $q a.c && $diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; } @@ -119,24 +108,21 @@ ci -r1.1.1 -mm $q a.c && co -r1.1.1.1 $q a.c && $diff a.3x1 a.c || { echo "#branches failed"; exit 1; } -rm -f a.c && co -l $q a.c && ci -f -mm $q a.c && co -r1.3 $q a.c && $diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; } -rm -f a.c && co -l $q a.c && echo 1.4 >a.c && ci -l -mm $q a.c && echo error >a.c && ci -mm $q a.c || { echo "#ci -l failed"; exit 1; } -rm -f a.c && co -l $q a.c && echo 1.5 >a.c && ci -u -mm $q a.c && -test -r a.c || { echo "#ci -u didn't create a working file"; exit 1; } +<a.c || { echo "#ci -u didn't create a working file"; exit 1; } rm -f a.c && echo error >a.c || exit 2 ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; } @@ -180,28 +166,42 @@ case $LOGNAME in esac esac esac - - -# Get the date of the previous revision in UTC. -date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` || exit -case $date in -[0-9][0-9][0-9]*[0-9]/[0-1][0-9]/[0-3][0-9]\ [0-2][0-9]:[0-5][0-9]:[0-6][0-9]);; -*) echo >&2 "$0: $date: bad rlog date output"; exit 1 +date=`date -u 2>/dev/null` || +date=`TZ=GMT0 date 2>/dev/null` || +date=`TZ= date` || exit 2 +set $date +case $2 in +Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;; +Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;; +*) echo >&2 "$0: $2: unknown month name"; exit 2 esac -PWD=`pwd` && export PWD && -rm -f a.c && +case $3 in +?) d=0$3;; +*) d=$3 +esac +case $6 in +[0-9][0-9][0-9][0-9]*) D=$6/$m/$d;; +*) + case $5 in + [0-9][0-9][0-9][0-9]*) D=$5/$m/$d;; + *) echo >&2 "$0: bad date format: $date"; exit 2 + esac +esac +T=$4 +case $PWD in +'') PWD=`pwd` +esac && co -l $q a.c && sed 's/@/$/g' >a.kv <<EOF @Author: w @ -@Date: $date @ -@Header: $PWD$SLASH$RCSfile 2.1 $date w s @ -@Id: a.c 2.1 $date w s @ +@Date: $D $T @ +@Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @ +@Id: a.c 2.1 $D $T w s @ @Locker: @ - * @Log: a.c @ - * Revision 2.1 $date w +@Log: a.c @ + * Revision 2.1 $D $T w * m * -@Name: Oz @ @RCSfile: a.c @ @Revision: 2.1 @ @Source: $PWD$SLASH$RCSfile @ @@ -210,28 +210,25 @@ EOF test $? = 0 && sed 's/:.*\$/$/' a.kv >a.k && sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl && -sed s/Oz//g a.kv >a.e && -sed s/Oz/N/g a.kv >a.N && -sed -e '/\$/!d' -e 's/\$$/: old $/' a.k >a.o && +sed -e '/^\$/!d' -e 's/\$$/: old $/' a.k >a.o && sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v && cp a.o a.c && -ci -d"$date" -nOz -ss -ww -u2.1 -mm $q a.c && +ci -d"$date" -ss -ww -u2.1 -mm $q a.c && $diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; } -co -pOz -ko $q a.c >a.oo && +co -p -ko $q a.c >a.oo && $diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; } -cp a.kv a.o && cp a.o a.b || exit 2 -rcs -oOz $q a.c && +cp a.kv a.o || exit 2 +rcs -o2.1 $q a.c && rcs -l $q a.c && ci -k -u $q a.c && $diff a.kv a.c || { echo "#ci -k failed"; exit 1; } -sed -n 's/^[^$]*\$/$/p' a.kv >a.i && +sed '/^[^$]/d' a.kv >a.i && ident a.c >a.i1 && sed -e 1d -e 's/^[ ]*//' a.i1 >a.i2 && $diff a.i a.i2 || { echo "#ident failed"; exit 1; } rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; } -rm -f a.c && co -l $q a.c && echo 2.2 >a.c && ci -mm $q a.c && @@ -262,73 +259,40 @@ rcs -nN:1.1 $q a.c && co -rN $q a.c && $diff a.11 a.c || { echo "#rcs -n failed"; exit 1; } -rm -f a.c && rcs -NN:2.1 $q a.c && co -rN $q a.c && -$diff a.N a.c || { echo "#rcs -N failed"; exit 1; } +$diff a.kv a.c || { echo "#rcs -N failed"; exit 1; } -rm -f a.c && co -l $q a.c && -echo ':::$''Log$' >a.c && +rcs -c':::' $q a.c && +echo '$''Log$' >a.c && ci -u -mm $q a.c && -test " `sed '$!d' a.c`" = ' :::' || { echo "#comment leader failed"; exit 1; } +test " `sed '$!d' a.c`" = ' :::' || { echo "#rcs -c failed"; exit 1; } -rm -f a.c && rcs -o2.2: $q a.c && co $q a.c && -$diff a.e a.c || { echo "#rcs -o failed"; exit 1; } +$diff a.kv a.c || { echo "#rcs -o failed"; exit 1; } -rcsdiff -r1.1 -rOz $q a.c >a.0 +rcsdiff -r1.1 -r2.1 $q a.c >a.0 case $? in 1) ;; *) echo "#rcsdiff bad status"; exit 1 esac -$DIFF a.11 a.kv >a.1 +diff a.11 a.kv >a.1 $diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; } rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; } -for i in b k kv kvl o v +for i in k kv kvl o v do rm -f a.c && cp a.$i a.c && - rcsdiff -k$i -rOz $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; } + rcsdiff -k$i $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; } done co -p1.1 -ko $q a.c >a.t && $diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; } rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; } rm -f a.c && -rcsclean $q a.c && -rcsclean -u $q a.c || { echo "#rcsclean botched a nonexistent file"; exit 1; } - -rm -f a.c && -co $q a.c && -rcsclean -n $q a.c && -rcsclean -n -u $q a.c && -test -f a.c || { echo "#rcsclean -n removed a file"; exit 1; } - -rm -f a.c && -co $q a.c && -rcsclean $q a.c && -test ! -f a.c || { echo "#rcsclean missed an unlocked file"; exit 1; } - -rm -f a.c && -co -l $q a.c && -rcsclean $q a.c && -test -f a.c || { echo "#rcsclean removed a locked file"; exit 1; } -rcsclean -u $q a.c && -test ! -f a.c || { - echo "#rcsclean -u missed an unchanged locked file"; exit 1; -} - -rm -f a.c && -co -l $q a.c && -echo change >>a.c && -rcsclean $q a.c && -rcsclean $q -u a.c && -test -f a.c || { echo "#rcsclean removed a changed file"; exit 1; } - -rm -f a.c && co -l $q a.c && cat >a.c <<'EOF' 2.2 @@ -360,7 +324,7 @@ b1 c d1 EOF -rcsmerge -E -r2.2 -r2.3 $q a.c +rcsmerge -r2.2 -r2.3 $q a.c case $? in 0) if $diff a.0 a.c >/dev/null @@ -379,36 +343,16 @@ case $? in echo "#rcsmerge bad status"; exit 1 esac -# Avoid `tr' if possible; it's not portable, and it can't handle null bytes. -# Our substitute exclusive-ORs with '\n'; -# this ensures null bytes on output, which is even better than `tr', -# since some diffs think a file is binary only if it contains null bytes. -cat >a.c <<'EOF' -#include <stdio.h> -int main() { - int c; - while ((c=getchar()) != EOF) - putchar(c ^ '\n'); - return 0; -} -EOF -tr=tr -if (rm -f a.exe a.out && $CL a.c $L >&2) >/dev/null 2>&1 -then - if test -s a.out - then tr=./a.out - elif test -s a.exe - then tr=./a.exe - fi -fi +nl=' +' { - co -p $q a.c | $tr '\012' '\200' >a.24 && + co -p $q a.c | tr "$nl" '\200' >a.24 && cp a.24 a.c && ciOut=`(ci -l -mm $q a.c 2>&1)` && case $ciOut in ?*) echo >&2 "$ciOut" esac && - co -p $q a.c | $tr '\200' '\012' >a.c && + co -p $q a.c | tr '\200' "$nl" >a.c && rcsdiff -r2.3 $q a.c >/dev/null && echo 2.5 >a.c && @@ -434,15 +378,15 @@ locks: strict access list: symbolic names: N: 2.1 - Oz: 2.1 n: 1.8 +comment leader: ":::" keyword substitution: kv total revisions: 13; selected revisions: 1 description: 1.1 ---------------------------- revision 2.1 -date: $date; author: w; state: s; lines: +14 -1 +date: $D $T; author: w; state: s; lines: +13 -1 ============================================================================= EOF test $? = 0 || { echo "#rlog failed"; exit 1; } @@ -450,5 +394,4 @@ test $? = 0 || { echo "#rlog failed"; exit 1; } test ! -f $lockfile || { echo "#lock file not removed"; exit 1; } -rm -f a.* $RCSfile $RCS_alt -$rmdir RCS +exec rm -f a.* $RCSfile $RCS_alt |