snapshot of project "mawk", label t20100220

This commit is contained in:
Thomas E. Dickey 2010-02-21 02:05:44 -05:00
parent 3eab34ea87
commit eabf806247
11 changed files with 169 additions and 60 deletions

12
CHANGES
View File

@ -1,8 +1,16 @@
-- $MawkId: CHANGES,v 1.100 2010/02/17 11:48:46 tom Exp $
-- $MawkId: CHANGES,v 1.102 2010/02/21 00:19:40 tom Exp $
Changes by Thomas E Dickey <dickey@invisible-island.net>
20100217
20100220
+ modify mawktest script to report results from all tests, rather than
halting on the first failure.
+ add limit-check after processing match(test, "[^0-9A-Za-z]") to
ensure the internal trailing null of the test-string is not mistaken
for part of the string, i.e., RSTART, RLENGTH are computed correctly
(report by Markus Gnam).
+ modify parsing of -W option to use comma-separated values, e.g.,
"-Wi,e" for "-Winteractive" and "-Werror".

View File

@ -1,4 +1,4 @@
MANIFEST for mawk, version t20100217
MANIFEST for mawk, version t20100220
--------------------------------------------------------------------------------
MANIFEST this file
ACKNOWLEDGMENT acknowledgements
@ -90,6 +90,7 @@ examples/nocomment.awk remove C comments from a list of files
examples/primes.awk find all primes between 2 and STOP (parameter)
examples/qsort.awk qsort text files
man subdirectory
man/Makefile makefile for alternate doc-formats
man/TODO to-do list (update to conform with POSIX-1003.1-2004)
man/mawk.1 troff source for unix style man pages
man/mawk.doc ascii man pages
@ -139,6 +140,7 @@ test/reg-awk.out reference for testing regular expressions
test/reg0.awk test simple pattern matching
test/reg1.awk test pattern with "|" OR
test/reg2.awk test pattern with ranges
test/reg3.awk testcase for pattern
test/reg4.awk test-case for square-brackets and embedded "/" or "]"
test/reg5.awk test-case for character-classes
test/reg6.awk testcase for J2C machine state

View File

