home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume37 / ed / part03 < prev    next >
Encoding:
Text File  |  1993-05-31  |  9.7 KB  |  273 lines

  1. Newsgroups: comp.sources.misc
  2. From: alm@netcom.com (Andrew Moore)
  3. Subject: v37i097:  ed - POSIX-compliant line editor, Part03/03
  4. Message-ID: <1993May31.025546.13582@sparky.imd.sterling.com>
  5. X-Md4-Signature: df53df0b1c15045a3ef2e32daa44ddd1
  6. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Mon, 31 May 1993 02:55:46 GMT
  9. Approved: kent@sparky.imd.sterling.com
  10.  
  11. Submitted-by: alm@netcom.com (Andrew Moore)
  12. Posting-number: Volume 37, Issue 97
  13. Archive-name: ed/part03
  14. Environment: POSIX, sun, linux, bsd
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  Makefile Makefile.386bsd Makefile.linux Makefile.netbsd
  21. #   POSIX signal.c
  22. # Wrapped by kent@sparky on Sun May 30 21:43:00 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 3 (of 3)."'
  26. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Makefile'\"
  28. else
  29.   echo shar: Extracting \"'Makefile'\" \(189 characters\)
  30.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  31. XPROG=    ed
  32. XCFLAGS+=-I${.CURDIR} -DVI_BANG -DDES -DGNU_REGEX -DHAVE_STRING_H=1
  33. XSRCS=    ed.c re.c buf.c cbc.c regex.c
  34. XLINKS=    ${BINDIR}/ed ${BINDIR}/red
  35. XMLINKS=    ed.1 red.1
  36. X
  37. X.include <bsd.prog.mk>
  38. END_OF_FILE
  39.   if test 189 -ne `wc -c <'Makefile'`; then
  40.     echo shar: \"'Makefile'\" unpacked with wrong size!
  41.   fi
  42.   # end of 'Makefile'
  43. fi
  44. if test -f 'Makefile.386bsd' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'Makefile.386bsd'\"
  46. else
  47.   echo shar: Extracting \"'Makefile.386bsd'\" \(189 characters\)
  48.   sed "s/^X//" >'Makefile.386bsd' <<'END_OF_FILE'
  49. XPROG=    ed
  50. XCFLAGS+=-I${.CURDIR} -DVI_BANG -DDES -DGNU_REGEX -DHAVE_STRING_H=1
  51. XSRCS=    ed.c re.c buf.c cbc.c regex.c
  52. XLINKS=    ${BINDIR}/ed ${BINDIR}/red
  53. XMLINKS=    ed.1 red.1
  54. X
  55. X.include <bsd.prog.mk>
  56. END_OF_FILE
  57.   if test 189 -ne `wc -c <'Makefile.386bsd'`; then
  58.     echo shar: \"'Makefile.386bsd'\" unpacked with wrong size!
  59.   fi
  60.   # end of 'Makefile.386bsd'
  61. fi
  62. if test -f 'Makefile.linux' -a "${1}" != "-c" ; then 
  63.   echo shar: Will not clobber existing file \"'Makefile.linux'\"
  64. else
  65.   echo shar: Extracting \"'Makefile.linux'\" \(400 characters\)
  66.   sed "s/^X//" >'Makefile.linux' <<'END_OF_FILE'
  67. XPROG   =ed
  68. XCC    =gcc
  69. XCFLAGS=-O -DGNU_REGEX -DNO_REALLOC_NULL -DVI_BANG -D_POSIX_SOURCE -D__USE_BSD_SIGNAL
  70. XSRCS=    ed.c re.c buf.c cbc.c
  71. XOBJS=    ed.o re.o buf.o cbc.o
  72. X
  73. Xall: ${PROG} doc
  74. X
  75. X${PROG}: ${OBJS}
  76. X    ${CC} -o $@ ${CFLAGS} ${OBJS} ${LDADD}
  77. X
  78. Xed.o: ed.c ed.h
  79. X
  80. Xre.o: re.c ed.h
  81. X
  82. Xbuf.o: buf.c ed.h
  83. X
  84. Xcbc.o: cbc.c ed.h
  85. X
  86. Xdoc:
  87. X    nroff -man ${PROG}.1 >${PROG}.0
  88. X
  89. Xclean:
  90. X    rm -f *.o ${PROG}.0 ${PROG} [Ee]rrs core *~
  91. END_OF_FILE
  92.   if test 400 -ne `wc -c <'Makefile.linux'`; then
  93.     echo shar: \"'Makefile.linux'\" unpacked with wrong size!
  94.   fi
  95.   # end of 'Makefile.linux'
  96. fi
  97. if test -f 'Makefile.netbsd' -a "${1}" != "-c" ; then 
  98.   echo shar: Will not clobber existing file \"'Makefile.netbsd'\"
  99. else
  100.   echo shar: Extracting \"'Makefile.netbsd'\" \(177 characters\)
  101.   sed "s/^X//" >'Makefile.netbsd' <<'END_OF_FILE'
  102. XPROG=    ed
  103. XCFLAGS+=-DVI_BANG -DDES -DGNU_REGEX
  104. XSRCS=    ed.c re.c buf.c cbc.c
  105. XLDADD=    -lgnuregex -lcrypt
  106. XLINKS=  ${BINDIR}/ed ${BINDIR}/red
  107. XMLINKS= ed.1 red.1
  108. X
  109. X.include <bsd.prog.mk>
  110. END_OF_FILE
  111.   if test 177 -ne `wc -c <'Makefile.netbsd'`; then
  112.     echo shar: \"'Makefile.netbsd'\" unpacked with wrong size!
  113.   fi
  114.   # end of 'Makefile.netbsd'
  115. fi
  116. if test -f 'POSIX' -a "${1}" != "-c" ; then 
  117.   echo shar: Will not clobber existing file \"'POSIX'\"
  118. else
  119.   echo shar: Extracting \"'POSIX'\" \(2651 characters\)
  120.   sed "s/^X//" >'POSIX' <<'END_OF_FILE'
  121. XThis version of ed is not strictly POSIX compliant, as described in the
  122. XPOSIX 1003.2 Draft 11.2 document.  BSD commands have been implemented
  123. Xwherever they do not conflict with the POSIX standard.  For backwards
  124. Xcompatibility, the POSIX rule that says a range of addresses cannot be
  125. Xused where only a single address is expected has been relaxed.
  126. X
  127. XThe BSD commands included are:
  128. X    1) `s' (i.e., s[rgp]*) to repeat a previous substitution,
  129. X    2) `W' for appending text to an existing file,
  130. X    3) `wq' for exiting after a write, and
  131. X    4) `z' for scrolling through the buffer.
  132. XBSD line addressing syntax (i.e., `^' and `%').  is also recognized.
  133. X
  134. XThe POSIX interactive global commands `G' and `V' are extended to support
  135. Xmultiple commands, including `a', `i' and `c'.  The command format is the
  136. Xsame as for the global commands `g' and `v', i.e., one command per line
  137. Xwith each line, except for the last, ending in a backslash (\).
  138. X
  139. XIf crypt is available, files can be read and written using DES encryption.
  140. XThe `x' command prompts the user to enter a key used for encrypting/
  141. Xdecrypting subsequent reads and writes.  If only a newline is entered as
  142. Xthe key, then encryption is disabled.  Otherwise, a key is read in the
  143. Xsame manner as a password entry.  The key remains in effect until
  144. Xencryption is disabled.  For more information on the encryption algorithm,
  145. Xsee the bdes(1) man page.  Encryption/decryption should be fully compatible
  146. Xwith SunOS DES.
  147. X
  148. XAn extension to the POSIX file commands `E', `e', `r', `W' and `w' is that
  149. X<file> arguments are processed for backslash escapes, i.e.,  any character
  150. Xpreceded by a backslash is interpreted literally.  If the first unescaped
  151. Xcharacter of a <file> argument is a bang (!), then the rest of the line
  152. Xis interpreted as a shell command, and no escape processing is performed
  153. Xby ed.
  154. X
  155. XThe vi editor's bang command syntax is supported, i.e.,
  156. X(addr1,addr2) !<shell-cmd> replaces the addressed lines with the output of 
  157. X    the command <shell-cmd>.
  158. X[rwe] !! reads/writes/edits the previous !<shell-cmd>.
  159. X
  160. XIf ed is invoked with a name argument prefixed by a bang, then the
  161. Xremainder of the argument is interpreted as a shell command.  To invoke
  162. Xed on a file whose name starts with bang, prefix the name with a backslash.
  163. X
  164. Xed runs in restricted mode if invoked as red.  This limits editing of
  165. Xfiles in the local directory only and prohibits !<shell-cmd> commands.
  166. X
  167. XThough ed is not a binary editor, it can be used (if painfully) to edit
  168. Xbinary files.  To assist in binary editing, when a file containing at
  169. Xleast one ASCII NUL character is written, a newline is not appended
  170. Xif it did not already contain one upon reading.
  171. END_OF_FILE
  172.   if test 2651 -ne `wc -c <'POSIX'`; then
  173.     echo shar: \"'POSIX'\" unpacked with wrong size!
  174.   fi
  175.   # end of 'POSIX'
  176. fi
  177. if test -f 'signal.c' -a "${1}" != "-c" ; then 
  178.   echo shar: Will not clobber existing file \"'signal.c'\"
  179. else
  180.   echo shar: Extracting \"'signal.c'\" \(2471 characters\)
  181.   sed "s/^X//" >'signal.c' <<'END_OF_FILE'
  182. X/*
  183. X * Copyright (c) 1985, 1989 Regents of the University of California.
  184. X * All rights reserved.
  185. X *
  186. X * Redistribution and use in source and binary forms, with or without
  187. X * modification, are permitted provided that the following conditions
  188. X * are met:
  189. X * 1. Redistributions of source code must retain the above copyright
  190. X *    notice, this list of conditions and the following disclaimer.
  191. X * 2. Redistributions in binary form must reproduce the above copyright
  192. X *    notice, this list of conditions and the following disclaimer in the
  193. X *    documentation and/or other materials provided with the distribution.
  194. X * 3. All advertising materials mentioning features or use of this software
  195. X *    must display the following acknowledgement:
  196. X *    This product includes software developed by the University of
  197. X *    California, Berkeley and its contributors.
  198. X * 4. Neither the name of the University nor the names of its contributors
  199. X *    may be used to endorse or promote products derived from this software
  200. X *    without specific prior written permission.
  201. X *
  202. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  203. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  204. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  205. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  206. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  207. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  208. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  209. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  210. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  211. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  212. X * SUCH DAMAGE.
  213. X */
  214. X
  215. X#if defined(LIBC_SCCS) && !defined(lint)
  216. Xstatic char sccsid[] = "@(#)signal.c    5.5 (Berkeley) 6/1/90";
  217. X#endif /* LIBC_SCCS and not lint */
  218. X
  219. X/*
  220. X * Almost backwards compatible signal.
  221. X */
  222. X#include <signal.h>
  223. X
  224. X#ifdef signal
  225. X# undefine signal
  226. X#endif
  227. X
  228. Xsigset_t _sigintr;        /* shared with siginterrupt */
  229. X
  230. Xvoid
  231. X(*signal(s, a))()
  232. X    int s;
  233. X    void (*a)();
  234. X{
  235. X    struct sigaction sa, osa;
  236. X
  237. X    sa.sa_handler = a;
  238. X    sigemptyset(&sa.sa_mask);
  239. X    sa.sa_flags = 0;
  240. X    if (!sigismember(&_sigintr, s))
  241. X#ifdef SA_RESTART
  242. X        sa.sa_flags |= SA_RESTART;
  243. X#else
  244. X        sa.sa_flags &= ~SA_INTERRUPT;
  245. X#endif
  246. X    if (sigaction(s, &sa, &osa) < 0)
  247. X        return (BADSIG);
  248. X    return (osa.sa_handler);
  249. X}
  250. END_OF_FILE
  251.   if test 2471 -ne `wc -c <'signal.c'`; then
  252.     echo shar: \"'signal.c'\" unpacked with wrong size!
  253.   fi
  254.   # end of 'signal.c'
  255. fi
  256. echo shar: End of archive 3 \(of 3\).
  257. cp /dev/null ark3isdone
  258. MISSING=""
  259. for I in 1 2 3 ; do
  260.     if test ! -f ark${I}isdone ; then
  261.     MISSING="${MISSING} ${I}"
  262.     fi
  263. done
  264. if test "${MISSING}" = "" ; then
  265.     echo You have unpacked all 3 archives.
  266.     rm -f ark[1-9]isdone
  267. else
  268.     echo You still must unpack the following archives:
  269.     echo "        " ${MISSING}
  270. fi
  271. exit 0
  272. exit 0 # Just in case...
  273.