commit 2795390efdf0781bff7d8f3cf5980ab198e6e1fa
parent 333f1304257cc023a1429b52e54fb942083a8472
Author: sin <sin@2f30.org>
Date: Tue, 18 Nov 2014 15:56:50 +0000
Remove files
Diffstat:
D | sed/POSIX | | | 199 | ------------------------------------------------------------------------------- |
D | sed/TEST/hanoi.sed | | | 103 | ------------------------------------------------------------------------------- |
D | sed/TEST/math.sed | | | 164 | ------------------------------------------------------------------------------- |
D | sed/TEST/sed.test | | | 549 | ------------------------------------------------------------------------------- |
D | sed/TODO | | | 1 | - |
5 files changed, 0 insertions(+), 1016 deletions(-)
diff --git a/sed/POSIX b/sed/POSIX
@@ -1,199 +0,0 @@
-# $OpenBSD: POSIX,v 1.2 1996/06/26 05:39:04 deraadt Exp $
-# from: @(#)POSIX 8.1 (Berkeley) 6/6/93
-
-Comments on the IEEE P1003.2 Draft 12
- Part 2: Shell and Utilities
- Section 4.55: sed - Stream editor
-
-Diomidis Spinellis <dds@doc.ic.ac.uk>
-Keith Bostic <bostic@cs.berkeley.edu>
-
-In the following paragraphs, "wrong" usually means "inconsistent with
-historic practice", as most of the following comments refer to
-undocumented inconsistencies between the historical versions of sed and
-the POSIX 1003.2 standard. All the comments are notes taken while
-implementing a POSIX-compatible version of sed, and should not be
-interpreted as official opinions or criticism towards the POSIX committee.
-All uses of "POSIX" refer to section 4.55, Draft 12 of POSIX 1003.2.
-
- 1. 32V and BSD derived implementations of sed strip the text
- arguments of the a, c and i commands of their initial blanks,
- i.e.
-
- #!/bin/sed -f
- a\
- foo\
- \ indent\
- bar
-
- produces:
-
- foo
- indent
- bar
-
- POSIX does not specify this behavior as the System V versions of
- sed do not do this stripping. The argument against stripping is
- that it is difficult to write sed scripts that have leading blanks
- if they are stripped. The argument for stripping is that it is
- difficult to write readable sed scripts unless indentation is allowed
- and ignored, and leading whitespace is obtainable by entering a
- backslash in front of it. This implementation follows the BSD
- historic practice.
-
- 2. Historical versions of sed required that the w flag be the last
- flag to an s command as it takes an additional argument. This
- is obvious, but not specified in POSIX.
-
- 3. Historical versions of sed required that whitespace follow a w
- flag to an s command. This is not specified in POSIX. This
- implementation permits whitespace but does not require it.
-
- 4. Historical versions of sed permitted any number of whitespace
- characters to follow the w command. This is not specified in
- POSIX. This implementation permits whitespace but does not
- require it.
-
- 5. The rule for the l command differs from historic practice. Table
- 2-15 includes the various ANSI C escape sequences, including \\
- for backslash. Some historical versions of sed displayed two
- digit octal numbers, too, not three as specified by POSIX. POSIX
- is a cleanup, and is followed by this implementation.
-
- 6. The POSIX specification for ! does not specify that for a single
- command the command must not contain an address specification
- whereas the command list can contain address specifications. The
- specification for ! implies that "3!/hello/p" works, and it never
- has, historically. Note,
-
- 3!{
- /hello/p
- }
-
- does work.
-
- 7. POSIX does not specify what happens with consecutive ! commands
- (e.g. /foo/!!!p). Historic implementations allow any number of
- !'s without changing the behaviour. (It seems logical that each
- one might reverse the behaviour.) This implementation follows
- historic practice.
-
- 8. Historic versions of sed permitted commands to be separated
- by semi-colons, e.g. 'sed -ne '1p;2p;3q' printed the first
- three lines of a file. This is not specified by POSIX.
- Note, the ; command separator is not allowed for the commands
- a, c, i, w, r, :, b, t, # and at the end of a w flag in the s
- command. This implementation follows historic practice and
- implements the ; separator.
-
- 9. Historic versions of sed terminated the script if EOF was reached
- during the execution of the 'n' command, i.e.:
-
- sed -e '
- n
- i\
- hello
- ' </dev/null
-
- did not produce any output. POSIX does not specify this behavior.
- This implementation follows historic practice.
-
-10. Deleted.
-
-11. Historical implementations do not output the change text of a c
- command in the case of an address range whose first line number
- is greater than the second (e.g. 3,1). POSIX requires that the
- text be output. Since the historic behavior doesn't seem to have
- any particular purpose, this implementation follows the POSIX
- behavior.
-
-12. POSIX does not specify whether address ranges are checked and
- reset if a command is not executed due to a jump. The following
- program will behave in different ways depending on whether the
- 'c' command is triggered at the third line, i.e. will the text
- be output even though line 3 of the input will never logically
- encounter that command.
-
- 2,4b
- 1,3c\
- text
-
- Historic implementations, and this implementation, do not output
- the text in the above example. The general rule, therefore,
- is that a range whose second address is never matched extends to
- the end of the input.
-
-13. Historical implementations allow an output suppressing #n at the
- beginning of -e arguments as well as in a script file. POSIX
- does not specify this. This implementation follows historical
- practice.
-
-14. POSIX does not explicitly specify how sed behaves if no script is
- specified. Since the sed Synopsis permits this form of the command,
- and the language in the Description section states that the input
- is output, it seems reasonable that it behave like the cat(1)
- command. Historic sed implementations behave differently for "ls |
- sed", where they produce no output, and "ls | sed -e#", where they
- behave like cat. This implementation behaves like cat in both cases.
-
-15. The POSIX requirement to open all w files at the beginning makes
- sed behave nonintuitively when the w commands are preceded by
- addresses or are within conditional blocks. This implementation
- follows historic practice and POSIX, by default, and provides the
- -a option which opens the files only when they are needed.
-
-16. POSIX does not specify how escape sequences other than \n and \D
- (where D is the delimiter character) are to be treated. This is
- reasonable, however, it also doesn't state that the backslash is
- to be discarded from the output regardless. A strict reading of
- POSIX would be that "echo xyz | sed s/./\a" would display "\ayz".
- As historic sed implementations always discarded the backslash,
- this implementation does as well.
-
-17. POSIX specifies that an address can be "empty". This implies
- that constructs like ",d" or "1,d" and ",5d" are allowed. This
- is not true for historic implementations or this implementation
- of sed.
-
-18. The b t and : commands are documented in POSIX to ignore leading
- white space, but no mention is made of trailing white space.
- Historic implementations of sed assigned different locations to
- the labels "x" and "x ". This is not useful, and leads to subtle
- programming errors, but it is historic practice and changing it
- could theoretically break working scripts. This implementation
- follows historic practice.
-
-19. Although POSIX specifies that reading from files that do not exist
- from within the script must not terminate the script, it does not
- specify what happens if a write command fails. Historic practice
- is to fail immediately if the file cannot be opened or written.
- This implementation follows historic practice.
-
-20. Historic practice is that the \n construct can be used for either
- string1 or string2 of the y command. This is not specified by
- POSIX. This implementation follows historic practice.
-
-21. Deleted.
-
-22. Historic implementations of sed ignore the RE delimiter characters
- within character classes. This is not specified in POSIX. This
- implementation follows historic practice.
-
-23. Historic implementations handle empty RE's in a special way: the
- empty RE is interpreted as if it were the last RE encountered,
- whether in an address or elsewhere. POSIX does not document this
- behavior. For example the command:
-
- sed -e /abc/s//XXX/
-
- substitutes XXX for the pattern abc. The semantics of "the last
- RE" can be defined in two different ways:
-
- 1. The last RE encountered when compiling (lexical/static scope).
- 2. The last RE encountered while running (dynamic scope).
-
- While many historical implementations fail on programs depending
- on scope differences, the SunOS version exhibited dynamic scope
- behaviour. This implementation does dynamic scoping, as this seems
- the most useful and in order to remain consistent with historical
- practice.
diff --git a/sed/TEST/hanoi.sed b/sed/TEST/hanoi.sed
@@ -1,103 +0,0 @@
-# $OpenBSD: hanoi.sed,v 1.2 1996/06/26 05:39:09 deraadt Exp $
-# Towers of Hanoi in sed.
-#
-# from: @(#)hanoi.sed 8.1 (Berkeley) 6/6/93
-#
-#
-# Ex:
-# Run "sed -f hanoi.sed", and enter:
-#
-# :abcd: : :<CR><CR>
-#
-# note -- TWO carriage returns, a peculiarity of sed), this will output the
-# sequence of states involved in moving 4 rings, the largest called "a" and
-# the smallest called "d", from the first to the second of three towers, so
-# that the rings on any tower at any time are in descending order of size.
-# You can start with a different arrangement and a different number of rings,
-# say :ce:b:ax: and it will give the shortest procedure for moving them all
-# to the middle tower. The rules are: the names of the rings must all be
-# lower-case letters, they must be input within 3 fields (representing the
-# towers) and delimited by 4 colons, such that the letters within each field
-# are in alphabetical order (i.e. rings are in descending order of size).
-#
-# For the benefit of anyone who wants to figure out the script, an "internal"
-# line of the form
-# b:0abx:1a2b3 :2 :3x2
-# has the following meaning: the material after the three markers :1, :2,
-# and :3 represents the three towers; in this case the current set-up is
-# ":ab : :x :". The numbers after a, b and x in these fields indicate
-# that the next time it gets a chance, it will move a to tower 2, move b
-# to tower 3, and move x to tower 2. The string after :0 just keeps track
-# of the alphabetical order of the names of the rings. The b at the
-# beginning means that it is now dealing with ring b (either about to move
-# it, or re-evaluating where it should next be moved to).
-#
-# Although this version is "limited" to 26 rings because of the size of the
-# alphabet, one could write a script using the same idea in which the rings
-# were represented by arbitrary [strings][within][brackets], and in place of
-# the built-in line of the script giving the order of the letters of the
-# alphabet, it would accept from the user a line giving the ordering to be
-# assumed, e.g. [ucbvax][decvax][hplabs][foo][bar].
-#
-# George Bergman
-# Math, UC Berkeley 94720 USA
-
-# cleaning, diagnostics
-s/ *//g
-/^$/d
-/[^a-z:]/{a\
-Illegal characters: use only a-z and ":". Try again.
-d
-}
-/^:[a-z]*:[a-z]*:[a-z]*:$/!{a\
-Incorrect format: use\
-\ : string1 : string2 : string3 :<CR><CR>\
-Try again.
-d
-}
-/\([a-z]\).*\1/{a\
-Repeated letters not allowed. Try again.
-d
-}
-# initial formatting
-h
-s/[a-z]/ /g
-G
-s/^:\( *\):\( *\):\( *\):\n:\([a-z]*\):\([a-z]*\):\([a-z]*\):$/:1\4\2\3:2\5\1\3:3\6\1\2:0/
-s/[a-z]/&2/g
-s/^/abcdefghijklmnopqrstuvwxyz/
-:a
-s/^\(.\).*\1.*/&\1/
-s/.//
-/^[^:]/ba
-s/\([^0]*\)\(:0.*\)/\2\1:/
-s/^[^0]*0\(.\)/\1&/
-:b
-# outputting current state without markers
-h
-s/.*:1/:/
-s/[123]//gp
-g
-:c
-# establishing destinations
-/^\(.\).*\1:1/td
-/^\(.\).*:1[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:1[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-/^\(.\).*:1[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:2[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-/^\(.\).*:2[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:2[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:3[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:3[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:3[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-bc
-# iterate back to find smallest out-of-place ring
-:d
-s/^\(.\)\(:0[^:]*\([^:]\)\1.*:\([123]\)[^:]*\1\)\4/\3\2\4/
-td
-# move said ring (right, resp. left)
-s/^\(.\)\(.*\)\1\([23]\)\(.*:\3[^ ]*\) /\1\2 \4\1\3/
-s/^\(.\)\(.*:\([12]\)[^ ]*\) \(.*\)\1\3/\1\2\1\3\4 /
-tb
-s/.*/Done! Try another, or end with ^D./p
-d
diff --git a/sed/TEST/math.sed b/sed/TEST/math.sed
@@ -1,164 +0,0 @@
-# $OpenBSD: math.sed,v 1.2 1996/06/26 05:39:10 deraadt Exp $
-#
-# from: @(#)math.sed 8.1 (Berkeley) 6/6/93
-#
-# Addition and multiplication in sed.
-# ++ for a limited time only do (expr) too!!!
-#
-# Kevin S Braunsdorf, PUCC UNIX Group, ksb@cc.purdue.edu.
-#
-# Ex:
-# echo "4+7*3" | sed -f %f
-
-# make sure the expression is well formed
-s/[ ]//g
-/[+*\/-]$/{
- a\
- poorly formed expression, operator on the end
- q
-}
-/^[+*\/]/{
- a\
- poorly formed expression, leading operator
- q
-}
-
-# fill hold space with done token
-x
-s/^.*/done/
-x
-
-# main loop, process operators (*, + and () )
-: loop
-/^\+/{
- s///
- b loop
-}
-/^\(.*\)(\([^)]*\))\(.*\)$/{
- H
- s//\2/
- x
- s/^\(.*\)\n\(.*\)(\([^()]*\))\(.*\)$/()\2@\4@\1/
- x
- b loop
-}
-/^[0-9]*\*/b mul
-/^\([0-9]*\)\+\([0-9+*]*\*[0-9]*\)$/{
- s//\2+\1/
- b loop
-}
-/^[0-9]*\+/{
- s/$/=/
- b add
-}
-x
-/^done$/{
- x
- p
- d
-}
-/^()/{
- s///
- x
- G
- s/\(.*\)\n\([^@]*\)@\([^@]*\)@\(.*\)/\2\1\3/
- x
- s/[^@]*@[^@]*@\(.*\)/\1/
- x
- b loop
-}
-i\
-help, stack problem
-p
-x
-p
-q
-
-# turn mul into add until 1*x -> x
-: mul
-/^0*1\*/{
- s///
- b loop
-}
-/^\([0-9]*\)0\*/{
- s/^\([0-9]*\)0\*\([0-9]*\)/\1*\20/
- b mul
-}
-s/^\([0-9]*\)1\*/\10*/
-s/^\([0-9]*\)2\*/\11*/
-s/^\([0-9]*\)3\*/\12*/
-s/^\([0-9]*\)4\*/\13*/
-s/^\([0-9]*\)5\*/\14*/
-s/^\([0-9]*\)6\*/\15*/
-s/^\([0-9]*\)7\*/\16*/
-s/^\([0-9]*\)8\*/\17*/
-s/^\([0-9]*\)9\*/\18*/
-s/\*\([0-9*]*\)/*\1+\1/
-b mul
-
-# get rid of a plus term until 0+x -> x
-: add
-/^\+\([0-9+*]*\)=/{
- s//\1/
- b loop
-}
-/^\([0-9*]*\)\+=/{
- s//\1/
- b loop
-}
-/^\([0-9]*\)\+\([0-9*+]*\)\+=/{
- s//\2+\1/
- b loop
-}
-/^\([0-9]*\)0\+\([0-9]*\)\([0-9]\)=/{
- s//\1+\2=\3/
- b add
-}
-/^\([0-9]*\)\([0-9]\)\+\([0-9]*\)0=/{
- s//\1+\3=\2/
- b add
-}
-/^\([0-9]*\)0\+\([0-9*+]*\)\+\([0-9]*\)\([0-9]\)=/{
- s//\1+\2+\3=\4/
- b add
-}
-/^\([0-9]*\)\([0-9]\)\+\([0-9*+]*\)\+\([0-9]*\)0=/{
- s//\1+\3+\4=\2/
- b add
-}
-s/^\([0-9]*\)1\+/\10+/
-s/^\([0-9]*\)2\+/\11+/
-s/^\([0-9]*\)3\+/\12+/
-s/^\([0-9]*\)4\+/\13+/
-s/^\([0-9]*\)5\+/\14+/
-s/^\([0-9]*\)6\+/\15+/
-s/^\([0-9]*\)7\+/\16+/
-s/^\([0-9]*\)8\+/\17+/
-s/^\([0-9]*\)9\+/\18+/
-
-s/9=\([0-9]*\)$/_=\1/
-s/8=\([0-9]*\)$/9=\1/
-s/7=\([0-9]*\)$/8=\1/
-s/6=\([0-9]*\)$/7=\1/
-s/5=\([0-9]*\)$/6=\1/
-s/4=\([0-9]*\)$/5=\1/
-s/3=\([0-9]*\)$/4=\1/
-s/2=\([0-9]*\)$/3=\1/
-s/1=\([0-9]*\)$/2=\1/
-/_/{
- s//_0/
- : inc
- s/9_/_0/
- s/8_/9/
- s/7_/8/
- s/6_/7/
- s/5_/6/
- s/4_/5/
- s/3_/4/
- s/2_/3/
- s/1_/2/
- s/0_/1/
- s/\+_/+1/
- /_/b inc
-}
-b add
diff --git a/sed/TEST/sed.test b/sed/TEST/sed.test
@@ -1,549 +0,0 @@
-#!/bin/sh -
-# $OpenBSD: sed.test,v 1.4 2008/10/07 15:02:45 millert Exp $
-#
-# Copyright (c) 1992 Diomidis Spinellis.
-# Copyright (c) 1992, 1993
-# The Regents of the University of California. 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. Neither the name of the University nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
-#
-# from: @(#)sed.test 8.1 (Berkeley) 6/6/93
-#
-
-# sed Regression Tests
-#
-# The following files are created:
-# lines[1-4], script1, script2
-# Two directories *.out contain the test results
-
-main()
-{
- BASE=/usr/bin/sed
- BASELOG=sed.out
- TEST=./sed
- TESTLOG=nsed.out
- DICT=/usr/share/dict/words
-
- test_error | more
-
- awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
- awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
-
- exec 4>&1 5>&2
-
- # Set these flags to get messages about known problems
- BSD=0
- GNU=0
- SUN=0
- tests $BASE $BASELOG
-
- BSD=0
- GNU=0
- SUN=0
- tests $TEST $TESTLOG
- exec 1>&4 2>&5
- diff $BASELOG $TESTLOG | less
-}
-
-tests()
-{
- SED=$1
- DIR=$2
- rm -rf $DIR
- mkdir $DIR
- MARK=100
-
- test_args
- test_addr
- echo Testing commands
- test_group
- test_acid
- test_branch
- test_pattern
- test_print
- test_subst
-}
-
-mark()
-{
- MARK=`expr $MARK + 1`
- exec 1>&4 2>&5
- exec >"$DIR/${MARK}_$1"
- echo "Test $1:$MARK"
- # Uncomment this line to match tests with sed error messages
- echo "Test $1:$MARK" >&5
-}
-
-test_args()
-{
- mark '1.1'
- echo Testing argument parsing
- echo First type
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' lines1
- fi
- mark '1.2' ; $SED -n 's/^/e1_/p' lines1
- mark '1.3'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' <lines1
- fi
- mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
- echo Second type
- mark '1.4.1'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed fails this
- fi
- $SED -e '' <lines1
- echo 's/^/s1_/p' >script1
- echo 's/^/s2_/p' >script2
- mark '1.5'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 lines1
- fi
- mark '1.6'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 <lines1
- fi
- mark '1.7'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1
- fi
- mark '1.8'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' <lines1
- fi
- mark '1.9' ; $SED -n -f script1 lines1
- mark '1.10' ; $SED -n -f script1 <lines1
- mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
- mark '1.12'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -n -e 's/^/e1_/p' <lines1
- fi
- mark '1.13'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
- fi
- mark '1.14'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 -f script2 lines1
- fi
- mark '1.15'
- if [ $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo GNU and SunOS sed fail this following older POSIX draft
- else
- $SED -e 's/^/e1_/p' -f script1 lines1
- fi
- mark '1.16'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1 lines1
- fi
- # POSIX D11.2:11251
- mark '1.17' ; $SED p <lines1 lines1
-cat >script1 <<EOF
-#n
-# A comment
-
-p
-EOF
- mark '1.18' ; $SED -f script1 <lines1 lines1
-}
-
-test_addr()
-{
- echo Testing address ranges
- mark '2.1' ; $SED -n -e '4p' lines1
- mark '2.2' ; $SED -n -e '20p' lines1 lines2
- mark '2.3' ; $SED -n -e '$p' lines1
- mark '2.4' ; $SED -n -e '$p' lines1 lines2
- mark '2.5' ; $SED -n -e '$a\
-hello' /dev/null
- mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
- # Should not print anything
- mark '2.7' ; $SED -n -e '20p' lines1
- mark '2.8' ; $SED -n -e '0p' lines1
- mark '2.9' ; $SED -n '/l1_7/p' lines1
- mark '2.10' ; $SED -n ' /l1_7/ p' lines1
- mark '2.11'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '\_l1\_7_p' lines1
- mark '2.12' ; $SED -n '1,4p' lines1
- mark '2.13' ; $SED -n '1,$p' lines1 lines2
- mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2
- mark '2.15' ; $SED -n '/4/,$p' lines1 lines2
- mark '2.16' ; $SED -n '/4/,20p' lines1 lines2
- mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
- mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
- mark '2.19'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '12,3p' lines1 lines2
- mark '2.20'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '/l1_7/,3p' lines1 lines2
-}
-
-test_group()
-{
- echo Brace and other grouping
- mark '3.1' ; $SED -e '
-4,12 {
- s/^/^/
- s/$/$/
- s/_/T/
-}' lines1
- mark '3.2' ; $SED -e '
-4,12 {
- s/^/^/
- /6/,/10/ {
- s/$/$/
- /8/ s/_/T/
- }
-}' lines1
- mark '3.3' ; $SED -e '
-4,12 !{
- s/^/^/
- /6/,/10/ !{
- s/$/$/
- /8/ !s/_/T/
- }
-}' lines1
- mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
-}
-
-test_acid()
-{
- echo Testing a c d and i commands
- mark '4.1' ; $SED -n -e '
-s/^/before_i/p
-20i\
-inserted
-s/^/after_i/p
-' lines1 lines2
- mark '4.2' ; $SED -n -e '
-5,12s/^/5-12/
-s/^/before_a/p
-/5-12/a\
-appended
-s/^/after_a/p
-' lines1 lines2
- mark '4.3'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n -e '
-s/^/^/p
-/l1_/a\
-appended
-8,10N
-s/$/$/p
-' lines1 lines2
- mark '4.4' ; $SED -n -e '
-c\
-hello
-' lines1
- mark '4.5' ; $SED -n -e '
-8c\
-hello
-' lines1
- mark '4.6' ; $SED -n -e '
-3,14c\
-hello
-' lines1
-# SunOS and GNU sed behave differently. We follow POSIX
-# mark '4.7' ; $SED -n -e '
-#8,3c\
-#hello
-#' lines1
- mark '4.8' ; $SED d <lines1
-}
-
-test_branch()
-{
- echo Testing labels and branching
- mark '5.1' ; $SED -n -e '
-b label4
-:label3
-s/^/label3_/p
-b end
-:label4
-2,12b label1
-b label2
-:label1
-s/^/label1_/p
-b
-:label2
-s/^/label2_/p
-b label3
-:end
-' lines1
- mark '5.2'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-s/l1_/l2_/
-t ok
-b
-:ok
-s/^/tested /p
-' lines1 lines2
-# SunOS sed behaves differently here. Clarification needed.
-# mark '5.3' ; $SED -n -e '
-#5,8b inside
-#1,5 {
-# s/^/^/p
-# :inside
-# s/$/$/p
-#}
-#' lines1
-# Check that t clears the substitution done flag
- mark '5.4' ; $SED -n -e '
-1,8s/^/^/
-t l1
-:l1
-t l2
-s/$/$/p
-b
-:l2
-s/^/ERROR/
-' lines1
-# Check that reading a line clears the substitution done flag
- mark '5.5'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-t l2
-1,8s/^/^/p
-2,7N
-b
-:l2
-s/^/ERROR/p
-' lines1
- mark '5.6' ; $SED 5q lines1
- mark '5.7' ; $SED -e '
-5i\
-hello
-5q' lines1
-# Branch across block boundary
- mark '5.8' ; $SED -e '
-{
-:b
-}
-s/l/m/
-tb' lines1
-}
-
-test_pattern()
-{
-echo Pattern space commands
-# Check that the pattern space is deleted
- mark '6.1' ; $SED -n -e '
-c\
-changed
-p
-' lines1
- mark '6.2' ; $SED -n -e '
-4d
-p
-' lines1
-# SunOS sed refused to print here
-# mark '6.3' ; $SED -e '
-#N
-#N
-#N
-#D
-#P
-#4p
-#' lines1
- mark '6.4' ; $SED -e '
-2h
-3H
-4g
-5G
-6x
-6p
-6x
-6p
-' lines1
- mark '6.5' ; $SED -e '4n' lines1
- mark '6.6' ; $SED -n -e '4n' lines1
-}
-
-test_print()
-{
- echo Testing print and file routines
- awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
- </dev/null >lines3
- # GNU and SunOS sed behave differently here
- mark '7.1'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed drops core on this one; TEST SKIPPED'
- else
- $SED -n l lines3
- fi
- mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
- rm -f lines4
- mark '7.3' ; $SED -e '3,12w lines4' lines1
- echo w results
- cat lines4
- mark '7.4' ; $SED -e '4r lines2' lines1
- mark '7.5' ; $SED -e '5r /dev/dds' lines1
- mark '7.6' ; $SED -e '6r /dev/null' lines1
- mark '7.7'
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD, GNU and SunOS cannot pass this one
- else
- sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
- rm -rf tmpdir
- mkdir tmpdir
- $SED -f script1 lines1
- cat tmpdir/*
- rm -rf tmpdir
- fi
- mark '7.8'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed cannot pass 7.7
- else
- echo line1 > lines3
- echo "" >> lines3
- $SED -n -e '$p' lines3 /dev/null
- fi
-
-}
-
-test_subst()
-{
- echo Testing substitution commands
- mark '8.1' ; $SED -e 's/./X/g' lines1
- mark '8.2' ; $SED -e 's,.,X,g' lines1
-# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator
-# mark '8.3' ; $SED -e 's.\..X.g' lines1
-# POSIX does not say that this should work
-# mark '8.4' ; $SED -e 's/[/]/Q/' lines1
- mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
- mark '8.5' ; $SED -e 's_\__X_' lines1
- mark '8.6' ; $SED -e 's/./(&)/g' lines1
- mark '8.7' ; $SED -e 's/./(\&)/g' lines1
- mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
- mark '8.9' ; $SED -e 's/_/u0\
-u1\
-u2/g' lines1
- mark '8.10'
- if [ $BSD -eq 1 -o $GNU -eq 1 ] ; then
- echo 'BSD/GNU sed do not understand digit flags on s commands'
- fi
- $SED -e 's/./X/4' lines1
- rm -f lines4
- mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
- echo s wfile results
- cat lines4
- mark '8.12' ; $SED -e 's/[123]/X/g' lines1
- mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
- mark '8.14' ;
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD/GNU/SUN sed fail this test
- else
- $SED -e 'y10\123456789198765432\101' lines1
- fi
- mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
- mark '8.16'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed does not handle branch defined REs'
- else
- echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
- -e 's//Y/p' -e '/f/bx'
- fi
-}
-
-test_error()
-{
- exec 0>&3 4>&1 5>&2
- exec 0</dev/null
- exec 2>&1
- set -x
- $TEST -x && exit 1
- $TEST -f && exit 1
- $TEST -e && exit 1
- $TEST -f /dev/dds && exit 1
- $TEST p /dev/dds && exit 1
- $TEST -f /bin/sh && exit 1
- $TEST '{' && exit 1
- $TEST '{' && exit 1
- $TEST '/hello/' && exit 1
- $TEST '1,/hello/' && exit 1
- $TEST -e '-5p' && exit 1
- $TEST '/jj' && exit 1
- $TEST 'a hello' && exit 1
- $TEST 'a \ hello' && exit 1
- $TEST 'b foo' && exit 1
- $TEST 'd hello' && exit 1
- $TEST 's/aa' && exit 1
- $TEST 's/aa/' && exit 1
- $TEST 's/a/b' && exit 1
- $TEST 's/a/b/c/d' && exit 1
- $TEST 's/a/b/ 1 2' && exit 1
- $TEST 's/a/b/ 1 g' && exit 1
- $TEST 's/a/b/w' && exit 1
- $TEST 'y/aa' && exit 1
- $TEST 'y/aa/b/' && exit 1
- $TEST 'y/aa/' && exit 1
- $TEST 'y/a/b' && exit 1
- $TEST 'y/a/b/c/d' && exit 1
- $TEST '!' && exit 1
- $TEST supercalifrangolisticexprialidociussupercalifrangolisticexcius
- set +x
- exec 0>&3 1>&4 2>&5
-}
-
-main
diff --git a/sed/TODO b/sed/TODO
@@ -1 +0,0 @@
-workaround REG_STARTEND: http://www.polarhome.com/service/man/generic.php?qf=regex&tf=2&of=OpenBSD&sf=3