@ -10,7 +10,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: files.c,v 1.12 2009/12/17 00:06:51 tom Exp $
* $MawkId: files.c,v 1.13 2010/02/21 01:32:50 tom Exp $
* @Log: files.c,v @
* Revision 1.9 1996/01/14 17:14:10 mike
* flush_all_output()
@ -506,7 +506,7 @@ remove_from_child_list(int pid)
int
wait_for(int pid)
{
int exit_status;
int exit_status = 0;
struct child *p;
int id;

4
fin.c
View File

@ -10,7 +10,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: fin.c,v 1.23 2010/01/29 20:03:43 Jan.Psota Exp $
* $MawkId: fin.c,v 1.24 2010/02/21 01:45:21 tom Exp $
* @Log: fin.c,v @
* Revision 1.10 1995/12/24 22:23:22 mike
* remove errmsg() from inside FINopen
@ -317,7 +317,7 @@ FINgets(FIN * fin, unsigned *len_p)
unsigned rr;
unsigned amount = (unsigned) (fin->limit - p);
p = (char *) memcpy(fin->buff, p, r = (unsigned) (fin->limit - p));
p = (char *) memmove(fin->buff, p, r = (unsigned) (fin->limit - p));
q = p + r;
rr = fin->nbuffs * BUFFSZ - r;

41
man/Makefile Normal file
View File

@ -0,0 +1,41 @@
# $MawkId: Makefile,v 1.1 2010/02/17 21:49:26 tom Exp $
# produce alternate forms from mawk's documentation.
SHELL=/bin/sh
PROG = mawk
manext = 1
.SUFFIXES : .html .$(manext) .man .ps .pdf .doc .txt
.$(manext).html :
GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Thtml -man" >$@
.$(manext).ps :
$(SHELL) -c "tbl $*.$(manext) | groff -man" >$@
.$(manext).doc :
GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man" >$@
.$(manext).txt :
GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man | col -bx" >$@
.ps.pdf :
ps2pdf $*.ps
ALL = \
$(PROG).html \
$(PROG).pdf \
$(PROG).ps \
$(PROG).txt \
all: $(PROG).doc $(ALL)
clean:
rm -f $(ALL)
distclean: clean
maintainer-clean:
$(PROG).pdf : $(PROG).ps

View File

@ -1,6 +1,6 @@
/*
* $MawkId: patchlev.h,v 1.17 2010/02/17 11:41:46 tom Exp $
* $MawkId: patchlev.h,v 1.18 2010/02/21 00:18:47 tom Exp $
*/
#define PATCHLEVEL 3
#define PATCH_STRING ".4"
#define DATE_STRING "20100217"
#define DATE_STRING "20100220"

10
rexp3.c
View File

@ -10,7 +10,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: rexp3.c,v 1.19 2010/02/17 11:38:24 Jonathan.Nieder Exp $
* $MawkId: rexp3.c,v 1.22 2010/02/21 02:05:44 tom Exp $
* @Log: rexp3.c,v @
* Revision 1.3 1993/07/24 17:55:15 mike
* more cleanup
@ -157,7 +157,10 @@ REmatch(char *str, /* string to test */
goto reswitch;
case M_STR + U_ON + END_OFF:
if (!(s = str_str(s, str_len, m->s_data.str, m->s_len))) {
if (s >= str_end) {
goto refill;
}
if (!(s = str_str(s, (unsigned) (str_end - s), m->s_data.str, m->s_len))) {
goto refill;
}
if (s >= str + strlen(str)) {
@ -237,6 +240,9 @@ REmatch(char *str, /* string to test */
s++;
}
}
if (s >= str_end) {
goto refill;
}
s++;
push(m, s, sp, ss, U_ON);
if (!ss) {

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MawkId: mawktest,v 1.24 2010/02/17 11:38:24 Jonathan.Nieder Exp $
# $MawkId: mawktest,v 1.27 2010/02/21 01:06:26 tom Exp $
# This is a simple test that a new made mawk seems to
# be working OK.
@ -9,6 +9,46 @@
# It needs to be run from mawk/test
# and mawk needs to be in mawk/test or in PATH
# POSIX shells have functions...
Fail() {
echo "?? fail $*"
FAIL=`expr $FAIL + 1`
ERRS=`expr $ERRS + 1`
}
Begin() {
echo
echo "$*"
OK=OK
FAIL=0
}
Finish() {
if test $FAIL = 1
then
echo "$* had one failure"
elif test $FAIL != 0
then
echo "$* had $FAIL failures"
else
echo "$* OK"
fi
}
ERRS=0
Summary() {
if test $ERRS = 1
then
echo "$* had one failure"
elif test $ERRS != 0
then
echo "$* had $ERRS failures"
else
echo "$* OK"
fi
}
PROG=mawk
MAWKBINMODE=7
@ -26,7 +66,9 @@ nulldat=mawknull.dat
STDOUT=${TMPDIR-/tmp}/mawk-out$$
STDERR=${TMPDIR-/tmp}/mawk-err$$
ulimit -v 25000
# The ulimit command interfers with valgrind (uncomment for ad hoc testing).
#ulimit -v 25000
trap 'echo mawk_test failed ; rm -f $STDOUT $STDERR; exit 1' 0
PATH=.:$PATH
@ -36,60 +78,65 @@ $PROG -W version
NULLS=`$PROG -W version 2>&1 |fgrep 'internal regex' 2>/dev/null`
#################################
echo
echo testing input and field splitting
Begin "testing input and field splitting"
LC_ALL=C $PROG -f wc.awk $dat | cmp -s - wc-awk.out || exit
LC_ALL=C $PROG -f null-rs.awk null-rs.dat | cmp -s - null-rs.out || exit
LC_ALL=C $PROG -f wc.awk $dat | cmp -s - wc-awk.out || Fail "wc.awk"
LC_ALL=C $PROG -f null-rs.awk null-rs.dat | cmp -s - null-rs.out || Fail "null-rs.awk"
LC_ALL=C $PROG -F '(a?)*b' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 2"
LC_ALL=C $PROG -F '(a?)+b' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 3"
LC_ALL=C $PROG -F '[^^]' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F '(.)' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F '(.)' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 4"
LC_ALL=C $PROG -F '[^]]' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F '[[#a-zA-Z0-9/*!=<>+,;.&_%(){}" -]' -f wc.awk $dat |
cmp -s - $STDOUT || exit
cmp -s - $STDOUT || Fail "case 5"
LC_ALL=C $PROG -F '[a[]' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F '[[a]' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F '[[a]' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 6"
LC_ALL=C $PROG -F '(])' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F '[]]' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F '[]]' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 7"
# check that the regexp [\ does not make mawk segfault
LC_ALL=C $PROG -F '[\' 2> $STDERR || exit
LC_ALL=C $PROG -F '[\' 2> $STDERR || Fail "case 8"
LC_ALL=C $PROG -F '(^)?)' -f wc.awk $dat > $STDOUT
LC_ALL=C $PROG -F ')' -f wc.awk $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG -F ')' -f wc.awk $dat | cmp -s - $STDOUT || Fail "case 9"
echo baaab | LC_ALL=C $PROG -F 'a*+' '{print NF}' > $STDOUT
echo baaab | LC_ALL=C $PROG -F 'a*' '{print NF}' | cmp -s - $STDOUT || exit
echo baaab | LC_ALL=C $PROG -F 'a*' '{print NF}' | cmp -s - $STDOUT || Fail "case 10"
if test -n "$NULLS" ; then
LC_ALL=C $PROG -F '\000' -f nulls0.awk $nulldat > $STDOUT
LC_ALL=C $PROG -F '[\000 ]' -f nulls0.awk $nulldat >> $STDOUT
cmp -s nulls.out $STDOUT || exit
echo "... $PROG supports matches with NUL bytes"
if ( cmp -s nulls.out $STDOUT )
then
echo "... $PROG supports matches with NUL bytes"
else
echo "... $PROG does NOT supports matches with NUL bytes"
fi
fi
echo input and field splitting OK
Finish "input and field splitting"
#####################################
echo
echo testing regular expression matching
Begin "testing regular expression matching"
LC_ALL=C $PROG -f reg0.awk $dat > $STDOUT
LC_ALL=C $PROG -f reg1.awk $dat >> $STDOUT
LC_ALL=C $PROG -f reg2.awk $dat >> $STDOUT
LC_ALL=C $PROG -f reg3.awk $dat >> $STDOUT
LC_ALL=C $PROG -f reg4.awk $dat >> $STDOUT
LC_ALL=C $PROG -f reg5.awk $dat >> $STDOUT
LC_ALL=C $PROG -f reg6.awk $dat >> $STDOUT
cmp -s reg-awk.out $STDOUT || exit
cmp -s reg-awk.out $STDOUT || Fail "reg0-reg6 case"
# 640 backslashes
backslashes='\\\\\\\\\\'
@ -97,68 +144,66 @@ backslashes="$backslashes$backslashes$backslashes$backslashes"
backslashes="$backslashes$backslashes$backslashes$backslashes"
backslashes="$backslashes$backslashes$backslashes$backslashes"
backslashes="$backslashes$backslashes$backslashes$backslashes"
( set +e; LC_ALL=C $PROG "/a$backslashes/" $dat 2> $STDERR ; test $? = 2 ) || exit
( set +e; LC_ALL=C $PROG "/a$backslashes/" $dat 2> $STDERR ; test $? = 2 ) || Fail "buffer-overflow"
# To be uncommented when they stop taking so long to run.
echo "''Italics with an apostrophe' embedded''" |
LC_ALL=C $PROG -f noloop.awk || exit
LC_ALL=C $PROG -f noloop.awk || Fail "noloop2 test"
#echo "''Italics with an apostrophe'' embedded''" |
# LC_ALL=C $PROG -f noloop.awk || exit
# LC_ALL=C $PROG -f noloop.awk || Fail "noloop1 test"
LC_ALL=C $PROG '/^[^^]*$/' $dat > $STDOUT
cmp -s $dat $STDOUT || exit
cmp -s $dat $STDOUT || Fail "case 1"
LC_ALL=C $PROG '!/^[^]]*$/' $dat > $STDOUT
LC_ALL=C $PROG '/]/' $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG '/]/' $dat | cmp -s - $STDOUT || Fail "case 2"
LC_ALL=C $PROG '/[a[]/' $dat > $STDOUT
LC_ALL=C $PROG '/[[a]/' $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG '/[[a]/' $dat | cmp -s - $STDOUT || Fail "case 3"
LC_ALL=C $PROG '/]/' $dat > $STDOUT
LC_ALL=C $PROG '/[]]/' $dat | cmp -s - $STDOUT || exit
LC_ALL=C $PROG '/[]]/' $dat | cmp -s - $STDOUT || Fail "case 4"
echo aaa | LC_ALL=C $PROG '/a*+/' > $STDOUT
echo aaa | LC_ALL=C $PROG '/a*/' | cmp -s - $STDOUT || exit
echo aaa | cmp -s - $STDOUT || exit
echo aaa | LC_ALL=C $PROG '/a*/' | cmp -s - $STDOUT || Fail "case 5"
echo aaa | cmp -s - $STDOUT || Fail "case 6"
Finish "regular expression matching"
echo regular expression matching OK
#######################################
echo
if [ -c /dev/full ]; then
echo testing checking for write errors
Begin "testing checking for write errors"
# Check for write errors noticed when closing the file
LC_ALL=C $PROG '{print}' <full-awk.dat >/dev/full 2>/dev/null && exit
LC_ALL=C $PROG '{print}' <full-awk.dat >/dev/full 2>/dev/null && Fail "case 1"
# Check for write errors noticed on writing
# The file has to be bigger than the buffer size of the libc
LC_ALL=C $PROG '{print}' <$SRC/scan.c >/dev/full 2>/dev/null && exit
LC_ALL=C $PROG '{print}' <$SRC/scan.c >/dev/full 2>/dev/null && Fail "case 2"
echo checking for write errors OK
Finish "checking for write errors"
else
echo
echo "No /dev/full - check for write errors skipped"
fi
#######################################
echo
echo testing arrays and flow of control
Begin "testing arrays and flow of control"
LC_ALL=C $PROG -f wfrq0.awk $dat | cmp -s - wfrq-awk.out || exit
LC_ALL=C $PROG -f wfrq0.awk $dat | cmp -s - wfrq-awk.out || Fail
Finish "array test"
echo array test OK
#################################
echo
echo testing function calls and general stress test
Begin "testing function calls and general stress test"
LC_ALL=C $PROG -f $SRC/examples/decl.awk $dat | cmp -s - decl-awk.out || exit
LC_ALL=C $PROG -f $SRC/examples/decl.awk $dat | cmp -s - decl-awk.out || Fail
echo general stress test passed
Finish "general stress test"
echo
echo tested $PROG seems OK
Summary "tested $PROG"
trap 0
rm -f $STDOUT
exit 0
exit $ERRS

View File

@ -1,5 +1,5 @@
echo off
rem $MawkId: mawktest.bat,v 1.4 2009/07/27 18:59:23 tom Exp $
rem $MawkId: mawktest.bat,v 1.5 2010/02/21 01:04:23 tom Exp $
rem vile:rs=lf
rem
rem This is a simple test that a new made mawk seems to
@ -35,6 +35,7 @@ echo testing regular expression matching
..\mawk -f reg0.awk %dat% > temp$$
..\mawk -f reg1.awk %dat% >> temp$$
..\mawk -f reg2.awk %dat% >> temp$$
..\mawk -f reg3.awk %dat% >> temp$$
..\mawk -f reg4.awk %dat% >> temp$$
..\mawk -f reg5.awk %dat% >> temp$$
%CMP% temp$$ reg-awk.out

View File

@ -1,6 +1,7 @@
3
4
1
0 -1
reg4.1<<: >>
reg4.2<<: >>
reg4.3<<: >>

5
test/reg3.awk Normal file
View File

@ -0,0 +1,5 @@
BEGIN {
test = "MFG"
match(test, "[^0-9A-Za-z]")
print RSTART, RLENGTH
}