home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: alm@netcom.com (Andrew Moore)
- Subject: v37i097: ed - POSIX-compliant line editor, Part03/03
- Message-ID: <1993May31.025546.13582@sparky.imd.sterling.com>
- X-Md4-Signature: df53df0b1c15045a3ef2e32daa44ddd1
- Sender: kent@sparky.imd.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Mon, 31 May 1993 02:55:46 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: alm@netcom.com (Andrew Moore)
- Posting-number: Volume 37, Issue 97
- Archive-name: ed/part03
- Environment: POSIX, sun, linux, bsd
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: Makefile Makefile.386bsd Makefile.linux Makefile.netbsd
- # POSIX signal.c
- # Wrapped by kent@sparky on Sun May 30 21:43:00 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 3)."'
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(189 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XPROG= ed
- XCFLAGS+=-I${.CURDIR} -DVI_BANG -DDES -DGNU_REGEX -DHAVE_STRING_H=1
- XSRCS= ed.c re.c buf.c cbc.c regex.c
- XLINKS= ${BINDIR}/ed ${BINDIR}/red
- XMLINKS= ed.1 red.1
- X
- X.include <bsd.prog.mk>
- END_OF_FILE
- if test 189 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'Makefile.386bsd' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.386bsd'\"
- else
- echo shar: Extracting \"'Makefile.386bsd'\" \(189 characters\)
- sed "s/^X//" >'Makefile.386bsd' <<'END_OF_FILE'
- XPROG= ed
- XCFLAGS+=-I${.CURDIR} -DVI_BANG -DDES -DGNU_REGEX -DHAVE_STRING_H=1
- XSRCS= ed.c re.c buf.c cbc.c regex.c
- XLINKS= ${BINDIR}/ed ${BINDIR}/red
- XMLINKS= ed.1 red.1
- X
- X.include <bsd.prog.mk>
- END_OF_FILE
- if test 189 -ne `wc -c <'Makefile.386bsd'`; then
- echo shar: \"'Makefile.386bsd'\" unpacked with wrong size!
- fi
- # end of 'Makefile.386bsd'
- fi
- if test -f 'Makefile.linux' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.linux'\"
- else
- echo shar: Extracting \"'Makefile.linux'\" \(400 characters\)
- sed "s/^X//" >'Makefile.linux' <<'END_OF_FILE'
- XPROG =ed
- XCC =gcc
- XCFLAGS=-O -DGNU_REGEX -DNO_REALLOC_NULL -DVI_BANG -D_POSIX_SOURCE -D__USE_BSD_SIGNAL
- XSRCS= ed.c re.c buf.c cbc.c
- XOBJS= ed.o re.o buf.o cbc.o
- X
- Xall: ${PROG} doc
- X
- X${PROG}: ${OBJS}
- X ${CC} -o $@ ${CFLAGS} ${OBJS} ${LDADD}
- X
- Xed.o: ed.c ed.h
- X
- Xre.o: re.c ed.h
- X
- Xbuf.o: buf.c ed.h
- X
- Xcbc.o: cbc.c ed.h
- X
- Xdoc:
- X nroff -man ${PROG}.1 >${PROG}.0
- X
- Xclean:
- X rm -f *.o ${PROG}.0 ${PROG} [Ee]rrs core *~
- END_OF_FILE
- if test 400 -ne `wc -c <'Makefile.linux'`; then
- echo shar: \"'Makefile.linux'\" unpacked with wrong size!
- fi
- # end of 'Makefile.linux'
- fi
- if test -f 'Makefile.netbsd' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.netbsd'\"
- else
- echo shar: Extracting \"'Makefile.netbsd'\" \(177 characters\)
- sed "s/^X//" >'Makefile.netbsd' <<'END_OF_FILE'
- XPROG= ed
- XCFLAGS+=-DVI_BANG -DDES -DGNU_REGEX
- XSRCS= ed.c re.c buf.c cbc.c
- XLDADD= -lgnuregex -lcrypt
- XLINKS= ${BINDIR}/ed ${BINDIR}/red
- XMLINKS= ed.1 red.1
- X
- X.include <bsd.prog.mk>
- END_OF_FILE
- if test 177 -ne `wc -c <'Makefile.netbsd'`; then
- echo shar: \"'Makefile.netbsd'\" unpacked with wrong size!
- fi
- # end of 'Makefile.netbsd'
- fi
- if test -f 'POSIX' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'POSIX'\"
- else
- echo shar: Extracting \"'POSIX'\" \(2651 characters\)
- sed "s/^X//" >'POSIX' <<'END_OF_FILE'
- XThis version of ed is not strictly POSIX compliant, as described in the
- XPOSIX 1003.2 Draft 11.2 document. BSD commands have been implemented
- Xwherever they do not conflict with the POSIX standard. For backwards
- Xcompatibility, the POSIX rule that says a range of addresses cannot be
- Xused where only a single address is expected has been relaxed.
- X
- XThe BSD commands included are:
- X 1) `s' (i.e., s[rgp]*) to repeat a previous substitution,
- X 2) `W' for appending text to an existing file,
- X 3) `wq' for exiting after a write, and
- X 4) `z' for scrolling through the buffer.
- XBSD line addressing syntax (i.e., `^' and `%'). is also recognized.
- X
- XThe POSIX interactive global commands `G' and `V' are extended to support
- Xmultiple commands, including `a', `i' and `c'. The command format is the
- Xsame as for the global commands `g' and `v', i.e., one command per line
- Xwith each line, except for the last, ending in a backslash (\).
- X
- XIf crypt is available, files can be read and written using DES encryption.
- XThe `x' command prompts the user to enter a key used for encrypting/
- Xdecrypting subsequent reads and writes. If only a newline is entered as
- Xthe key, then encryption is disabled. Otherwise, a key is read in the
- Xsame manner as a password entry. The key remains in effect until
- Xencryption is disabled. For more information on the encryption algorithm,
- Xsee the bdes(1) man page. Encryption/decryption should be fully compatible
- Xwith SunOS DES.
- X
- XAn extension to the POSIX file commands `E', `e', `r', `W' and `w' is that
- X<file> arguments are processed for backslash escapes, i.e., any character
- Xpreceded by a backslash is interpreted literally. If the first unescaped
- Xcharacter of a <file> argument is a bang (!), then the rest of the line
- Xis interpreted as a shell command, and no escape processing is performed
- Xby ed.
- X
- XThe vi editor's bang command syntax is supported, i.e.,
- X(addr1,addr2) !<shell-cmd> replaces the addressed lines with the output of
- X the command <shell-cmd>.
- X[rwe] !! reads/writes/edits the previous !<shell-cmd>.
- X
- XIf ed is invoked with a name argument prefixed by a bang, then the
- Xremainder of the argument is interpreted as a shell command. To invoke
- Xed on a file whose name starts with bang, prefix the name with a backslash.
- X
- Xed runs in restricted mode if invoked as red. This limits editing of
- Xfiles in the local directory only and prohibits !<shell-cmd> commands.
- X
- XThough ed is not a binary editor, it can be used (if painfully) to edit
- Xbinary files. To assist in binary editing, when a file containing at
- Xleast one ASCII NUL character is written, a newline is not appended
- Xif it did not already contain one upon reading.
- END_OF_FILE
- if test 2651 -ne `wc -c <'POSIX'`; then
- echo shar: \"'POSIX'\" unpacked with wrong size!
- fi
- # end of 'POSIX'
- fi
- if test -f 'signal.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'signal.c'\"
- else
- echo shar: Extracting \"'signal.c'\" \(2471 characters\)
- sed "s/^X//" >'signal.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1985, 1989 Regents of the University of California.
- X * All rights reserved.
- X *
- X * Redistribution and use in source and binary forms, with or without
- X * modification, are permitted provided that the following conditions
- X * are met:
- X * 1. Redistributions of source code must retain the above copyright
- X * notice, this list of conditions and the following disclaimer.
- X * 2. Redistributions in binary form must reproduce the above copyright
- X * notice, this list of conditions and the following disclaimer in the
- X * documentation and/or other materials provided with the distribution.
- X * 3. All advertising materials mentioning features or use of this software
- X * must display the following acknowledgement:
- X * This product includes software developed by the University of
- X * California, Berkeley and its contributors.
- X * 4. Neither the name of the University nor the names of its contributors
- X * may be used to endorse or promote products derived from this software
- X * without specific prior written permission.
- X *
- X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- X * SUCH DAMAGE.
- X */
- X
- X#if defined(LIBC_SCCS) && !defined(lint)
- Xstatic char sccsid[] = "@(#)signal.c 5.5 (Berkeley) 6/1/90";
- X#endif /* LIBC_SCCS and not lint */
- X
- X/*
- X * Almost backwards compatible signal.
- X */
- X#include <signal.h>
- X
- X#ifdef signal
- X# undefine signal
- X#endif
- X
- Xsigset_t _sigintr; /* shared with siginterrupt */
- X
- Xvoid
- X(*signal(s, a))()
- X int s;
- X void (*a)();
- X{
- X struct sigaction sa, osa;
- X
- X sa.sa_handler = a;
- X sigemptyset(&sa.sa_mask);
- X sa.sa_flags = 0;
- X if (!sigismember(&_sigintr, s))
- X#ifdef SA_RESTART
- X sa.sa_flags |= SA_RESTART;
- X#else
- X sa.sa_flags &= ~SA_INTERRUPT;
- X#endif
- X if (sigaction(s, &sa, &osa) < 0)
- X return (BADSIG);
- X return (osa.sa_handler);
- X}
- END_OF_FILE
- if test 2471 -ne `wc -c <'signal.c'`; then
- echo shar: \"'signal.c'\" unpacked with wrong size!
- fi
- # end of 'signal.c'
- fi
- echo shar: End of archive 3 \(of 3\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-