diff options
Diffstat (limited to 'x2p')
-rw-r--r-- | x2p/EXTERN.h | 4 | ||||
-rw-r--r-- | x2p/INTERN.h | 4 | ||||
-rw-r--r-- | x2p/Makefile | 134 | ||||
-rwxr-xr-x[-rw-r--r--] | x2p/Makefile.SH | 8 | ||||
-rw-r--r-- | x2p/a2p.c | 1607 | ||||
-rw-r--r-- | x2p/a2p.h | 6 | ||||
-rw-r--r-- | x2p/a2p.man | 4 | ||||
-rw-r--r-- | x2p/a2p.y | 4 | ||||
-rw-r--r-- | x2p/a2py.c | 5 | ||||
-rw-r--r-- | x2p/all | 0 | ||||
-rwxr-xr-x | x2p/cflags | 55 | ||||
-rwxr-xr-x[-rw-r--r--] | x2p/cflags.SH | 0 | ||||
l--------- | x2p/config.sh | 1 | ||||
-rwxr-xr-x | x2p/find2perl | 568 | ||||
-rwxr-xr-x[-rw-r--r--] | x2p/find2perl.SH | 26 | ||||
-rw-r--r-- | x2p/handy.h | 4 | ||||
-rw-r--r-- | x2p/hash.c | 4 | ||||
-rw-r--r-- | x2p/hash.h | 4 | ||||
-rw-r--r-- | x2p/make.out | 13 | ||||
-rw-r--r-- | x2p/makefile | 229 | ||||
-rw-r--r-- | x2p/malloc.c | 506 | ||||
-rwxr-xr-x | x2p/s2p | 760 | ||||
-rwxr-xr-x[-rw-r--r--] | x2p/s2p.SH | 4 | ||||
-rw-r--r-- | x2p/s2p.man | 4 | ||||
-rw-r--r-- | x2p/str.c | 4 | ||||
-rw-r--r-- | x2p/str.h | 4 | ||||
-rw-r--r-- | x2p/util.c | 4 | ||||
-rw-r--r-- | x2p/util.h | 4 | ||||
-rw-r--r-- | x2p/walk.c | 4 |
29 files changed, 3942 insertions, 32 deletions
diff --git a/x2p/EXTERN.h b/x2p/EXTERN.h index d6174c419e..6a77ad00cb 100644 --- a/x2p/EXTERN.h +++ b/x2p/EXTERN.h @@ -1,4 +1,4 @@ -/* $RCSfile: EXTERN.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:11:15 $ +/* $RCSfile: EXTERN.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:05 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: EXTERN.h,v $ + * Revision 4.1 92/08/07 18:29:05 lwall + * * Revision 4.0.1.1 91/06/07 12:11:15 lwall * patch4: new copyright notice * diff --git a/x2p/INTERN.h b/x2p/INTERN.h index 566531fc0d..64c528272d 100644 --- a/x2p/INTERN.h +++ b/x2p/INTERN.h @@ -1,4 +1,4 @@ -/* $RCSfile: INTERN.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:11:20 $ +/* $RCSfile: INTERN.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:06 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: INTERN.h,v $ + * Revision 4.1 92/08/07 18:29:06 lwall + * * Revision 4.0.1.1 91/06/07 12:11:20 lwall * patch4: new copyright notice * diff --git a/x2p/Makefile b/x2p/Makefile new file mode 100644 index 0000000000..1c6d4a9398 --- /dev/null +++ b/x2p/Makefile @@ -0,0 +1,134 @@ +# : Makefile.SH,v 15738Revision: 4.1 15738Date: 92/08/07 18:29:07 $ +# +# $Log: Makefile.SH,v $ +# Revision 4.1 92/08/07 18:29:07 lwall +# +# Revision 4.0.1.3 92/06/08 16:11:32 lwall +# patch20: SH files didn't work well with symbolic links +# patch20: cray didn't give enough memory to /bin/sh +# patch20: makefiles now display new shift/reduce expectations +# +# Revision 4.0.1.2 91/11/05 19:19:04 lwall +# patch11: random cleanup +# +# Revision 4.0.1.1 91/06/07 12:12:14 lwall +# patch4: cflags now emits entire cc command except for the filename +# +# Revision 4.0 91/03/20 01:57:03 lwall +# 4.0 baseline. +# +# + +CC = cc +YACC = /bin/yacc +bin = /usr/local/bin +lib = +mansrc = /usr/man/manl +manext = l +LDFLAGS = +SMALL = +LARGE = +mallocsrc = malloc.c +mallocobj = malloc.o +shellflags = + +libs = -ldbm -lm -lposix + +CCCMD = `sh $(shellflags) cflags $@` + +public = a2p s2p find2perl + +private = + +manpages = a2p.man s2p.man + +util = + +sh = Makefile.SH makedepend.SH + +h = EXTERN.h INTERN.h ../config.h handy.h hash.h a2p.h str.h util.h + +c = hash.c $(mallocsrc) str.c util.c walk.c + +obj = hash.o $(mallocobj) str.o util.o walk.o + +lintflags = -phbvxac + +addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7 + +# grrr +SHELL = /bin/sh + +.c.o: + $(CCCMD) $*.c + +all: $(public) $(private) $(util) + touch all + +a2p: $(obj) a2p.o + $(CC) $(LDFLAGS) $(obj) a2p.o $(libs) -o a2p + +a2p.c: a2p.y + @ echo Expect 231 shift/reduce conflicts... + $(YACC) a2p.y + mv y.tab.c a2p.c + +a2p.o: a2p.c a2py.c a2p.h EXTERN.h util.h INTERN.h handy.h ../config.h str.h hash.h + $(CCCMD) $(LARGE) a2p.c + +install: a2p s2p +# won't work with csh + export PATH || exit 1 + - mv $(bin)/a2p $(bin)/a2p.old 2>/dev/null + - mv $(bin)/s2p $(bin)/s2p.old 2>/dev/null + - if test `pwd` != $(bin); then cp $(public) $(bin); fi + cd $(bin); \ +for pub in $(public); do \ +chmod +x `basename $$pub`; \ +done + - if test `pwd` != $(mansrc); then \ +for page in $(manpages); do \ +cp $$page $(mansrc)/`basename $$page .man`.$(manext); \ +done; \ +fi + +clean: + rm -f a2p *.o a2p.c + +realclean: clean + rm -f *.orig */*.orig core $(addedbyconf) a2p.c s2p find2perl all cflags + +# The following lint has practically everything turned on. Unfortunately, +# you have to wade through a lot of mumbo jumbo that can't be suppressed. +# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message +# for that spot. + +lint: + lint $(lintflags) $(defs) $(c) > a2p.fuzz + +depend: $(mallocsrc) ../makedepend + ../makedepend + +clist: + echo $(c) | tr ' ' '\012' >.clist + +hlist: + echo $(h) | tr ' ' '\012' >.hlist + +shlist: + echo $(sh) | tr ' ' '\012' >.shlist + +config.sh: ../config.sh + rm -f config.sh + ln ../config.sh . + +malloc.c: ../malloc.c + sed <../malloc.c >malloc.c \ + -e 's/"perl.h"/"..\/perl.h"/' \ + -e 's/my_exit/exit/' + +# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE +$(obj): + @ echo "You haven't done a "'"make depend" yet!'; exit 1 +makedepend: makedepend.SH + /bin/sh $(shellflags) makedepend.SH diff --git a/x2p/Makefile.SH b/x2p/Makefile.SH index 6d8d735ca5..f3c1a8d3d7 100644..100755 --- a/x2p/Makefile.SH +++ b/x2p/Makefile.SH @@ -16,9 +16,11 @@ esac echo "Extracting x2p/Makefile (with variable substitutions)" rm -f Makefile cat >Makefile <<!GROK!THIS! -# $RCSfile: Makefile.SH,v $$Revision: 4.0.1.3 $$Date: 92/06/08 16:11:32 $ +# $RCSfile: Makefile.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:29:07 $ # # $Log: Makefile.SH,v $ +# Revision 4.1 92/08/07 18:29:07 lwall +# # Revision 4.0.1.3 92/06/08 16:11:32 lwall # patch20: SH files didn't work well with symbolic links # patch20: cray didn't give enough memory to /bin/sh @@ -142,7 +144,9 @@ config.sh: ../config.sh ln ../config.sh . malloc.c: ../malloc.c - sed 's/"perl.h"/"..\/perl.h"/' ../malloc.c >malloc.c + sed <../malloc.c >malloc.c \ + -e 's/"perl.h"/"..\/perl.h"/' \ + -e 's/my_exit/exit/' # AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE $(obj): diff --git a/x2p/a2p.c b/x2p/a2p.c new file mode 100644 index 0000000000..41636f0c17 --- /dev/null +++ b/x2p/a2p.c @@ -0,0 +1,1607 @@ +extern char *malloc(), *realloc(); + +# line 2 "a2p.y" +/* $RCSfile: a2p.y,v $$Revision: 4.0.1.2 $$Date: 92/06/08 16:13:03 $ + * + * Copyright (c) 1991, Larry Wall + * + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. + * + * $Log: a2p.y,v $ + * Revision 4.0.1.2 92/06/08 16:13:03 lwall + * patch20: in a2p, getline should allow variable to be array element + * + * Revision 4.0.1.1 91/06/07 12:12:41 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:57:21 lwall + * 4.0 baseline. + * + */ + +#include "INTERN.h" +#include "a2p.h" + +int root; +int begins = Nullop; +int ends = Nullop; + +# define BEGIN 257 +# define END 258 +# define REGEX 259 +# define SEMINEW 260 +# define NEWLINE 261 +# define COMMENT 262 +# define FUN1 263 +# define FUNN 264 +# define GRGR 265 +# define PRINT 266 +# define PRINTF 267 +# define SPRINTF 268 +# define SPLIT 269 +# define IF 270 +# define ELSE 271 +# define WHILE 272 +# define FOR 273 +# define IN 274 +# define EXIT 275 +# define NEXT 276 +# define BREAK 277 +# define CONTINUE 278 +# define RET 279 +# define GETLINE 280 +# define DO 281 +# define SUB 282 +# define GSUB 283 +# define MATCH 284 +# define FUNCTION 285 +# define USERFUN 286 +# define DELETE 287 +# define ASGNOP 288 +# define OROR 289 +# define ANDAND 290 +# define NUMBER 291 +# define VAR 292 +# define SUBSTR 293 +# define INDEX 294 +# define MATCHOP 295 +# define RELOP 296 +# define OR 297 +# define STRING 298 +# define UMINUS 299 +# define NOT 300 +# define INCR 301 +# define DECR 302 +# define FIELD 303 +# define VFIELD 304 +#define yyclearin yychar = -1 +#define yyerrok yyerrflag = 0 +extern int yychar; +extern int yyerrflag; +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 150 +#endif +#ifndef YYSTYPE +#define YYSTYPE int +#endif +YYSTYPE yylval, yyval; +# define YYERRCODE 256 + +# line 402 "a2p.y" + +#include "a2py.c" +int yyexca[] ={ +-1, 1, + 0, -1, + -2, 0, + }; +# define YYNPROD 137 +# define YYLAST 3142 +int yyact[]={ + + 63, 44, 156, 32, 50, 31, 222, 73, 74, 75, + 210, 53, 45, 46, 124, 49, 86, 307, 104, 158, + 74, 75, 52, 54, 53, 302, 126, 271, 306, 265, + 106, 107, 270, 245, 51, 157, 269, 21, 56, 92, + 2, 131, 55, 20, 48, 72, 19, 90, 69, 132, + 47, 196, 241, 102, 100, 272, 195, 193, 109, 110, + 111, 112, 253, 76, 79, 252, 72, 139, 15, 77, + 237, 68, 78, 311, 236, 160, 66, 64, 309, 65, + 293, 67, 187, 174, 255, 139, 198, 184, 183, 130, + 68, 80, 179, 129, 5, 66, 64, 71, 65, 128, + 67, 68, 286, 214, 199, 212, 66, 211, 105, 103, + 99, 67, 98, 97, 96, 95, 71, 108, 94, 89, + 88, 152, 87, 4, 153, 10, 9, 200, 69, 14, + 177, 178, 239, 140, 13, 3, 136, 137, 127, 1, + 0, 0, 0, 185, 186, 0, 72, 69, 151, 0, + 0, 154, 0, 0, 0, 0, 0, 0, 69, 0, + 0, 0, 0, 204, 205, 72, 0, 106, 107, 0, + 0, 0, 0, 0, 175, 176, 72, 213, 0, 215, + 76, 0, 140, 0, 0, 0, 77, 0, 0, 78, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 230, 231, 232, 233, 234, 235, 0, + 206, 207, 0, 0, 0, 0, 244, 0, 0, 0, + 159, 106, 107, 34, 35, 0, 162, 163, 37, 39, + 170, 0, 171, 173, 248, 166, 165, 164, 167, 168, + 33, 172, 42, 43, 41, 161, 36, 169, 44, 18, + 247, 27, 44, 38, 40, 54, 53, 249, 28, 45, + 46, 29, 30, 45, 46, 54, 53, 54, 53, 0, + 282, 18, 18, 238, 284, 285, 242, 243, 289, 290, + 54, 53, 240, 91, 54, 53, 0, 299, 300, 54, + 53, 0, 304, 0, 0, 6, 7, 8, 18, 0, + 0, 298, 0, 113, 114, 115, 116, 63, 70, 18, + 32, 310, 31, 313, 312, 315, 314, 316, 0, 18, + 0, 0, 303, 0, 247, 0, 158, 70, 201, 202, + 203, 0, 133, 135, 91, 91, 308, 287, 247, 141, + 143, 144, 145, 146, 147, 149, 91, 0, 0, 91, + 0, 301, 0, 0, 0, 18, 18, 0, 0, 0, + 63, 0, 0, 32, 0, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 181, 158, + 0, 0, 0, 0, 0, 0, 0, 0, 141, 0, + 174, 0, 305, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 91, 91, + 63, 0, 208, 32, 209, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, + 0, 219, 220, 0, 221, 0, 223, 225, 226, 227, + 228, 229, 0, 174, 0, 274, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 18, 0, + 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 63, 0, 0, 32, 0, 31, 0, 0, + 0, 0, 266, 0, 0, 0, 267, 268, 0, 0, + 0, 158, 0, 174, 0, 217, 275, 0, 276, 0, + 0, 0, 0, 0, 278, 0, 279, 0, 280, 0, + 281, 0, 0, 0, 0, 0, 0, 0, 18, 0, + 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, + 34, 35, 18, 162, 163, 37, 39, 170, 0, 171, + 173, 0, 166, 165, 164, 167, 168, 33, 172, 42, + 43, 41, 0, 36, 169, 174, 0, 216, 27, 44, + 38, 40, 0, 0, 0, 28, 0, 0, 29, 30, + 45, 46, 63, 0, 0, 32, 0, 31, 0, 0, + 159, 0, 0, 34, 35, 0, 162, 163, 37, 39, + 170, 0, 171, 173, 0, 166, 165, 164, 167, 168, + 33, 172, 42, 43, 41, 0, 36, 169, 0, 0, + 0, 27, 44, 38, 40, 0, 0, 0, 28, 0, + 0, 29, 30, 45, 46, 0, 25, 0, 0, 32, + 159, 31, 0, 34, 35, 0, 162, 163, 37, 39, + 170, 0, 171, 173, 0, 166, 165, 164, 167, 168, + 33, 172, 42, 43, 41, 0, 36, 169, 0, 0, + 0, 27, 44, 38, 40, 0, 0, 0, 28, 0, + 0, 29, 30, 45, 46, 63, 0, 0, 32, 0, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 159, 0, 158, 34, 35, 0, 162, 163, + 37, 39, 170, 0, 171, 173, 0, 166, 165, 164, + 167, 168, 33, 172, 42, 43, 41, 0, 36, 169, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 63, 0, 0, + 32, 0, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 158, 0, 174, 0, + 197, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 63, 0, 0, 32, 138, 31, 0, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 162, 163, + 37, 39, 59, 0, 58, 0, 0, 166, 165, 164, + 167, 168, 33, 0, 42, 43, 41, 0, 36, 169, + 174, 0, 155, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 24, 0, 106, 107, 34, + 35, 0, 0, 0, 37, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 26, 29, 30, 45, + 46, 0, 0, 0, 0, 159, 0, 0, 34, 35, + 0, 162, 163, 37, 39, 170, 0, 171, 173, 0, + 166, 165, 164, 167, 168, 33, 172, 42, 43, 41, + 63, 36, 169, 32, 0, 31, 27, 44, 38, 40, + 0, 0, 0, 28, 0, 0, 29, 30, 45, 46, + 59, 0, 58, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 159, 0, 0, + 34, 35, 0, 162, 163, 37, 39, 170, 0, 171, + 173, 0, 166, 165, 164, 167, 168, 33, 172, 42, + 43, 41, 0, 36, 169, 23, 0, 0, 27, 44, + 38, 40, 0, 0, 0, 28, 0, 0, 29, 30, + 45, 46, 0, 0, 62, 34, 35, 0, 0, 0, + 37, 39, 0, 0, 0, 81, 82, 62, 62, 85, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 62, 27, 44, 38, 40, 60, 57, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 0, + 62, 62, 62, 62, 62, 62, 25, 62, 0, 32, + 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, + 62, 62, 62, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 180, 0, 0, 0, 0, 0, 0, 62, + 63, 62, 0, 32, 0, 31, 0, 62, 0, 62, + 62, 62, 62, 62, 0, 62, 0, 0, 0, 12, + 0, 0, 0, 34, 35, 0, 0, 62, 37, 39, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 42, 43, 41, 62, 36, 62, 0, 0, + 0, 27, 44, 38, 40, 60, 57, 0, 28, 0, + 0, 29, 30, 45, 46, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 62, 62, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 62, 62, 62, 0, 62, + 0, 62, 62, 62, 62, 62, 0, 0, 0, 0, + 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, + 0, 0, 62, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 61, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 62, 62, 62, 83, 84, 0, 0, 0, + 0, 62, 62, 0, 62, 62, 62, 62, 0, 0, + 101, 0, 0, 16, 17, 24, 0, 0, 0, 34, + 35, 0, 0, 0, 37, 39, 0, 0, 118, 119, + 120, 121, 122, 123, 0, 125, 33, 0, 42, 43, + 41, 11, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 61, 26, 29, 30, 45, + 46, 0, 25, 0, 0, 32, 0, 31, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 61, 61, 61, + 61, 288, 0, 34, 35, 0, 0, 0, 37, 39, + 0, 0, 0, 0, 0, 0, 0, 61, 0, 61, + 33, 0, 42, 43, 41, 61, 36, 61, 61, 61, + 61, 61, 25, 61, 0, 32, 0, 31, 28, 0, + 0, 29, 30, 45, 46, 61, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 218, 0, 61, 0, 0, 0, 0, + 0, 0, 0, 0, 63, 263, 0, 32, 264, 31, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 61, 61, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 61, 61, 61, 0, 61, 0, 61, + 61, 61, 61, 61, 0, 0, 63, 261, 0, 32, + 262, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 61, 61, 61, 0, 0, 0, 0, 0, 0, 61, + 61, 0, 61, 61, 61, 61, 63, 259, 0, 32, + 260, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 24, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 257, 0, 32, 258, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 26, 29, 30, 45, 46, 0, 0, 0, + 0, 24, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 251, 0, 32, 250, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 26, 29, 30, 45, 46, 34, 35, 0, + 0, 0, 37, 39, 0, 0, 63, 0, 0, 32, + 0, 31, 0, 0, 33, 0, 42, 43, 41, 0, + 36, 0, 0, 0, 0, 27, 44, 38, 40, 0, + 0, 0, 28, 0, 0, 29, 30, 45, 46, 34, + 35, 0, 0, 0, 37, 39, 0, 0, 0, 0, + 0, 0, 142, 0, 0, 32, 33, 31, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 0, 0, 0, 0, 0, 0, 0, 34, + 35, 0, 0, 0, 37, 39, 63, 297, 0, 32, + 0, 31, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 296, 0, 32, 0, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 295, 0, 32, 0, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 106, 107, 34, + 35, 0, 0, 0, 37, 39, 63, 294, 0, 32, + 0, 31, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 24, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 292, 0, 32, 0, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 26, 29, 30, 45, 46, 0, 0, 34, + 35, 0, 0, 0, 37, 39, 63, 291, 0, 32, + 0, 31, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 0, 0, 0, 34, 35, 0, 0, 63, + 37, 39, 32, 0, 31, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 283, 63, 0, 0, 32, 0, 31, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 34, + 35, 0, 0, 0, 37, 39, 63, 273, 0, 32, + 0, 31, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 0, 0, 0, 34, 35, 0, 0, 0, + 37, 39, 63, 256, 0, 32, 0, 31, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 0, 34, + 35, 0, 0, 0, 37, 39, 63, 254, 0, 32, + 0, 31, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 34, 35, 0, 0, 0, 37, 39, 0, + 0, 0, 63, 0, 0, 32, 0, 31, 0, 33, + 0, 42, 43, 41, 0, 36, 0, 0, 0, 0, + 27, 44, 38, 40, 0, 0, 0, 28, 0, 0, + 29, 30, 45, 46, 0, 0, 0, 0, 0, 0, + 0, 0, 277, 0, 0, 63, 34, 35, 32, 194, + 31, 37, 39, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 33, 0, 42, 43, 41, 0, 36, + 0, 0, 0, 0, 27, 44, 38, 40, 0, 0, + 0, 28, 0, 0, 29, 30, 45, 46, 63, 34, + 35, 32, 192, 31, 37, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 0, 0, 0, 63, 34, 35, 32, 191, 31, + 37, 39, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 0, 63, 34, + 35, 32, 190, 31, 37, 39, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 42, 43, + 41, 0, 36, 0, 0, 0, 0, 27, 44, 38, + 40, 0, 0, 0, 28, 0, 0, 29, 30, 45, + 46, 224, 0, 0, 63, 34, 35, 32, 189, 31, + 37, 39, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 42, 43, 41, 0, 36, 0, + 0, 0, 0, 27, 44, 38, 40, 0, 0, 0, + 28, 0, 0, 29, 30, 45, 46, 63, 34, 35, + 32, 188, 31, 37, 39, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 42, 43, 41, + 0, 36, 0, 0, 0, 0, 27, 44, 38, 40, + 0, 0, 0, 28, 0, 0, 29, 30, 45, 46, + 0, 34, 35, 0, 0, 0, 37, 39, 63, 182, + 0, 32, 0, 31, 0, 0, 0, 0, 33, 0, + 42, 43, 41, 0, 36, 0, 0, 0, 0, 27, + 44, 38, 40, 0, 0, 0, 28, 0, 0, 29, + 30, 45, 46, 0, 0, 0, 0, 34, 35, 0, + 0, 0, 37, 39, 63, 0, 0, 32, 0, 31, + 0, 0, 0, 0, 33, 0, 42, 43, 41, 0, + 36, 0, 0, 0, 0, 27, 44, 38, 40, 0, + 0, 0, 28, 0, 0, 29, 30, 45, 46, 0, + 0, 34, 35, 0, 0, 0, 37, 39, 0, 0, + 63, 0, 0, 32, 0, 31, 0, 0, 33, 0, + 42, 43, 41, 0, 36, 0, 0, 0, 0, 27, + 44, 38, 40, 0, 0, 0, 28, 0, 0, 29, + 30, 45, 46, 0, 0, 0, 0, 34, 35, 0, + 0, 0, 37, 39, 63, 0, 0, 32, 138, 31, + 0, 0, 0, 0, 33, 0, 42, 43, 41, 0, + 36, 0, 0, 0, 0, 27, 44, 38, 40, 0, + 0, 0, 28, 0, 0, 29, 30, 45, 46, 0, + 34, 35, 0, 0, 0, 37, 39, 63, 134, 0, + 32, 0, 31, 0, 0, 0, 0, 33, 0, 42, + 43, 41, 0, 36, 0, 0, 0, 0, 27, 44, + 38, 40, 0, 0, 0, 28, 0, 0, 29, 30, + 45, 46, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 34, 35, 0, 0, 63, 37, 39, 32, 0, + 31, 0, 0, 0, 0, 0, 0, 0, 33, 0, + 42, 43, 41, 0, 36, 0, 0, 0, 0, 27, + 44, 38, 40, 0, 0, 0, 28, 0, 0, 29, + 30, 45, 46, 150, 0, 0, 0, 34, 35, 0, + 0, 63, 37, 39, 32, 0, 31, 0, 0, 0, + 0, 0, 0, 0, 33, 0, 42, 43, 41, 0, + 36, 0, 0, 0, 0, 27, 44, 38, 40, 0, + 0, 0, 28, 0, 0, 29, 30, 45, 46, 148, + 0, 0, 0, 34, 35, 0, 0, 93, 37, 39, + 32, 0, 31, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 42, 43, 41, 0, 36, 0, 0, 0, + 0, 27, 44, 38, 40, 0, 0, 0, 28, 0, + 0, 29, 30, 45, 46, 0, 0, 34, 35, 0, + 0, 0, 37, 39, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 33, 0, 42, 43, 41, 0, + 36, 0, 0, 0, 0, 27, 44, 38, 40, 0, + 0, 0, 28, 0, 0, 29, 30, 45, 46, 0, + 34, 35, 0, 0, 0, 37, 39, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 33, 0, 42, + 43, 41, 0, 36, 0, 0, 0, 0, 27, 44, + 38, 40, 0, 0, 0, 28, 0, 0, 29, 30, + 45, 46, 0, 0, 117, 0, 0, 0, 34, 35, + 0, 0, 0, 37, 39, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 42, 43, 41, + 0, 36, 0, 0, 0, 0, 27, 44, 38, 40, + 0, 0, 0, 28, 0, 0, 29, 30, 45, 46, + 0, 0, 0, 0, 34, 35, 0, 0, 0, 37, + 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 0, 42, 43, 41, 0, 36, 0, 0, + 0, 0, 27, 44, 38, 40, 0, 0, 0, 28, + 0, 0, 29, 30, 45, 46, 0, 0, 0, 0, + 34, 35, 0, 0, 0, 37, 39, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 33, 0, 42, + 43, 41, 0, 36, 0, 0, 0, 0, 27, 44, + 38, 40, 0, 0, 0, 28, 0, 0, 29, 30, + 45, 46 }; +int yypact[]={ + + -1000, -1000, 35, 1016, -1000, -1000, -1000, -1000, -1000, -1000, + -79, -271, -1000, -1000, -227, -22, -81, -85, 880, -1000, + -1000, -1000, 53, -281, -1000, 1332, 1332, -1000, -1000, -291, + -291, 2791, 2791, -44, 82, 80, 79, 2837, 78, 75, + 74, 73, 72, 70, -37, -1000, 2791, 35, -1000, 69, + -231, -1000, 1332, -1000, -1000, -1000, -1000, 2791, 2791, 2791, + 2745, 53, -293, 1332, 2791, 2791, 2791, 2791, 2791, 2791, + -278, 2791, -254, 1332, -1000, -1000, 58, 52, 48, 0, + -1000, -1000, -1000, -46, -46, -11, 2791, 2697, 2837, 2837, + -1000, 2654, 23, 1652, 2791, 2791, 2791, 2791, 2610, 2564, + 2837, -67, -231, 2837, 697, -1000, -1000, -1000, -266, 586, + 586, -231, -231, 1080, 1080, 1080, 1080, -1000, 64, 64, + -46, -46, -46, -46, -1000, 34, -291, -266, -1000, -1000, + -1000, -1000, 2791, 1080, -1000, 2518, 47, 46, -1000, -1000, + 41, 742, 1652, 2467, 2424, 2378, 2334, 2288, 13, 2245, + 12, -42, 635, 45, -1000, -1000, -1000, 68, -1000, -1000, + -1000, 2791, 2837, 2837, -1000, -1000, 2791, -1000, 2791, -282, + 67, 65, -1000, 63, -1000, -1000, -279, 432, 370, 2791, + -1000, 1080, -1000, -1000, -1000, 1606, 1606, -1000, 2791, -286, + 2791, 2202, 2791, 2791, 2791, 2791, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -231, -231, 8, 8, 2791, 2791, + -39, 1332, 1332, -40, 532, -231, -1000, -1000, 53, 2791, + 2791, 1562, 21, 2156, 43, 2112, 1512, 1466, 1416, 1374, + -94, -231, -231, -231, -231, -231, 2791, -1000, -1000, -1000, + 2791, 2791, -5, -9, -245, -4, 2066, -1000, 320, 35, + 2791, -1000, 2023, -1000, -1000, -1000, -1000, -1000, 2791, -1000, + 2791, -1000, 2791, -1000, 2791, -1000, 2791, 2791, 1969, -1000, + -1000, 62, 1282, -1000, -1000, 1926, 1882, 39, 1836, 1792, + 1742, 1696, -231, -1000, -40, -40, 1332, -34, 532, -40, + -231, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 267, -243, + -1000, -24, 532, 37, -1000, -1000, -1000, -1000, 32, -1000, + -40, -1000, -40, -1000, -40, -1000, -1000 }; +int yypgo[]={ + + 0, 139, 40, 135, 134, 4, 18, 129, 126, 125, + 124, 47, 64, 245, 46, 43, 37, 1223, 985, 39, + 123, 108, 104, 2, 35, 75, 33, 74 }; +int yyr1[]={ + + 0, 1, 4, 7, 7, 3, 3, 8, 8, 8, + 8, 8, 8, 10, 9, 9, 12, 12, 12, 12, + 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, + 14, 14, 13, 13, 13, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, + 17, 18, 18, 18, 18, 11, 11, 11, 19, 19, + 19, 2, 2, 20, 20, 20, 20, 5, 5, 21, + 21, 22, 22, 22, 22, 6, 6, 23, 23, 23, + 23, 26, 26, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 27, 27, 27, 25, + 25, 25, 25, 25, 25, 25, 25 }; +int yyr2[]={ + + 0, 5, 13, 11, 5, 7, 1, 3, 11, 21, + 9, 2, 2, 3, 3, 7, 2, 2, 2, 2, + 7, 9, 9, 5, 7, 7, 7, 7, 7, 7, + 3, 7, 3, 5, 7, 3, 3, 3, 7, 7, + 7, 7, 7, 7, 7, 11, 5, 5, 5, 5, + 5, 5, 7, 3, 5, 7, 9, 7, 9, 3, + 7, 9, 9, 9, 5, 17, 13, 17, 17, 13, + 13, 13, 13, 13, 13, 13, 13, 17, 17, 17, + 17, 3, 9, 3, 5, 2, 2, 1, 9, 9, + 7, 5, 1, 3, 3, 3, 3, 5, 1, 3, + 3, 5, 5, 5, 5, 5, 1, 7, 5, 5, + 2, 2, 1, 2, 9, 5, 9, 5, 3, 3, + 3, 5, 3, 3, 5, 11, 3, 3, 3, 13, + 19, 13, 15, 21, 19, 13, 11 }; +int yychk[]={ + + -1000, -1, -2, -3, -20, 59, 260, 261, 262, -8, + -9, 285, 123, -4, -7, -12, 257, 258, -13, -14, + -15, -16, -17, -18, 259, 40, 300, 291, 298, 301, + 302, 45, 43, 280, 263, 264, 286, 268, 293, 269, + 294, 284, 282, 283, 292, 303, 304, -2, 123, 286, + -5, 261, 44, 290, 289, 123, 123, 296, 62, 60, + 295, -17, -18, 40, 43, 45, 42, 47, 37, 94, + 274, 63, 112, 288, 301, 302, -16, -15, -14, -12, + -12, -18, -18, -17, -17, -18, 60, 40, 40, 40, + -11, -13, -19, 40, 40, 40, 40, 40, 40, 40, + 91, -17, -5, 40, -6, -21, 261, 262, -12, -5, + -5, -5, -5, -13, -13, -13, -13, 259, -17, -17, + -17, -17, -17, -17, 292, -17, 280, -12, 41, 41, + 41, 41, 60, -13, 41, -13, -11, -11, 44, 44, + -19, -13, 40, -13, -13, -13, -13, -13, 259, -13, + 259, -11, -6, -10, -11, 125, -23, -24, 59, 260, + -25, -13, 266, 267, 277, 276, 275, 278, 279, 287, + 270, 272, 281, 273, 123, -12, -12, -6, -6, 58, + -18, -13, 41, 41, 41, -5, -5, 41, 44, 44, + 44, 44, 44, 44, 44, 44, 93, 125, 41, -22, + 59, 260, 261, 262, -5, -5, -11, -11, -13, -13, + 292, 40, 40, -5, 40, -5, 125, 125, -17, -13, + -13, -13, 292, -13, 259, -13, -13, -13, -13, -13, + -5, -5, -5, -5, -5, -5, -27, 62, 265, 124, + -27, 91, -12, -12, -23, -26, -13, -24, -6, -2, + 44, 41, 44, 41, 41, 41, 41, 41, 44, 41, + 44, 41, 44, 41, 44, 123, -13, -13, -13, 41, + 41, 272, 59, 41, 125, -13, -13, 259, -13, -13, + -13, -13, -5, 93, -5, -5, 40, -12, 59, -5, + -5, 41, 41, 41, 41, 41, 41, 41, -6, -23, + -23, -12, 59, -26, -23, 125, 271, 41, -26, 41, + -5, 41, -5, -23, -5, -23, -23 }; +int yydef[]={ + + 92, -2, 6, 1, 91, 93, 94, 95, 96, 92, + 7, 0, 98, 11, 12, 14, 0, 0, 16, 17, + 18, 19, 32, 35, 30, 0, 0, 36, 37, 0, + 0, 0, 0, 53, 59, 0, 0, 87, 0, 0, + 0, 0, 0, 0, 81, 83, 0, 5, 98, 0, + 106, 4, 0, 98, 98, 98, 98, 0, 0, 0, + 0, 33, 35, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 46, 47, 19, 18, 17, 0, + 23, 48, 49, 50, 51, 54, 0, 0, 87, 87, + 64, 85, 86, 0, 0, 0, 0, 0, 0, 0, + 87, 84, 106, 87, 0, 97, 99, 100, 15, 0, + 0, 106, 106, 24, 25, 26, 28, 29, 38, 39, + 40, 41, 42, 43, 44, 0, 57, 34, 20, 27, + 31, 52, 0, 55, 60, 0, 0, 0, 98, 98, + 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 13, 10, 105, 0, 98, 98, + 110, 113, 87, 87, 118, 119, 120, 122, 123, 0, + 0, 0, 98, 0, 98, 21, 22, 0, 0, 0, + 58, 56, 61, 62, 63, 0, 0, 90, 0, 0, + 0, 0, 0, 0, 0, 0, 82, 8, 98, 98, + 98, 98, 98, 98, 108, 109, 115, 117, 121, 124, + 0, 0, 0, 0, 112, 106, 92, 3, 45, 88, + 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 107, 101, 102, 103, 104, 0, 126, 127, 128, + 0, 0, 0, 0, 0, 0, 113, 111, 0, 2, + 0, 66, 0, 69, 70, 71, 72, 73, 0, 74, + 0, 75, 0, 76, 0, 98, 114, 116, 0, 98, + 98, 0, 0, 98, 98, 0, 0, 0, 0, 0, + 0, 0, 106, 125, 0, 0, 0, 0, 112, 0, + 136, 65, 67, 68, 77, 78, 79, 80, 0, 129, + 131, 0, 112, 0, 135, 9, 98, 132, 0, 98, + 0, 98, 0, 130, 0, 134, 133 }; +typedef struct { char *t_name; int t_val; } yytoktype; +#ifndef YYDEBUG +# define YYDEBUG 0 /* don't allow debugging */ +#endif + +#if YYDEBUG + +yytoktype yytoks[] = +{ + "BEGIN", 257, + "END", 258, + "REGEX", 259, + "SEMINEW", 260, + "NEWLINE", 261, + "COMMENT", 262, + "FUN1", 263, + "FUNN", 264, + "GRGR", 265, + "PRINT", 266, + "PRINTF", 267, + "SPRINTF", 268, + "SPLIT", 269, + "IF", 270, + "ELSE", 271, + "WHILE", 272, + "FOR", 273, + "IN", 274, + "EXIT", 275, + "NEXT", 276, + "BREAK", 277, + "CONTINUE", 278, + "RET", 279, + "GETLINE", 280, + "DO", 281, + "SUB", 282, + "GSUB", 283, + "MATCH", 284, + "FUNCTION", 285, + "USERFUN", 286, + "DELETE", 287, + "ASGNOP", 288, + "?", 63, + ":", 58, + "OROR", 289, + "ANDAND", 290, + "NUMBER", 291, + "VAR", 292, + "SUBSTR", 293, + "INDEX", 294, + "MATCHOP", 295, + "RELOP", 296, + "<", 60, + ">", 62, + "OR", 297, + "STRING", 298, + "+", 43, + "-", 45, + "*", 42, + "/", 47, + "%", 37, + "UMINUS", 299, + "NOT", 300, + "^", 94, + "INCR", 301, + "DECR", 302, + "FIELD", 303, + "VFIELD", 304, + "-unknown-", -1 /* ends search */ +}; + +char * yyreds[] = +{ + "-no such reduction-", + "program : junk hunks", + "begin : BEGIN '{' maybe states '}' junk", + "end : END '{' maybe states '}'", + "end : end NEWLINE", + "hunks : hunks hunk junk", + "hunks : /* empty */", + "hunk : patpat", + "hunk : patpat '{' maybe states '}'", + "hunk : FUNCTION USERFUN '(' arg_list ')' maybe '{' maybe states '}'", + "hunk : '{' maybe states '}'", + "hunk : begin", + "hunk : end", + "arg_list : expr_list", + "patpat : cond", + "patpat : cond ',' cond", + "cond : expr", + "cond : match", + "cond : rel", + "cond : compound_cond", + "compound_cond : '(' compound_cond ')'", + "compound_cond : cond ANDAND maybe cond", + "compound_cond : cond OROR maybe cond", + "compound_cond : NOT cond", + "rel : expr RELOP expr", + "rel : expr '>' expr", + "rel : expr '<' expr", + "rel : '(' rel ')'", + "match : expr MATCHOP expr", + "match : expr MATCHOP REGEX", + "match : REGEX", + "match : '(' match ')'", + "expr : term", + "expr : expr term", + "expr : variable ASGNOP cond", + "term : variable", + "term : NUMBER", + "term : STRING", + "term : term '+' term", + "term : term '-' term", + "term : term '*' term", + "term : term '/' term", + "term : term '%' term", + "term : term '^' term", + "term : term IN VAR", + "term : term '?' term ':' term", + "term : variable INCR", + "term : variable DECR", + "term : INCR variable", + "term : DECR variable", + "term : '-' term", + "term : '+' term", + "term : '(' cond ')'", + "term : GETLINE", + "term : GETLINE variable", + "term : GETLINE '<' expr", + "term : GETLINE variable '<' expr", + "term : term 'p' GETLINE", + "term : term 'p' GETLINE variable", + "term : FUN1", + "term : FUN1 '(' ')'", + "term : FUN1 '(' expr ')'", + "term : FUNN '(' expr_list ')'", + "term : USERFUN '(' expr_list ')'", + "term : SPRINTF expr_list", + "term : SUBSTR '(' expr ',' expr ',' expr ')'", + "term : SUBSTR '(' expr ',' expr ')'", + "term : SPLIT '(' expr ',' VAR ',' expr ')'", + "term : SPLIT '(' expr ',' VAR ',' REGEX ')'", + "term : SPLIT '(' expr ',' VAR ')'", + "term : INDEX '(' expr ',' expr ')'", + "term : MATCH '(' expr ',' REGEX ')'", + "term : MATCH '(' expr ',' expr ')'", + "term : SUB '(' expr ',' expr ')'", + "term : SUB '(' REGEX ',' expr ')'", + "term : GSUB '(' expr ',' expr ')'", + "term : GSUB '(' REGEX ',' expr ')'", + "term : SUB '(' expr ',' expr ',' expr ')'", + "term : SUB '(' REGEX ',' expr ',' expr ')'", + "term : GSUB '(' expr ',' expr ',' expr ')'", + "term : GSUB '(' REGEX ',' expr ',' expr ')'", + "variable : VAR", + "variable : VAR '[' expr_list ']'", + "variable : FIELD", + "variable : VFIELD term", + "expr_list : expr", + "expr_list : clist", + "expr_list : /* empty */", + "clist : expr ',' maybe expr", + "clist : clist ',' maybe expr", + "clist : '(' clist ')'", + "junk : junk hunksep", + "junk : /* empty */", + "hunksep : ';'", + "hunksep : SEMINEW", + "hunksep : NEWLINE", + "hunksep : COMMENT", + "maybe : maybe nlstuff", + "maybe : /* empty */", + "nlstuff : NEWLINE", + "nlstuff : COMMENT", + "separator : ';' maybe", + "separator : SEMINEW maybe", + "separator : NEWLINE maybe", + "separator : COMMENT maybe", + "states : states statement", + "states : /* empty */", + "statement : simple separator maybe", + "statement : ';' maybe", + "statement : SEMINEW maybe", + "statement : compound", + "simpnull : simple", + "simpnull : /* empty */", + "simple : expr", + "simple : PRINT expr_list redir expr", + "simple : PRINT expr_list", + "simple : PRINTF expr_list redir expr", + "simple : PRINTF expr_list", + "simple : BREAK", + "simple : NEXT", + "simple : EXIT", + "simple : EXIT expr", + "simple : CONTINUE", + "simple : RET", + "simple : RET expr", + "simple : DELETE VAR '[' expr ']'", + "redir : '>'", + "redir : GRGR", + "redir : '|'", + "compound : IF '(' cond ')' maybe statement", + "compound : IF '(' cond ')' maybe statement ELSE maybe statement", + "compound : WHILE '(' cond ')' maybe statement", + "compound : DO maybe statement WHILE '(' cond ')'", + "compound : FOR '(' simpnull ';' cond ';' simpnull ')' maybe statement", + "compound : FOR '(' simpnull ';' ';' simpnull ')' maybe statement", + "compound : FOR '(' expr ')' maybe statement", + "compound : '{' maybe states '}' maybe", +}; +#endif /* YYDEBUG */ +#line 1 "/usr/lib/yaccpar" +/* @(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10 */ + +/* +** Skeleton parser driver for yacc output +*/ + +/* +** yacc user known macros and defines +*/ +#define YYERROR goto yyerrlab +#define YYACCEPT { free(yys); free(yyv); return(0); } +#define YYABORT { free(yys); free(yyv); return(1); } +#define YYBACKUP( newtoken, newvalue )\ +{\ + if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ + {\ + yyerror( "syntax error - cannot backup" );\ + goto yyerrlab;\ + }\ + yychar = newtoken;\ + yystate = *yyps;\ + yylval = newvalue;\ + goto yynewstate;\ +} +#define YYRECOVERING() (!!yyerrflag) +#ifndef YYDEBUG +# define YYDEBUG 1 /* make debugging available */ +#endif + +/* +** user known globals +*/ +int yydebug; /* set to 1 to get debugging */ + +/* +** driver internal defines +*/ +#define YYFLAG (-1000) + +/* +** static variables used by the parser +*/ +static YYSTYPE *yyv; /* value stack */ +static int *yys; /* state stack */ + +static YYSTYPE *yypv; /* top of value stack */ +static int *yyps; /* top of state stack */ + +static int yystate; /* current state */ +static int yytmp; /* extra var (lasts between blocks) */ + +int yynerrs; /* number of errors */ + +int yyerrflag; /* error recovery flag */ +int yychar; /* current input token number */ + + +/* +** yyparse - return 0 if worked, 1 if syntax error not recovered from +*/ +int +yyparse() +{ + register YYSTYPE *yypvt; /* top of value stack for $vars */ + unsigned yymaxdepth = YYMAXDEPTH; + + /* + ** Initialize externals - yyparse may be called more than once + */ + yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE)); + yys = (int*)malloc(yymaxdepth*sizeof(int)); + if (!yyv || !yys) + { + yyerror( "out of memory" ); + return(1); + } + yypv = &yyv[-1]; + yyps = &yys[-1]; + yystate = 0; + yytmp = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = -1; + + goto yystack; + { + register YYSTYPE *yy_pv; /* top of value stack */ + register int *yy_ps; /* top of state stack */ + register int yy_state; /* current state */ + register int yy_n; /* internal state number info */ + + /* + ** get globals into registers. + ** branch to here only if YYBACKUP was called. + */ + yynewstate: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + goto yy_newstate; + + /* + ** get globals into registers. + ** either we just started, or we just finished a reduction + */ + yystack: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + + /* + ** top of for (;;) loop while no reductions done + */ + yy_stack: + /* + ** put a state and value onto the stacks + */ +#if YYDEBUG + /* + ** if debugging, look up token value in list of value vs. + ** name pairs. 0 and negative (-1) are special values. + ** Note: linear search is used since time is not a real + ** consideration while debugging. + */ + if ( yydebug ) + { + register int yy_i; + + (void)printf( "State %d, token ", yy_state ); + if ( yychar == 0 ) + (void)printf( "end-of-file\n" ); + else if ( yychar < 0 ) + (void)printf( "-none-\n" ); + else + { + for ( yy_i = 0; yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val == yychar ) + break; + } + (void)printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ + { + /* + ** reallocate and recover. Note that pointers + ** have to be reset, or bad things will happen + */ + int yyps_index = (yy_ps - yys); + int yypv_index = (yy_pv - yyv); + int yypvt_index = (yypvt - yyv); + yymaxdepth += YYMAXDEPTH; + yyv = (YYSTYPE*)realloc((char*)yyv, + yymaxdepth * sizeof(YYSTYPE)); + yys = (int*)realloc((char*)yys, + yymaxdepth * sizeof(int)); + if (!yyv || !yys) + { + yyerror( "yacc stack overflow" ); + return(1); + } + yy_ps = yys + yyps_index; + yy_pv = yyv + yypv_index; + yypvt = yyv + yypvt_index; + } + *yy_ps = yy_state; + *++yy_pv = yyval; + + /* + ** we have a new state - find out what to do + */ + yy_newstate: + if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) + goto yydefault; /* simple state */ +#if YYDEBUG + /* + ** if debugging, need to mark whether new token grabbed + */ + yytmp = yychar < 0; +#endif + if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) + yychar = 0; /* reached EOF */ +#if YYDEBUG + if ( yydebug && yytmp ) + { + register int yy_i; + + (void)printf( "Received token " ); + if ( yychar == 0 ) + (void)printf( "end-of-file\n" ); + else if ( yychar < 0 ) + (void)printf( "-none-\n" ); + else + { + for ( yy_i = 0; yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val == yychar ) + break; + } + (void)printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) + goto yydefault; + if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ + { + yychar = -1; + yyval = yylval; + yy_state = yy_n; + if ( yyerrflag > 0 ) + yyerrflag--; + goto yy_stack; + } + + yydefault: + if ( ( yy_n = yydef[ yy_state ] ) == -2 ) + { +#if YYDEBUG + yytmp = yychar < 0; +#endif + if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) + yychar = 0; /* reached EOF */ +#if YYDEBUG + if ( yydebug && yytmp ) + { + register int yy_i; + + (void)printf( "Received token " ); + if ( yychar == 0 ) + (void)printf( "end-of-file\n" ); + else if ( yychar < 0 ) + (void)printf( "-none-\n" ); + else + { + for ( yy_i = 0; + yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val + == yychar ) + { + break; + } + } + (void)printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + /* + ** look through exception table + */ + { + register int *yyxi = yyexca; + + while ( ( *yyxi != -1 ) || + ( yyxi[1] != yy_state ) ) + { + yyxi += 2; + } + while ( ( *(yyxi += 2) >= 0 ) && + ( *yyxi != yychar ) ) + ; + if ( ( yy_n = yyxi[1] ) < 0 ) + YYACCEPT; + } + } + + /* + ** check for syntax error + */ + if ( yy_n == 0 ) /* have an error */ + { + /* no worry about speed here! */ + switch ( yyerrflag ) + { + case 0: /* new error */ + yyerror( "syntax error" ); + goto skip_init; + yyerrlab: + /* + ** get globals into registers. + ** we have a user generated syntax type error + */ + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + yynerrs++; + skip_init: + case 1: + case 2: /* incompletely recovered error */ + /* try again... */ + yyerrflag = 3; + /* + ** find state where "error" is a legal + ** shift action + */ + while ( yy_ps >= yys ) + { + yy_n = yypact[ *yy_ps ] + YYERRCODE; + if ( yy_n >= 0 && yy_n < YYLAST && + yychk[yyact[yy_n]] == YYERRCODE) { + /* + ** simulate shift of "error" + */ + yy_state = yyact[ yy_n ]; + goto yy_stack; + } + /* + ** current state has no shift on + ** "error", pop stack + */ +#if YYDEBUG +# define _POP_ "Error recovery pops state %d, uncovers state %d\n" + if ( yydebug ) + (void)printf( _POP_, *yy_ps, + yy_ps[-1] ); +# undef _POP_ +#endif + yy_ps--; + yy_pv--; + } + /* + ** there is no state on stack with "error" as + ** a valid shift. give up. + */ + YYABORT; + case 3: /* no shift yet; eat a token */ +#if YYDEBUG + /* + ** if debugging, look up token in list of + ** pairs. 0 and negative shouldn't occur, + ** but since timing doesn't matter when + ** debugging, it doesn't hurt to leave the + ** tests here. + */ + if ( yydebug ) + { + register int yy_i; + + (void)printf( "Error recovery discards " ); + if ( yychar == 0 ) + (void)printf( "token end-of-file\n" ); + else if ( yychar < 0 ) + (void)printf( "token -none-\n" ); + else + { + for ( yy_i = 0; + yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val + == yychar ) + { + break; + } + } + (void)printf( "token %s\n", + yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( yychar == 0 ) /* reached EOF. quit */ + YYABORT; + yychar = -1; + goto yy_newstate; + } + }/* end if ( yy_n == 0 ) */ + /* + ** reduction by production yy_n + ** put stack tops, etc. so things right after switch + */ +#if YYDEBUG + /* + ** if debugging, print the string that is the user's + ** specification of the reduction which is just about + ** to be done. + */ + if ( yydebug ) + (void)printf( "Reduce by (%d) \"%s\"\n", + yy_n, yyreds[ yy_n ] ); +#endif + yytmp = yy_n; /* value to switch over */ + yypvt = yy_pv; /* $vars top of value stack */ + /* + ** Look in goto table for next state + ** Sorry about using yy_state here as temporary + ** register variable, but why not, if it works... + ** If yyr2[ yy_n ] doesn't have the low order bit + ** set, then there is no action to be done for + ** this reduction. So, no saving & unsaving of + ** registers done. The only difference between the + ** code just after the if and the body of the if is + ** the goto yy_stack in the body. This way the test + ** can be made before the choice of what to do is needed. + */ + { + /* length of production doubled with extra bit */ + register int yy_len = yyr2[ yy_n ]; + + if ( !( yy_len & 01 ) ) + { + yy_len >>= 1; + yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ + yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + + *( yy_ps -= yy_len ) + 1; + if ( yy_state >= YYLAST || + yychk[ yy_state = + yyact[ yy_state ] ] != -yy_n ) + { + yy_state = yyact[ yypgo[ yy_n ] ]; + } + goto yy_stack; + } + yy_len >>= 1; + yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ + yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + + *( yy_ps -= yy_len ) + 1; + if ( yy_state >= YYLAST || + yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) + { + yy_state = yyact[ yypgo[ yy_n ] ]; + } + } + /* save until reenter driver code */ + yystate = yy_state; + yyps = yy_ps; + yypv = yy_pv; + } + /* + ** code supplied by user is placed in this switch + */ + switch( yytmp ) + { + +case 1: +# line 60 "a2p.y" +{ root = oper4(OPROG,yypvt[-1],begins,yypvt[-0],ends); } break; +case 2: +# line 64 "a2p.y" +{ begins = oper4(OJUNK,begins,yypvt[-3],yypvt[-2],yypvt[-0]); in_begin = FALSE; + yyval = Nullop; } break; +case 3: +# line 69 "a2p.y" +{ ends = oper3(OJUNK,ends,yypvt[-2],yypvt[-1]); yyval = Nullop; } break; +case 4: +# line 71 "a2p.y" +{ yyval = yypvt[-1]; } break; +case 5: +# line 75 "a2p.y" +{ yyval = oper3(OHUNKS,yypvt[-2],yypvt[-1],yypvt[-0]); } break; +case 6: +# line 77 "a2p.y" +{ yyval = Nullop; } break; +case 7: +# line 81 "a2p.y" +{ yyval = oper1(OHUNK,yypvt[-0]); need_entire = TRUE; } break; +case 8: +# line 83 "a2p.y" +{ yyval = oper2(OHUNK,yypvt[-4],oper2(OJUNK,yypvt[-2],yypvt[-1])); } break; +case 9: +# line 85 "a2p.y" +{ fixfargs(yypvt[-8],yypvt[-6],0); yyval = oper5(OUSERDEF,yypvt[-8],yypvt[-6],yypvt[-4],yypvt[-2],yypvt[-1]); } break; +case 10: +# line 87 "a2p.y" +{ yyval = oper2(OHUNK,Nullop,oper2(OJUNK,yypvt[-2],yypvt[-1])); } break; +case 13: +# line 93 "a2p.y" +{ yyval = rememberargs(yyval); } break; +case 14: +# line 97 "a2p.y" +{ yyval = oper1(OPAT,yypvt[-0]); } break; +case 15: +# line 99 "a2p.y" +{ yyval = oper2(ORANGE,yypvt[-2],yypvt[-0]); } break; +case 20: +# line 110 "a2p.y" +{ yyval = oper1(OCPAREN,yypvt[-1]); } break; +case 21: +# line 112 "a2p.y" +{ yyval = oper3(OCANDAND,yypvt[-3],yypvt[-1],yypvt[-0]); } break; +case 22: +# line 114 "a2p.y" +{ yyval = oper3(OCOROR,yypvt[-3],yypvt[-1],yypvt[-0]); } break; +case 23: +# line 116 "a2p.y" +{ yyval = oper1(OCNOT,yypvt[-0]); } break; +case 24: +# line 120 "a2p.y" +{ yyval = oper3(ORELOP,yypvt[-1],yypvt[-2],yypvt[-0]); } break; +case 25: +# line 122 "a2p.y" +{ yyval = oper3(ORELOP,string(">",1),yypvt[-2],yypvt[-0]); } break; +case 26: +# line 124 "a2p.y" +{ yyval = oper3(ORELOP,string("<",1),yypvt[-2],yypvt[-0]); } break; +case 27: +# line 126 "a2p.y" +{ yyval = oper1(ORPAREN,yypvt[-1]); } break; +case 28: +# line 130 "a2p.y" +{ yyval = oper3(OMATCHOP,yypvt[-1],yypvt[-2],yypvt[-0]); } break; +case 29: +# line 132 "a2p.y" +{ yyval = oper3(OMATCHOP,yypvt[-1],yypvt[-2],oper1(OREGEX,yypvt[-0])); } break; +case 30: +# line 134 "a2p.y" +{ yyval = oper1(OREGEX,yypvt[-0]); } break; +case 31: +# line 136 "a2p.y" +{ yyval = oper1(OMPAREN,yypvt[-1]); } break; +case 32: +# line 140 "a2p.y" +{ yyval = yypvt[-0]; } break; +case 33: +# line 142 "a2p.y" +{ yyval = oper2(OCONCAT,yypvt[-1],yypvt[-0]); } break; +case 34: +# line 144 "a2p.y" +{ yyval = oper3(OASSIGN,yypvt[-1],yypvt[-2],yypvt[-0]); + if ((ops[yypvt[-2]].ival & 255) == OFLD) + lval_field = TRUE; + if ((ops[yypvt[-2]].ival & 255) == OVFLD) + lval_field = TRUE; + } break; +case 35: +# line 153 "a2p.y" +{ yyval = yypvt[-0]; } break; +case 36: +# line 155 "a2p.y" +{ yyval = oper1(ONUM,yypvt[-0]); } break; +case 37: +# line 157 "a2p.y" +{ yyval = oper1(OSTR,yypvt[-0]); } break; +case 38: +# line 159 "a2p.y" +{ yyval = oper2(OADD,yypvt[-2],yypvt[-0]); } break; +case 39: +# line 161 "a2p.y" +{ yyval = oper2(OSUBTRACT,yypvt[-2],yypvt[-0]); } break; +case 40: +# line 163 "a2p.y" +{ yyval = oper2(OMULT,yypvt[-2],yypvt[-0]); } break; +case 41: +# line 165 "a2p.y" +{ yyval = oper2(ODIV,yypvt[-2],yypvt[-0]); } break; +case 42: +# line 167 "a2p.y" +{ yyval = oper2(OMOD,yypvt[-2],yypvt[-0]); } break; +case 43: +# line 169 "a2p.y" +{ yyval = oper2(OPOW,yypvt[-2],yypvt[-0]); } break; +case 44: +# line 171 "a2p.y" +{ yyval = oper2(ODEFINED,aryrefarg(yypvt[-0]),yypvt[-2]); } break; +case 45: +# line 173 "a2p.y" +{ yyval = oper3(OCOND,yypvt[-4],yypvt[-2],yypvt[-0]); } break; +case 46: +# line 175 "a2p.y" +{ yyval = oper1(OPOSTINCR,yypvt[-1]); } break; +case 47: +# line 177 "a2p.y" +{ yyval = oper1(OPOSTDECR,yypvt[-1]); } break; +case 48: +# line 179 "a2p.y" +{ yyval = oper1(OPREINCR,yypvt[-0]); } break; +case 49: +# line 181 "a2p.y" +{ yyval = oper1(OPREDECR,yypvt[-0]); } break; +case 50: +# line 183 "a2p.y" +{ yyval = oper1(OUMINUS,yypvt[-0]); } break; +case 51: +# line 185 "a2p.y" +{ yyval = oper1(OUPLUS,yypvt[-0]); } break; +case 52: +# line 187 "a2p.y" +{ yyval = oper1(OPAREN,yypvt[-1]); } break; +case 53: +# line 189 "a2p.y" +{ yyval = oper0(OGETLINE); } break; +case 54: +# line 191 "a2p.y" +{ yyval = oper1(OGETLINE,yypvt[-0]); } break; +case 55: +# line 193 "a2p.y" +{ yyval = oper3(OGETLINE,Nullop,string("<",1),yypvt[-0]); + if (ops[yypvt[-0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 56: +# line 196 "a2p.y" +{ yyval = oper3(OGETLINE,yypvt[-2],string("<",1),yypvt[-0]); + if (ops[yypvt[-0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 57: +# line 199 "a2p.y" +{ yyval = oper3(OGETLINE,Nullop,string("|",1),yypvt[-2]); + if (ops[yypvt[-2]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 58: +# line 202 "a2p.y" +{ yyval = oper3(OGETLINE,yypvt[-0],string("|",1),yypvt[-3]); + if (ops[yypvt[-3]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 59: +# line 205 "a2p.y" +{ yyval = oper0(yypvt[-0]); need_entire = do_chop = TRUE; } break; +case 60: +# line 207 "a2p.y" +{ yyval = oper1(yypvt[-2],Nullop); need_entire = do_chop = TRUE; } break; +case 61: +# line 209 "a2p.y" +{ yyval = oper1(yypvt[-3],yypvt[-1]); } break; +case 62: +# line 211 "a2p.y" +{ yyval = oper1(yypvt[-3],yypvt[-1]); } break; +case 63: +# line 213 "a2p.y" +{ yyval = oper2(OUSERFUN,yypvt[-3],yypvt[-1]); } break; +case 64: +# line 215 "a2p.y" +{ yyval = oper1(OSPRINTF,yypvt[-0]); } break; +case 65: +# line 217 "a2p.y" +{ yyval = oper3(OSUBSTR,yypvt[-5],yypvt[-3],yypvt[-1]); } break; +case 66: +# line 219 "a2p.y" +{ yyval = oper2(OSUBSTR,yypvt[-3],yypvt[-1]); } break; +case 67: +# line 221 "a2p.y" +{ yyval = oper3(OSPLIT,yypvt[-5],aryrefarg(numary(yypvt[-3])),yypvt[-1]); } break; +case 68: +# line 223 "a2p.y" +{ yyval = oper3(OSPLIT,yypvt[-5],aryrefarg(numary(yypvt[-3])),oper1(OREGEX,yypvt[-1]));} break; +case 69: +# line 225 "a2p.y" +{ yyval = oper2(OSPLIT,yypvt[-3],aryrefarg(numary(yypvt[-1]))); } break; +case 70: +# line 227 "a2p.y" +{ yyval = oper2(OINDEX,yypvt[-3],yypvt[-1]); } break; +case 71: +# line 229 "a2p.y" +{ yyval = oper2(OMATCH,yypvt[-3],oper1(OREGEX,yypvt[-1])); } break; +case 72: +# line 231 "a2p.y" +{ yyval = oper2(OMATCH,yypvt[-3],yypvt[-1]); } break; +case 73: +# line 233 "a2p.y" +{ yyval = oper2(OSUB,yypvt[-3],yypvt[-1]); } break; +case 74: +# line 235 "a2p.y" +{ yyval = oper2(OSUB,oper1(OREGEX,yypvt[-3]),yypvt[-1]); } break; +case 75: +# line 237 "a2p.y" +{ yyval = oper2(OGSUB,yypvt[-3],yypvt[-1]); } break; +case 76: +# line 239 "a2p.y" +{ yyval = oper2(OGSUB,oper1(OREGEX,yypvt[-3]),yypvt[-1]); } break; +case 77: +# line 241 "a2p.y" +{ yyval = oper3(OSUB,yypvt[-5],yypvt[-3],yypvt[-1]); } break; +case 78: +# line 243 "a2p.y" +{ yyval = oper3(OSUB,oper1(OREGEX,yypvt[-5]),yypvt[-3],yypvt[-1]); } break; +case 79: +# line 245 "a2p.y" +{ yyval = oper3(OGSUB,yypvt[-5],yypvt[-3],yypvt[-1]); } break; +case 80: +# line 247 "a2p.y" +{ yyval = oper3(OGSUB,oper1(OREGEX,yypvt[-5]),yypvt[-3],yypvt[-1]); } break; +case 81: +# line 251 "a2p.y" +{ yyval = oper1(OVAR,yypvt[-0]); } break; +case 82: +# line 253 "a2p.y" +{ yyval = oper2(OVAR,aryrefarg(yypvt[-3]),yypvt[-1]); } break; +case 83: +# line 255 "a2p.y" +{ yyval = oper1(OFLD,yypvt[-0]); } break; +case 84: +# line 257 "a2p.y" +{ yyval = oper1(OVFLD,yypvt[-0]); } break; +case 87: +# line 264 "a2p.y" +{ yyval = Nullop; } break; +case 88: +# line 268 "a2p.y" +{ yyval = oper3(OCOMMA,yypvt[-3],yypvt[-1],yypvt[-0]); } break; +case 89: +# line 270 "a2p.y" +{ yyval = oper3(OCOMMA,yypvt[-3],yypvt[-1],yypvt[-0]); } break; +case 90: +# line 272 "a2p.y" +{ yyval = yypvt[-1]; } break; +case 91: +# line 276 "a2p.y" +{ yyval = oper2(OJUNK,yypvt[-1],yypvt[-0]); } break; +case 92: +# line 278 "a2p.y" +{ yyval = Nullop; } break; +case 93: +# line 282 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } break; +case 94: +# line 284 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } break; +case 95: +# line 286 "a2p.y" +{ yyval = oper0(ONEWLINE); } break; +case 96: +# line 288 "a2p.y" +{ yyval = oper1(OCOMMENT,yypvt[-0]); } break; +case 97: +# line 292 "a2p.y" +{ yyval = oper2(OJUNK,yypvt[-1],yypvt[-0]); } break; +case 98: +# line 294 "a2p.y" +{ yyval = Nullop; } break; +case 99: +# line 298 "a2p.y" +{ yyval = oper0(ONEWLINE); } break; +case 100: +# line 300 "a2p.y" +{ yyval = oper1(OCOMMENT,yypvt[-0]); } break; +case 101: +# line 305 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),yypvt[-0]); } break; +case 102: +# line 307 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSNEWLINE),yypvt[-0]); } break; +case 103: +# line 309 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSNEWLINE),yypvt[-0]); } break; +case 104: +# line 311 "a2p.y" +{ yyval = oper2(OJUNK,oper1(OSCOMMENT,yypvt[-1]),yypvt[-0]); } break; +case 105: +# line 315 "a2p.y" +{ yyval = oper2(OSTATES,yypvt[-1],yypvt[-0]); } break; +case 106: +# line 317 "a2p.y" +{ yyval = Nullop; } break; +case 107: +# line 322 "a2p.y" +{ yyval = oper2(OJUNK,oper2(OSTATE,yypvt[-2],yypvt[-1]),yypvt[-0]); } break; +case 108: +# line 324 "a2p.y" +{ yyval = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSEMICOLON),yypvt[-0])); } break; +case 109: +# line 326 "a2p.y" +{ yyval = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSNEWLINE),yypvt[-0])); } break; +case 112: +# line 332 "a2p.y" +{ yyval = Nullop; } break; +case 114: +# line 338 "a2p.y" +{ yyval = oper3(OPRINT,yypvt[-2],yypvt[-1],yypvt[-0]); + do_opens = TRUE; + saw_ORS = saw_OFS = TRUE; + if (!yypvt[-2]) need_entire = TRUE; + if (ops[yypvt[-0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 115: +# line 344 "a2p.y" +{ yyval = oper1(OPRINT,yypvt[-0]); + if (!yypvt[-0]) need_entire = TRUE; + saw_ORS = saw_OFS = TRUE; + } break; +case 116: +# line 349 "a2p.y" +{ yyval = oper3(OPRINTF,yypvt[-2],yypvt[-1],yypvt[-0]); + do_opens = TRUE; + if (!yypvt[-2]) need_entire = TRUE; + if (ops[yypvt[-0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } break; +case 117: +# line 354 "a2p.y" +{ yyval = oper1(OPRINTF,yypvt[-0]); + if (!yypvt[-0]) need_entire = TRUE; + } break; +case 118: +# line 358 "a2p.y" +{ yyval = oper0(OBREAK); } break; +case 119: +# line 360 "a2p.y" +{ yyval = oper0(ONEXT); } break; +case 120: +# line 362 "a2p.y" +{ yyval = oper0(OEXIT); } break; +case 121: +# line 364 "a2p.y" +{ yyval = oper1(OEXIT,yypvt[-0]); } break; +case 122: +# line 366 "a2p.y" +{ yyval = oper0(OCONTINUE); } break; +case 123: +# line 368 "a2p.y" +{ yyval = oper0(ORETURN); } break; +case 124: +# line 370 "a2p.y" +{ yyval = oper1(ORETURN,yypvt[-0]); } break; +case 125: +# line 372 "a2p.y" +{ yyval = oper2(ODELETE,aryrefarg(yypvt[-3]),yypvt[-1]); } break; +case 126: +# line 376 "a2p.y" +{ yyval = oper1(OREDIR,string(">",1)); } break; +case 127: +# line 378 "a2p.y" +{ yyval = oper1(OREDIR,string(">>",2)); } break; +case 128: +# line 380 "a2p.y" +{ yyval = oper1(OREDIR,string("|",1)); } break; +case 129: +# line 385 "a2p.y" +{ yyval = oper2(OIF,yypvt[-3],bl(yypvt[-0],yypvt[-1])); } break; +case 130: +# line 387 "a2p.y" +{ yyval = oper3(OIF,yypvt[-6],bl(yypvt[-3],yypvt[-4]),bl(yypvt[-0],yypvt[-1])); } break; +case 131: +# line 389 "a2p.y" +{ yyval = oper2(OWHILE,yypvt[-3],bl(yypvt[-0],yypvt[-1])); } break; +case 132: +# line 391 "a2p.y" +{ yyval = oper2(ODO,bl(yypvt[-4],yypvt[-5]),yypvt[-1]); } break; +case 133: +# line 393 "a2p.y" +{ yyval = oper4(OFOR,yypvt[-7],yypvt[-5],yypvt[-3],bl(yypvt[-0],yypvt[-1])); } break; +case 134: +# line 395 "a2p.y" +{ yyval = oper4(OFOR,yypvt[-6],string("",0),yypvt[-3],bl(yypvt[-0],yypvt[-1])); } break; +case 135: +# line 397 "a2p.y" +{ yyval = oper2(OFORIN,yypvt[-3],bl(yypvt[-0],yypvt[-1])); } break; +case 136: +# line 399 "a2p.y" +{ yyval = oper3(OBLOCK,oper2(OJUNK,yypvt[-3],yypvt[-2]),Nullop,yypvt[-0]); } break; + } + goto yystack; /* reset registers in driver code */ +} @@ -1,4 +1,4 @@ -/* $RCSfile: a2p.h,v $$Revision: 4.0.1.2 $$Date: 92/06/08 16:12:23 $ +/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: a2p.h,v $ + * Revision 4.1 92/08/07 18:29:09 lwall + * * Revision 4.0.1.2 92/06/08 16:12:23 lwall * patch20: hash tables now split only if the memory is available to do so * @@ -336,3 +338,5 @@ EXT HASH *curarghash; #define P_POW 95 #define P_AUTO 100 #define P_MAX 999 + +EXT int an; diff --git a/x2p/a2p.man b/x2p/a2p.man index 47515261d5..4f4168b269 100644 --- a/x2p/a2p.man +++ b/x2p/a2p.man @@ -1,7 +1,9 @@ .rn '' }` -''' $Header: a2p.man,v 4.0 91/03/20 01:57:11 lwall Locked $ +''' $RCSfile: a2p.man,v $$Revision: 4.1 $$Date: 92/08/07 18:29:10 $ ''' ''' $Log: a2p.man,v $ +''' Revision 4.1 92/08/07 18:29:10 lwall +''' ''' Revision 4.0 91/03/20 01:57:11 lwall ''' 4.0 baseline. ''' @@ -1,5 +1,5 @@ %{ -/* $RCSfile: a2p.y,v $$Revision: 4.0.1.2 $$Date: 92/06/08 16:13:03 $ +/* $RCSfile: a2p.y,v $$Revision: 4.1 $$Date: 92/08/07 18:29:12 $ * * Copyright (c) 1991, Larry Wall * @@ -7,6 +7,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: a2p.y,v $ + * Revision 4.1 92/08/07 18:29:12 lwall + * * Revision 4.0.1.2 92/06/08 16:13:03 lwall * patch20: in a2p, getline should allow variable to be array element * diff --git a/x2p/a2py.c b/x2p/a2py.c index c785828712..a092c8ab63 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -1,4 +1,4 @@ -/* $RCSfile: a2py.c,v $$Revision: 4.0.1.2 $$Date: 92/06/08 16:15:16 $ +/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: a2py.c,v $ + * Revision 4.1 92/08/07 18:29:14 lwall + * * Revision 4.0.1.2 92/06/08 16:15:16 lwall * patch20: in a2p, now warns about spurious backslashes * patch20: in a2p, now allows [ to be backslashed in pattern @@ -1295,4 +1297,3 @@ int prevargs; } return numargs; } - diff --git a/x2p/all b/x2p/all new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/x2p/all diff --git a/x2p/cflags b/x2p/cflags new file mode 100755 index 0000000000..ba795b376a --- /dev/null +++ b/x2p/cflags @@ -0,0 +1,55 @@ +case "$0" in +*/*) cd `expr X$0 : 'X\(.*\)/'` ;; +esac +case $CONFIG in +'') + if test ! -f config.sh; then + ln ../config.sh . || \ + ln ../../config.sh . || \ + ln ../../../config.sh . || \ + (echo "Can't find config.sh."; exit 1) + fi 2>/dev/null + . ./config.sh + ;; +esac + +also=': ' +case $# in +1) also='echo 1>&2 " CCCMD = "' +esac + +case $# in +0) set *.c; echo "The current C flags are:" ;; +esac + +set `echo "$* " | sed 's/\.[oc] / /g'` + +for file do + + case "$#" in + 1) ;; + *) echo $n " $file.c $c" ;; + esac + + : allow variables like str_cflags to be evaluated + + eval 'eval ${'"${file}_cflags"'-""}' + + : or customize here + + case "$file" in + a2p) ;; + a2py) ;; + hash) ;; + str) ;; + util) ;; + walk) ;; + *) ;; + esac + + echo "$cc -c $ccflags $optimize $large $split" + eval "$also "'"$cc -c $ccflags $optimize $large $split"' + + . ./config.sh + +done diff --git a/x2p/cflags.SH b/x2p/cflags.SH index db857c0492..db857c0492 100644..100755 --- a/x2p/cflags.SH +++ b/x2p/cflags.SH diff --git a/x2p/config.sh b/x2p/config.sh new file mode 120000 index 0000000000..3131e78bcf --- /dev/null +++ b/x2p/config.sh @@ -0,0 +1 @@ +../config.sh
\ No newline at end of file diff --git a/x2p/find2perl b/x2p/find2perl new file mode 100755 index 0000000000..62e6b1b740 --- /dev/null +++ b/x2p/find2perl @@ -0,0 +1,568 @@ +#!/usr/local/bin/perl + +eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + +$bin = "/usr/local/bin"; + + +while ($ARGV[0] =~ /^[^-!(]/) { + push(@roots, shift); +} +@roots = ('.') unless @roots; +for (@roots) { $_ = "e($_); } +$roots = join(',', @roots); + +$indent = 1; + +while (@ARGV) { + $_ = shift; + s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n"; + if ($_ eq '(') { + $out .= &tab . "(\n"; + $indent++; + next; + } + elsif ($_ eq ')') { + $indent--; + $out .= &tab . ")"; + } + elsif ($_ eq '!') { + $out .= &tab . "!"; + next; + } + elsif ($_ eq 'name') { + $out .= &tab; + $pat = &fileglob_to_re(shift); + $out .= '/' . $pat . "/"; + } + elsif ($_ eq 'perm') { + $onum = shift; + die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/; + if ($onum =~ s/^-//) { + $onum = '0' . sprintf("%o", oct($onum) & 017777); # s/b 07777 ? + $out .= &tab . "((\$mode & $onum) == $onum)"; + } + else { + $onum = '0' . $onum unless $onum =~ /^0/; + $out .= &tab . "((\$mode & 0777) == $onum)"; + } + } + elsif ($_ eq 'type') { + ($filetest = shift) =~ tr/s/S/; + $out .= &tab . "-$filetest _"; + } + elsif ($_ eq 'print') { + $out .= &tab . 'print("$name\n")'; + } + elsif ($_ eq 'print0') { + $out .= &tab . 'print("$name\0")'; + } + elsif ($_ eq 'fstype') { + $out .= &tab; + $type = shift; + if ($type eq 'nfs') + { $out .= '$dev < 0'; } + else + { $out .= '$dev >= 0'; } + } + elsif ($_ eq 'user') { + $uname = shift; + $out .= &tab . "\$uid == \$uid{'$uname'}"; + $inituser++; + } + elsif ($_ eq 'group') { + $gname = shift; + $out .= &tab . "\$gid == \$gid{'$gname'}"; + $initgroup++; + } + elsif ($_ eq 'nouser') { + $out .= &tab . '!defined $uid{$uid}'; + $inituser++; + } + elsif ($_ eq 'nogroup') { + $out .= &tab . '!defined $gid{$gid}'; + $initgroup++; + } + elsif ($_ eq 'links') { + $out .= &tab . '$nlink ' . &n(shift); + } + elsif ($_ eq 'inum') { + $out .= &tab . '$ino ' . &n(shift); + } + elsif ($_ eq 'size') { + $out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift); + } + elsif ($_ eq 'atime') { + $out .= &tab . 'int(-A _) ' . &n(shift); + } + elsif ($_ eq 'mtime') { + $out .= &tab . 'int(-M _) ' . &n(shift); + } + elsif ($_ eq 'ctime') { + $out .= &tab . 'int(-C _) ' . &n(shift); + } + elsif ($_ eq 'exec') { + for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } + shift; + $_ = "@cmd"; + if (m#^(/bin/)?rm -f {}$#) { + if (!@ARGV) { + $out .= &tab . 'unlink($_)'; + } + else { + $out .= &tab . '(unlink($_) || 1)'; + } + } + elsif (m#^(/bin/)?rm {}$#) { + $out .= &tab . '(unlink($_) || warn "$name: $!\n")'; + } + else { + for (@cmd) { s/'/\\'/g; } + $" = "','"; + $out .= &tab . "&exec(0, '@cmd')"; + $" = ' '; + $initexec++; + } + } + elsif ($_ eq 'ok') { + for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } + shift; + for (@cmd) { s/'/\\'/g; } + $" = "','"; + $out .= &tab . "&exec(1, '@cmd')"; + $" = ' '; + $initexec++; + } + elsif ($_ eq 'prune') { + $out .= &tab . '($prune = 1)'; + } + elsif ($_ eq 'xdev') { + $out .= &tab . '(($prune |= ($dev != $topdev)),1)'; + } + elsif ($_ eq 'newer') { + $out .= &tab; + $file = shift; + $newername = 'AGE_OF' . $file; + $newername =~ s/[^\w]/_/g; + $newername = '$' . $newername; + $out .= "-M _ < $newername"; + $initnewer .= "$newername = -M " . "e($file) . ";\n"; + } + elsif ($_ eq 'eval') { + $prog = "e(shift); + $out .= &tab . "eval $prog"; + } + elsif ($_ eq 'depth') { + $depth++; + next; + } + elsif ($_ eq 'ls') { + $out .= &tab . "&ls"; + $initls++; + } + elsif ($_ eq 'tar') { + $out .= &tab; + die "-tar must have a filename argument\n" unless @ARGV; + $file = shift; + $fh = 'FH' . $file; + $fh =~ s/[^\w]/_/g; + $out .= "&tar($fh)"; + $file = '>' . $file; + $initfile .= "open($fh, " . "e($file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $inittar++; + $flushall = "\n&tflushall;\n"; + } + elsif (/^n?cpio$/) { + $depth++; + $out .= &tab; + die "-$_ must have a filename argument\n" unless @ARGV; + $file = shift; + $fh = 'FH' . $file; + $fh =~ s/[^\w]/_/g; + $out .= "&cpio('" . substr($_,0,1) . "', $fh)"; + $file = '>' . $file; + $initfile .= "open($fh, " . "e($file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $initcpio++; + $flushall = "\n&flushall;\n"; + } + else { + die "Unrecognized switch: -$_\n"; + } + if (@ARGV) { + if ($ARGV[0] eq '-o') { + { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; } + $statdone = 0 if $indent == 1 && $delayedstat; + $saw_or++; + shift; + } + else { + $out .= " &&" unless $ARGV[0] eq ')'; + $out .= "\n"; + shift if $ARGV[0] eq '-a'; + } + } +} + +print <<"END"; +#!$bin/perl + +eval 'exec $bin/perl -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; + +END + +if ($initls) { + print <<'END'; +@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx'); +@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); + +END +} + +if ($inituser || $initls) { + print 'while (($name, $pw, $uid) = getpwent) {', "\n"; + print ' $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser; + print ' $user{$uid} = $name unless $user{$uid};', "\n" if $initls; + print "}\n\n"; +} + +if ($initgroup || $initls) { + print 'while (($name, $pw, $gid) = getgrent) {', "\n"; + print ' $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup; + print ' $group{$gid} = $name unless $group{$gid};', "\n" if $initls; + print "}\n\n"; +} + +print $initnewer, "\n" if $initnewer; + +print $initfile, "\n" if $initfile; + +$find = $depth ? "finddepth" : "find"; +print <<"END"; +require "$find.pl"; + +# Traverse desired filesystems + +&$find($roots); +$flushall +exit; + +sub wanted { +$out; +} + +END + +if ($initexec) { + print <<'END'; +sub exec { + local($ok, @cmd) = @_; + foreach $word (@cmd) { + $word =~ s#{}#$name#g; + } + if ($ok) { + local($old) = select(STDOUT); + $| = 1; + print "@cmd"; + select($old); + return 0 unless <STDIN> =~ /^y/; + } + chdir $cwd; # sigh + system @cmd; + chdir $dir; + return !$?; +} + +END +} + +if ($initls) { + print <<'END'; +sub ls { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + + $pname = $name; + + if (defined $blocks) { + $blocks = int(($blocks + 1) / 2); + } + else { + $blocks = int(($size + 1023) / 1024); + } + + if (-f _) { $perms = '-'; } + elsif (-d _) { $perms = 'd'; } + elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; } + elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; } + elsif (-p _) { $perms = 'p'; } + elsif (-S _) { $perms = 's'; } + else { $perms = 'l'; $pname .= ' -> ' . readlink($_); } + + $tmpmode = $mode; + $tmp = $rwx[$tmpmode & 7]; + $tmpmode >>= 3; + $tmp = $rwx[$tmpmode & 7] . $tmp; + $tmpmode >>= 3; + $tmp = $rwx[$tmpmode & 7] . $tmp; + substr($tmp,2,1) =~ tr/-x/Ss/ if -u _; + substr($tmp,5,1) =~ tr/-x/Ss/ if -g _; + substr($tmp,8,1) =~ tr/-x/Tt/ if -k _; + $perms .= $tmp; + + $user = $user{$uid} || $uid; + $group = $group{$gid} || $gid; + + ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); + $moname = $moname[$mon]; + if (-M _ > 365.25 / 2) { + $timeyear = '19' . $year; + } + else { + $timeyear = sprintf("%02d:%02d", $hour, $min); + } + + printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n", + $ino, + $blocks, + $perms, + $nlink, + $user, + $group, + $sizemm, + $moname, + $mday, + $timeyear, + $pname; + 1; +} + +sub sizemm { + sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255); +} + +END +} + +if ($initcpio) { +print <<'END'; +sub cpio { + local($nc,$fh) = @_; + local($text); + + if ($name eq 'TRAILER!!!') { + $text = ''; + $size = 0; + } + else { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $name: $!\n"; + return; + }; + } + else { + $text = readlink($_); + $size = 0 unless defined $text; + } + } + + ($nm = $name) =~ s#^\./##; + $nc{$fh} = $nc; + if ($nc eq 'n') { + $cpout{$fh} .= + sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0", + 070707, + $dev & 0777777, + $ino & 0777777, + $mode & 0777777, + $uid & 0777777, + $gid & 0777777, + $nlink & 0777777, + $rdev & 0177777, + $mtime, + length($nm)+1, + $size, + $nm); + } + else { + $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1; + $cpout{$fh} .= pack("SSSSSSSSLSLa*", + 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, + length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0")); + } + if ($text ne '') { + $cpout{$fh} .= $text; + } + elsif ($size) { + &flush($fh) while ($l = length($cpout{$fh})) >= 5120; + while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) { + &flush($fh); + $l = length($cpout{$fh}); + } + } + close IN; +} + +sub flush { + local($fh) = @_; + + while (length($cpout{$fh}) >= 5120) { + syswrite($fh,$cpout{$fh},5120); + ++$blocks{$fh}; + substr($cpout{$fh}, 0, 5120) = ''; + } +} + +sub flushall { + $name = 'TRAILER!!!'; + foreach $fh (keys %cpout) { + &cpio($nc{$fh},$fh); + $cpout{$fh} .= "0" x (5120 - length($cpout{$fh})); + &flush($fh); + print $blocks{$fh} * 10, " blocks\n"; + } +} + +END +} + +if ($inittar) { +print <<'END'; +sub tar { + local($fh) = @_; + local($linkname,$header,$l,$slop); + local($linkflag) = "\0"; + + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + $nm = $name; + if ($nlink > 1) { + if ($linkname = $linkseen{$fh,$dev,$ino}) { + $linkflag = 1; + } + else { + $linkseen{$fh,$dev,$ino} = $nm; + } + } + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $name: $!\n"; + return; + }; + $size = 0 if $linkflag ne "\0"; + } + else { + $linkname = readlink($_); + $linkflag = 2 if defined $linkname; + $nm .= '/' if -d _; + $size = 0; + } + + $header = pack("a100a8a8a8a12a12a8a1a100", + $nm, + sprintf("%6o ", $mode & 0777), + sprintf("%6o ", $uid & 0777777), + sprintf("%6o ", $gid & 0777777), + sprintf("%11o ", $size), + sprintf("%11o ", $mtime), + " ", + $linkflag, + $linkname); + $l = length($header) % 512; + substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header)); + substr($header, 154, 1) = "\0"; # blech + $tarout{$fh} .= $header; + $tarout{$fh} .= "\0" x (512 - $l) if $l; + if ($size) { + &tflush($fh) while ($l = length($tarout{$fh})) >= 10240; + while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) { + $slop = length($tarout{$fh}) % 512; + $tarout{$fh} .= "\0" x (512 - $slop) if $slop; + &tflush($fh); + $l = length($tarout{$fh}); + } + } + close IN; +} + +sub tflush { + local($fh) = @_; + + while (length($tarout{$fh}) >= 10240) { + syswrite($fh,$tarout{$fh},10240); + ++$blocks{$fh}; + substr($tarout{$fh}, 0, 10240) = ''; + } +} + +sub tflushall { + local($len); + + foreach $fh (keys %tarout) { + $len = 10240 - length($tarout{$fh}); + $len += 10240 if $len < 1024; + $tarout{$fh} .= "\0" x $len; + &tflush($fh); + } +} + +END +} + +exit; + +############################################################################ + +sub tab { + local($tabstring); + + $tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4); + if (!$statdone) { + if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) { + $delayedstat++; + } + else { + if ($saw_or) { + $tabstring .= <<'ENDOFSTAT' . $tabstring; +($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) && +ENDOFSTAT + } + else { + $tabstring .= <<'ENDOFSTAT' . $tabstring; +(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && +ENDOFSTAT + } + $statdone = 1; + } + } + $tabstring =~ s/^\s+/ / if $out =~ /!$/; + $tabstring; +} + +sub fileglob_to_re { + local($tmp) = @_; + + $tmp =~ s/([.^\$()])/\\$1/g; + $tmp =~ s/([?*])/.$1/g; + "^$tmp$"; +} + +sub n { + local($n) = @_; + + $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /; + $n =~ s/ 0*(\d)/ $1/; + $n; +} + +sub quote { + local($string) = @_; + $string =~ s/'/\\'/; + "'$string'"; +} diff --git a/x2p/find2perl.SH b/x2p/find2perl.SH index 4a95de04a1..324ec12654 100644..100755 --- a/x2p/find2perl.SH +++ b/x2p/find2perl.SH @@ -89,18 +89,18 @@ while (@ARGV) { $out .= &tab; $type = shift; if ($type eq 'nfs') - { $out .= '$dev < 0'; } + { $out .= '($dev < 0)'; } else - { $out .= '$dev >= 0'; } + { $out .= '($dev >= 0)'; } } elsif ($_ eq 'user') { $uname = shift; - $out .= &tab . "\$uid == \$uid{'$uname'}"; + $out .= &tab . "(\$uid == \$uid{'$uname'})"; $inituser++; } elsif ($_ eq 'group') { $gname = shift; - $out .= &tab . "\$gid == \$gid{'$gname'}"; + $out .= &tab . "(\$gid == \$gid{'$gname'})"; $initgroup++; } elsif ($_ eq 'nouser') { @@ -112,22 +112,22 @@ while (@ARGV) { $initgroup++; } elsif ($_ eq 'links') { - $out .= &tab . '$nlink ' . &n(shift); + $out .= &tab . '($nlink ' . &n(shift); } elsif ($_ eq 'inum') { - $out .= &tab . '$ino ' . &n(shift); + $out .= &tab . '($ino ' . &n(shift); } elsif ($_ eq 'size') { - $out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift); + $out .= &tab . '(int((-s _ + 511) / 512) ' . &n(shift); } elsif ($_ eq 'atime') { - $out .= &tab . 'int(-A _) ' . &n(shift); + $out .= &tab . '(int(-A _) ' . &n(shift); } elsif ($_ eq 'mtime') { - $out .= &tab . 'int(-M _) ' . &n(shift); + $out .= &tab . '(int(-M _) ' . &n(shift); } elsif ($_ eq 'ctime') { - $out .= &tab . 'int(-C _) ' . &n(shift); + $out .= &tab . '(int(-C _) ' . &n(shift); } elsif ($_ eq 'exec') { for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } @@ -173,7 +173,7 @@ while (@ARGV) { $newername = 'AGE_OF' . $file; $newername =~ s/[^\w]/_/g; $newername = '$' . $newername; - $out .= "-M _ < $newername"; + $out .= "(-M _ < $newername)"; $initnewer .= "$newername = -M " . "e($file) . ";\n"; } elsif ($_ eq 'eval') { @@ -575,7 +575,7 @@ ENDOFSTAT sub fileglob_to_re { local($tmp) = @_; - $tmp =~ s/([.^\$()])/\\$1/g; + $tmp =~ s#([./^\$()])#\\$1#g; $tmp =~ s/([?*])/.$1/g; "^$tmp$"; } @@ -585,7 +585,7 @@ sub n { $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /; $n =~ s/ 0*(\d)/ $1/; - $n; + $n . ')'; } sub quote { diff --git a/x2p/handy.h b/x2p/handy.h index 25a1bdac1e..ee31a1c577 100644 --- a/x2p/handy.h +++ b/x2p/handy.h @@ -1,4 +1,4 @@ -/* $RCSfile: handy.h,v $$Revision: 4.0.1.2 $$Date: 91/06/07 12:15:43 $ +/* $RCSfile: handy.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:19 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: handy.h,v $ + * Revision 4.1 92/08/07 18:29:19 lwall + * * Revision 4.0.1.2 91/06/07 12:15:43 lwall * patch4: new copyright notice * diff --git a/x2p/hash.c b/x2p/hash.c index 03ff1b2c79..96b854f770 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -1,4 +1,4 @@ -/* $RCSfile: hash.c,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:15:55 $ +/* $RCSfile: hash.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:20 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: hash.c,v $ + * Revision 4.1 92/08/07 18:29:20 lwall + * * Revision 4.0.1.1 91/06/07 12:15:55 lwall * patch4: new copyright notice * diff --git a/x2p/hash.h b/x2p/hash.h index bd65b8dbac..a977ae5cfc 100644 --- a/x2p/hash.h +++ b/x2p/hash.h @@ -1,4 +1,4 @@ -/* $RCSfile: hash.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:16:04 $ +/* $RCSfile: hash.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:21 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: hash.h,v $ + * Revision 4.1 92/08/07 18:29:21 lwall + * * Revision 4.0.1.1 91/06/07 12:16:04 lwall * patch4: new copyright notice * diff --git a/x2p/make.out b/x2p/make.out new file mode 100644 index 0000000000..bd2565451f --- /dev/null +++ b/x2p/make.out @@ -0,0 +1,13 @@ +../makedepend +make: Warning: Both `makefile' and `Makefile' exists +Current working directory /usr/src/local/lwall/perl5/x2p +echo hash.c malloc.c str.c util.c walk.c | tr ' ' '\012' >.clist +Finding dependencies for hash.o. +Finding dependencies for malloc.o. +Finding dependencies for str.o. +Finding dependencies for util.o. +Finding dependencies for walk.o. +make: Warning: Both `makefile' and `Makefile' exists +Current working directory /usr/src/local/lwall/perl5/x2p +echo Makefile.SH makedepend.SH | tr ' ' '\012' >.shlist +Updating makefile... diff --git a/x2p/makefile b/x2p/makefile new file mode 100644 index 0000000000..d6a11d348d --- /dev/null +++ b/x2p/makefile @@ -0,0 +1,229 @@ +# : Makefile.SH,v 15738Revision: 4.1 15738Date: 92/08/07 18:29:07 $ +# +# $Log: Makefile.SH,v $ +# Revision 4.1 92/08/07 18:29:07 lwall +# +# Revision 4.0.1.3 92/06/08 16:11:32 lwall +# patch20: SH files didn't work well with symbolic links +# patch20: cray didn't give enough memory to /bin/sh +# patch20: makefiles now display new shift/reduce expectations +# +# Revision 4.0.1.2 91/11/05 19:19:04 lwall +# patch11: random cleanup +# +# Revision 4.0.1.1 91/06/07 12:12:14 lwall +# patch4: cflags now emits entire cc command except for the filename +# +# Revision 4.0 91/03/20 01:57:03 lwall +# 4.0 baseline. +# +# + +CC = cc +YACC = /bin/yacc +bin = /usr/local/bin +lib = +mansrc = /usr/man/manl +manext = l +LDFLAGS = +SMALL = +LARGE = +mallocsrc = malloc.c +mallocobj = malloc.o +shellflags = + +libs = -ldbm -lm -lposix + +CCCMD = `sh $(shellflags) cflags $@` + +public = a2p s2p find2perl + +private = + +manpages = a2p.man s2p.man + +util = + +sh = Makefile.SH makedepend.SH + +h = EXTERN.h INTERN.h ../config.h handy.h hash.h a2p.h str.h util.h + +c = hash.c $(mallocsrc) str.c util.c walk.c + +obj = hash.o $(mallocobj) str.o util.o walk.o + +lintflags = -phbvxac + +addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7 + +# grrr +SHELL = /bin/sh + +.c.o: + $(CCCMD) $*.c + +all: $(public) $(private) $(util) + touch all + +a2p: $(obj) a2p.o + $(CC) $(LDFLAGS) $(obj) a2p.o $(libs) -o a2p + +a2p.c: a2p.y + @ echo Expect 231 shift/reduce conflicts... + $(YACC) a2p.y + mv y.tab.c a2p.c + +a2p.o: a2p.c a2py.c a2p.h EXTERN.h util.h INTERN.h handy.h ../config.h str.h hash.h + $(CCCMD) $(LARGE) a2p.c + +install: a2p s2p +# won't work with csh + export PATH || exit 1 + - mv $(bin)/a2p $(bin)/a2p.old 2>/dev/null + - mv $(bin)/s2p $(bin)/s2p.old 2>/dev/null + - if test `pwd` != $(bin); then cp $(public) $(bin); fi + cd $(bin); \ +for pub in $(public); do \ +chmod +x `basename $$pub`; \ +done + - if test `pwd` != $(mansrc); then \ +for page in $(manpages); do \ +cp $$page $(mansrc)/`basename $$page .man`.$(manext); \ +done; \ +fi + +clean: + rm -f a2p *.o a2p.c + +realclean: clean + rm -f *.orig */*.orig core $(addedbyconf) a2p.c s2p find2perl all cflags + +# The following lint has practically everything turned on. Unfortunately, +# you have to wade through a lot of mumbo jumbo that can't be suppressed. +# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message +# for that spot. + +lint: + lint $(lintflags) $(defs) $(c) > a2p.fuzz + +depend: $(mallocsrc) ../makedepend + ../makedepend + +clist: + echo $(c) | tr ' ' '\012' >.clist + +hlist: + echo $(h) | tr ' ' '\012' >.hlist + +shlist: + echo $(sh) | tr ' ' '\012' >.shlist + +config.sh: ../config.sh + rm -f config.sh + ln ../config.sh . + +malloc.c: ../malloc.c + sed <../malloc.c >malloc.c \ + -e 's/"perl.h"/"..\/perl.h"/' \ + -e 's/my_exit/exit/' + +# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE +# If this runs make out of memory, delete /usr/include lines. +hash.o: +hash.o: ../config.h +hash.o: /usr/ucbinclude/ctype.h +hash.o: /usr/ucbinclude/stdio.h +hash.o: EXTERN.h +hash.o: a2p.h +hash.o: handy.h +hash.o: hash.c +hash.o: hash.h +hash.o: str.h +hash.o: util.h +malloc.o: +malloc.o: ../av.h +malloc.o: ../config.h +malloc.o: ../cop.h +malloc.o: ../embed.h +malloc.o: ../form.h +malloc.o: ../gv.h +malloc.o: ../handy.h +malloc.o: ../hv.h +malloc.o: ../op.h +malloc.o: ../opcode.h +malloc.o: ../perl.h +malloc.o: ../pm.h +malloc.o: ../pp.h +malloc.o: ../proto.h +malloc.o: ../regexp.h +malloc.o: ../sv.h +malloc.o: ../unixish.h +malloc.o: ../util.h +malloc.o: /usr/ucbinclude/ctype.h +malloc.o: /usr/ucbinclude/dirent.h +malloc.o: /usr/ucbinclude/errno.h +malloc.o: /usr/ucbinclude/machine/param.h +malloc.o: /usr/ucbinclude/machine/setjmp.h +malloc.o: /usr/ucbinclude/ndbm.h +malloc.o: /usr/ucbinclude/netinet/in.h +malloc.o: /usr/ucbinclude/setjmp.h +malloc.o: /usr/ucbinclude/stdio.h +malloc.o: /usr/ucbinclude/sys/dirent.h +malloc.o: /usr/ucbinclude/sys/errno.h +malloc.o: /usr/ucbinclude/sys/filio.h +malloc.o: /usr/ucbinclude/sys/ioccom.h +malloc.o: /usr/ucbinclude/sys/ioctl.h +malloc.o: /usr/ucbinclude/sys/param.h +malloc.o: /usr/ucbinclude/sys/signal.h +malloc.o: /usr/ucbinclude/sys/sockio.h +malloc.o: /usr/ucbinclude/sys/stat.h +malloc.o: /usr/ucbinclude/sys/stdtypes.h +malloc.o: /usr/ucbinclude/sys/sysmacros.h +malloc.o: /usr/ucbinclude/sys/time.h +malloc.o: /usr/ucbinclude/sys/times.h +malloc.o: /usr/ucbinclude/sys/ttold.h +malloc.o: /usr/ucbinclude/sys/ttychars.h +malloc.o: /usr/ucbinclude/sys/ttycom.h +malloc.o: /usr/ucbinclude/sys/ttydev.h +malloc.o: /usr/ucbinclude/sys/types.h +malloc.o: /usr/ucbinclude/time.h +malloc.o: /usr/ucbinclude/vm/faultcode.h +malloc.o: EXTERN.h +malloc.o: malloc.c +str.o: +str.o: ../config.h +str.o: /usr/ucbinclude/ctype.h +str.o: /usr/ucbinclude/stdio.h +str.o: EXTERN.h +str.o: a2p.h +str.o: handy.h +str.o: hash.h +str.o: str.c +str.o: str.h +str.o: util.h +util.o: +util.o: ../config.h +util.o: /usr/ucbinclude/ctype.h +util.o: /usr/ucbinclude/stdio.h +util.o: EXTERN.h +util.o: INTERN.h +util.o: a2p.h +util.o: handy.h +util.o: hash.h +util.o: str.h +util.o: util.c +util.o: util.h +walk.o: +walk.o: ../config.h +walk.o: /usr/ucbinclude/ctype.h +walk.o: /usr/ucbinclude/stdio.h +walk.o: EXTERN.h +walk.o: a2p.h +walk.o: handy.h +walk.o: hash.h +walk.o: str.h +walk.o: util.h +walk.o: walk.c +Makefile: Makefile.SH config.sh ; /bin/sh Makefile.SH +makedepend: makedepend.SH config.sh ; /bin/sh makedepend.SH +# WARNING: Put nothing here or make depend will gobble it up! diff --git a/x2p/malloc.c b/x2p/malloc.c new file mode 100644 index 0000000000..c31d0e151e --- /dev/null +++ b/x2p/malloc.c @@ -0,0 +1,506 @@ +/* $RCSfile: malloc.c,v $$Revision: 4.1 $$Date: 92/08/07 18:24:25 $ + * + * $Log: malloc.c,v $ + * Revision 4.1 92/08/07 18:24:25 lwall + * + * Revision 4.0.1.4 92/06/08 14:28:38 lwall + * patch20: removed implicit int declarations on functions + * patch20: hash tables now split only if the memory is available to do so + * patch20: realloc(0, size) now does malloc in case library routines call it + * + * Revision 4.0.1.3 91/11/05 17:57:40 lwall + * patch11: safe malloc code now integrated into Perl's malloc when possible + * + * Revision 4.0.1.2 91/06/07 11:20:45 lwall + * patch4: many, many itty-bitty portability fixes + * + * Revision 4.0.1.1 91/04/11 17:48:31 lwall + * patch1: Configure now figures out malloc ptr type + * + * Revision 4.0 91/03/20 01:28:52 lwall + * 4.0 baseline. + * + */ + +#ifndef lint +/*SUPPRESS 592*/ +static char sccsid[] = "@(#)malloc.c 4.3 (Berkeley) 9/16/83"; + +#ifdef DEBUGGING +#define RCHECK +#endif +/* + * malloc.c (Caltech) 2/21/82 + * Chris Kingsley, kingsley@cit-20. + * + * This is a very fast storage allocator. It allocates blocks of a small + * number of different sizes, and keeps free lists of each size. Blocks that + * don't exactly fit are passed up to the next larger size. In this + * implementation, the available sizes are 2^n-4 (or 2^n-12) bytes long. + * This is designed for use in a program that uses vast quantities of memory, + * but bombs when it runs out. + */ + +#include "EXTERN.h" +#include "../perl.h" + +static int findbucket(); +static int morecore(); + +/* I don't much care whether these are defined in sys/types.h--LAW */ + +#define u_char unsigned char +#define u_int unsigned int +#define u_short unsigned short + +/* + * The overhead on a block is at least 4 bytes. When free, this space + * contains a pointer to the next free block, and the bottom two bits must + * be zero. When in use, the first byte is set to MAGIC, and the second + * byte is the size index. The remaining bytes are for alignment. + * If range checking is enabled and the size of the block fits + * in two bytes, then the top two bytes hold the size of the requested block + * plus the range checking words, and the header word MINUS ONE. + */ +union overhead { + union overhead *ov_next; /* when free */ +#if ALIGNBYTES > 4 + double strut; /* alignment problems */ +#endif + struct { + u_char ovu_magic; /* magic number */ + u_char ovu_index; /* bucket # */ +#ifdef RCHECK + u_short ovu_size; /* actual block size */ + u_int ovu_rmagic; /* range magic number */ +#endif + } ovu; +#define ov_magic ovu.ovu_magic +#define ov_index ovu.ovu_index +#define ov_size ovu.ovu_size +#define ov_rmagic ovu.ovu_rmagic +}; + +#define MAGIC 0xff /* magic # on accounting info */ +#define OLDMAGIC 0x7f /* same after a free() */ +#define RMAGIC 0x55555555 /* magic # on range info */ +#ifdef RCHECK +#define RSLOP sizeof (u_int) +#else +#define RSLOP 0 +#endif + +/* + * nextf[i] is the pointer to the next free block of size 2^(i+3). The + * smallest allocatable block is 8 bytes. The overhead information + * precedes the data area returned to the user. + */ +#define NBUCKETS 30 +static union overhead *nextf[NBUCKETS]; +extern char *sbrk(); + +#ifdef MSTATS +/* + * nmalloc[i] is the difference between the number of mallocs and frees + * for a given block size. + */ +static u_int nmalloc[NBUCKETS]; +#include <stdio.h> +#endif + +#ifdef debug +#define ASSERT(p) if (!(p)) botch("p"); else +static void +botch(s) + char *s; +{ + + printf("assertion botched: %s\n", s); + abort(); +} +#else +#define ASSERT(p) +#endif + +MALLOCPTRTYPE * +malloc(nbytes) + register MEM_SIZE nbytes; +{ + register union overhead *p; + register int bucket = 0; + register MEM_SIZE shiftr; + +#ifdef safemalloc +#ifdef DEBUGGING + MEM_SIZE size = nbytes; +#endif + +#ifdef MSDOS + if (nbytes > 0xffff) { + fprintf(stderr, "Allocation too large: %lx\n", (long)nbytes); + exit(1); + } +#endif /* MSDOS */ +#ifdef DEBUGGING + if ((long)nbytes < 0) + fatal("panic: malloc"); +#endif +#endif /* safemalloc */ + + /* + * Convert amount of memory requested into + * closest block size stored in hash buckets + * which satisfies request. Account for + * space used per block for accounting. + */ + nbytes += sizeof (union overhead) + RSLOP; + nbytes = (nbytes + 3) &~ 3; + shiftr = (nbytes - 1) >> 2; + /* apart from this loop, this is O(1) */ + while (shiftr >>= 1) + bucket++; + /* + * If nothing in hash bucket right now, + * request more memory from the system. + */ + if (nextf[bucket] == NULL) + morecore(bucket); + if ((p = (union overhead *)nextf[bucket]) == NULL) { +#ifdef safemalloc + if (!nomemok) { + fputs("Out of memory!\n", stderr); + exit(1); + } +#else + return (NULL); +#endif + } + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) malloc %ld bytes\n",p+1,an++,(long)size); +# else + if (debug & 128) + fprintf(stderr,"0x%lx: (%05d) malloc %ld bytes\n",p+1,an++,(long)size); +# endif +#endif +#endif /* safemalloc */ + + /* remove from linked list */ +#ifdef RCHECK + if (*((int*)p) & (sizeof(union overhead) - 1)) +#if !(defined(I286) || defined(atarist)) + fprintf(stderr,"Corrupt malloc ptr 0x%x at 0x%x\n",*((int*)p),p); +#else + fprintf(stderr,"Corrupt malloc ptr 0x%lx at 0x%lx\n",*((int*)p),p); +#endif +#endif + nextf[bucket] = p->ov_next; + p->ov_magic = MAGIC; + p->ov_index= bucket; +#ifdef MSTATS + nmalloc[bucket]++; +#endif +#ifdef RCHECK + /* + * Record allocated size of block and + * bound space with magic numbers. + */ + if (nbytes <= 0x10000) + p->ov_size = nbytes - 1; + p->ov_rmagic = RMAGIC; + *((u_int *)((caddr_t)p + nbytes - RSLOP)) = RMAGIC; +#endif + return ((MALLOCPTRTYPE *)(p + 1)); +} + +/* + * Allocate more memory to the indicated bucket. + */ +static +morecore(bucket) + register int bucket; +{ + register union overhead *op; + register int rnu; /* 2^rnu bytes will be requested */ + register int nblks; /* become nblks blocks of the desired size */ + register MEM_SIZE siz; + + if (nextf[bucket]) + return; + /* + * Insure memory is allocated + * on a page boundary. Should + * make getpageize call? + */ +#ifndef atarist /* on the atari we dont have to worry about this */ + op = (union overhead *)sbrk(0); +#ifndef I286 + if ((int)op & 0x3ff) + (void)sbrk(1024 - ((int)op & 0x3ff)); +#else + /* The sbrk(0) call on the I286 always returns the next segment */ +#endif +#endif /* atarist */ + +#if !(defined(I286) || defined(atarist)) + /* take 2k unless the block is bigger than that */ + rnu = (bucket <= 8) ? 11 : bucket + 3; +#else + /* take 16k unless the block is bigger than that + (80286s like large segments!), probably good on the atari too */ + rnu = (bucket <= 11) ? 14 : bucket + 3; +#endif + nblks = 1 << (rnu - (bucket + 3)); /* how many blocks to get */ + if (rnu < bucket) + rnu = bucket; + op = (union overhead *)sbrk(1L << rnu); + /* no more room! */ + if ((int)op == -1) + return; + /* + * Round up to minimum allocation size boundary + * and deduct from block count to reflect. + */ +#ifndef I286 + if ((int)op & 7) { + op = (union overhead *)(((MEM_SIZE)op + 8) &~ 7); + nblks--; + } +#else + /* Again, this should always be ok on an 80286 */ +#endif + /* + * Add new memory allocated to that on + * free list for this hash bucket. + */ + nextf[bucket] = op; + siz = 1 << (bucket + 3); + while (--nblks > 0) { + op->ov_next = (union overhead *)((caddr_t)op + siz); + op = (union overhead *)((caddr_t)op + siz); + } +} + +void +free(mp) + MALLOCPTRTYPE *mp; +{ + register MEM_SIZE size; + register union overhead *op; + char *cp = (char*)mp; + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) free\n",cp,an++); +# else + if (debug & 128) + fprintf(stderr,"0x%lx: (%05d) free\n",cp,an++); +# endif +#endif +#endif /* safemalloc */ + + if (cp == NULL) + return; + op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); +#ifdef debug + ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */ +#else + if (op->ov_magic != MAGIC) { + warn("%s free() ignored", + op->ov_magic == OLDMAGIC ? "Duplicate" : "Bad"); + return; /* sanity */ + } + op->ov_magic = OLDMAGIC; +#endif +#ifdef RCHECK + ASSERT(op->ov_rmagic == RMAGIC); + if (op->ov_index <= 13) + ASSERT(*(u_int *)((caddr_t)op + op->ov_size + 1 - RSLOP) == RMAGIC); +#endif + ASSERT(op->ov_index < NBUCKETS); + size = op->ov_index; + op->ov_next = nextf[size]; + nextf[size] = op; +#ifdef MSTATS + nmalloc[size]--; +#endif +} + +/* + * When a program attempts "storage compaction" as mentioned in the + * old malloc man page, it realloc's an already freed block. Usually + * this is the last block it freed; occasionally it might be farther + * back. We have to search all the free lists for the block in order + * to determine its bucket: 1st we make one pass thru the lists + * checking only the first block in each; if that fails we search + * ``reall_srchlen'' blocks in each list for a match (the variable + * is extern so the caller can modify it). If that fails we just copy + * however many bytes was given to realloc() and hope it's not huge. + */ +int reall_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ + +MALLOCPTRTYPE * +realloc(mp, nbytes) + MALLOCPTRTYPE *mp; + MEM_SIZE nbytes; +{ + register MEM_SIZE onb; + union overhead *op; + char *res; + register int i; + int was_alloced = 0; + char *cp = (char*)mp; + +#ifdef safemalloc +#ifdef DEBUGGING + MEM_SIZE size = nbytes; +#endif + +#ifdef MSDOS + if (nbytes > 0xffff) { + fprintf(stderr, "Reallocation too large: %lx\n", size); + exit(1); + } +#endif /* MSDOS */ + if (!cp) + return malloc(nbytes); +#ifdef DEBUGGING + if ((long)nbytes < 0) + fatal("panic: realloc"); +#endif +#endif /* safemalloc */ + + op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); + if (op->ov_magic == MAGIC) { + was_alloced++; + i = op->ov_index; + } else { + /* + * Already free, doing "compaction". + * + * Search for the old block of memory on the + * free list. First, check the most common + * case (last element free'd), then (this failing) + * the last ``reall_srchlen'' items free'd. + * If all lookups fail, then assume the size of + * the memory block being realloc'd is the + * smallest possible. + */ + if ((i = findbucket(op, 1)) < 0 && + (i = findbucket(op, reall_srchlen)) < 0) + i = 0; + } + onb = (1L << (i + 3)) - sizeof (*op) - RSLOP; + /* avoid the copy if same size block */ + if (was_alloced && + nbytes <= onb && nbytes > (onb >> 1) - sizeof(*op) - RSLOP) { +#ifdef RCHECK + /* + * Record new allocated size of block and + * bound space with magic numbers. + */ + if (op->ov_index <= 13) { + /* + * Convert amount of memory requested into + * closest block size stored in hash buckets + * which satisfies request. Account for + * space used per block for accounting. + */ + nbytes += sizeof (union overhead) + RSLOP; + nbytes = (nbytes + 3) &~ 3; + op->ov_size = nbytes - 1; + *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC; + } +#endif + res = cp; + } + else { + if ((res = (char*)malloc(nbytes)) == NULL) + return (NULL); + if (cp != res) /* common optimization */ + Copy(cp, res, (MEM_SIZE)(nbytes<onb?nbytes:onb), char); + if (was_alloced) + free(cp); + } + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) { + fprintf(stderr,"0x%x: (%05d) rfree\n",res,an++); + fprintf(stderr,"0x%x: (%05d) realloc %ld bytes\n",res,an++,(long)size); + } +# else + if (debug & 128) { + fprintf(stderr,"0x%lx: (%05d) rfree\n",res,an++); + fprintf(stderr,"0x%lx: (%05d) realloc %ld bytes\n",res,an++,(long)size); + } +# endif +#endif +#endif /* safemalloc */ + return ((MALLOCPTRTYPE*)res); +} + +/* + * Search ``srchlen'' elements of each free list for a block whose + * header starts at ``freep''. If srchlen is -1 search the whole list. + * Return bucket number, or -1 if not found. + */ +static int +findbucket(freep, srchlen) + union overhead *freep; + int srchlen; +{ + register union overhead *p; + register int i, j; + + for (i = 0; i < NBUCKETS; i++) { + j = 0; + for (p = nextf[i]; p && j != srchlen; p = p->ov_next) { + if (p == freep) + return (i); + j++; + } + } + return (-1); +} + +#ifdef MSTATS +/* + * mstats - print out statistics about malloc + * + * Prints two lines of numbers, one showing the length of the free list + * for each size category, the second showing the number of mallocs - + * frees for each size category. + */ +void +mstats(s) + char *s; +{ + register int i, j; + register union overhead *p; + int totfree = 0, + totused = 0; + + fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s); + for (i = 0; i < NBUCKETS; i++) { + for (j = 0, p = nextf[i]; p; p = p->ov_next, j++) + ; + fprintf(stderr, " %d", j); + totfree += j * (1 << (i + 3)); + } + fprintf(stderr, "\nused:\t"); + for (i = 0; i < NBUCKETS; i++) { + fprintf(stderr, " %d", nmalloc[i]); + totused += nmalloc[i] * (1 << (i + 3)); + } + fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n", + totused, totfree); +} +#endif +#endif /* lint */ diff --git a/x2p/s2p b/x2p/s2p new file mode 100755 index 0000000000..fa6e01791d --- /dev/null +++ b/x2p/s2p @@ -0,0 +1,760 @@ +#!/usr/local/bin/perl + +eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + +$bin = '/usr/local/bin'; + +# $RCSfile: s2p.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:29:23 $ +# +# $Log: s2p.SH,v $ +# Revision 4.1 92/08/07 18:29:23 lwall +# +# Revision 4.0.1.2 92/06/08 17:26:31 lwall +# patch20: s2p didn't output portable startup code +# patch20: added ... as variant on .. +# patch20: s2p didn't translate s/pat/\&/ or s/pat/\$/ or s/pat/\\1/ right +# +# Revision 4.0.1.1 91/06/07 12:19:18 lwall +# patch4: s2p now handles embedded newlines better and optimizes common idioms +# +# Revision 4.0 91/03/20 01:57:59 lwall +# 4.0 baseline. +# +# + +$indent = 4; +$shiftwidth = 4; +$l = '{'; $r = '}'; + +while ($ARGV[0] =~ /^-/) { + $_ = shift; + last if /^--/; + if (/^-D/) { + $debug++; + open(BODY,'>-'); + next; + } + if (/^-n/) { + $assumen++; + next; + } + if (/^-p/) { + $assumep++; + next; + } + die "I don't recognize this switch: $_\n"; +} + +unless ($debug) { + open(BODY,">/tmp/sperl$$") || + &Die("Can't open temp file: $!\n"); +} + +if (!$assumen && !$assumep) { + print BODY &q(<<'EOT'); +: while ($ARGV[0] =~ /^-/) { +: $_ = shift; +: last if /^--/; +: if (/^-n/) { +: $nflag++; +: next; +: } +: die "I don't recognize this switch: $_\\n"; +: } +: +EOT +} + +print BODY &q(<<'EOT'); +: #ifdef PRINTIT +: #ifdef ASSUMEP +: $printit++; +: #else +: $printit++ unless $nflag; +: #endif +: #endif +: <><> +: $\ = "\n"; # automatically add newline on print +: <><> +: #ifdef TOPLABEL +: LINE: +: while (chop($_ = <>)) { +: #else +: LINE: +: while (<>) { +: chop; +: #endif +EOT + +LINE: +while (<>) { + + # Wipe out surrounding whitespace. + + s/[ \t]*(.*)\n$/$1/; + + # Perhaps it's a label/comment. + + if (/^:/) { + s/^:[ \t]*//; + $label = &make_label($_); + if ($. == 1) { + $toplabel = $label; + if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) { + $_ = <>; + redo LINE; # Never referenced, so delete it if not a comment. + } + } + $_ = "$label:"; + if ($lastlinewaslabel++) { + $indent += 4; + print BODY &tab, ";\n"; + $indent -= 4; + } + if ($indent >= 2) { + $indent -= 2; + $indmod = 2; + } + next; + } else { + $lastlinewaslabel = ''; + } + + # Look for one or two address clauses + + $addr1 = ''; + $addr2 = ''; + if (s/^([0-9]+)//) { + $addr1 = "$1"; + $addr1 = "\$. == $addr1" unless /^,/; + } + elsif (s/^\$//) { + $addr1 = 'eof()'; + } + elsif (s|^/||) { + $addr1 = &fetchpat('/'); + } + if (s/^,//) { + if (s/^([0-9]+)//) { + $addr2 = "$1"; + } elsif (s/^\$//) { + $addr2 = "eof()"; + } elsif (s|^/||) { + $addr2 = &fetchpat('/'); + } else { + &Die("Invalid second address at line $.\n"); + } + if ($addr2 =~ /^\d+$/) { + $addr1 .= "..$addr2"; + } + else { + $addr1 .= "...$addr2"; + } + } + + # Now we check for metacommands {, }, and ! and worry + # about indentation. + + s/^[ \t]+//; + # a { to keep vi happy + if ($_ eq '}') { + $indent -= 4; + next; + } + if (s/^!//) { + $if = 'unless'; + $else = "$r else $l\n"; + } else { + $if = 'if'; + $else = ''; + } + if (s/^{//) { # a } to keep vi happy + $indmod = 4; + $redo = $_; + $_ = ''; + $rmaybe = ''; + } else { + $rmaybe = "\n$r"; + if ($addr2 || $addr1) { + $space = ' ' x $shiftwidth; + } else { + $space = ''; + } + $_ = &transmogrify(); + } + + # See if we can optimize to modifier form. + + if ($addr1) { + if ($_ !~ /[\n{}]/ && $rmaybe && !$change && + $_ !~ / if / && $_ !~ / unless /) { + s/;$/ $if $addr1;/; + $_ = substr($_,$shiftwidth,1000); + } else { + $_ = "$if ($addr1) $l\n$change$_$rmaybe"; + } + $change = ''; + next LINE; + } +} continue { + @lines = split(/\n/,$_); + for (@lines) { + unless (s/^ *<<--//) { + print BODY &tab; + } + print BODY $_, "\n"; + } + $indent += $indmod; + $indmod = 0; + if ($redo) { + $_ = $redo; + $redo = ''; + redo LINE; + } +} +if ($lastlinewaslabel++) { + $indent += 4; + print BODY &tab, ";\n"; + $indent -= 4; +} + +if ($appendseen || $tseen || !$assumen) { + $printit++ if $dseen || (!$assumen && !$assumep); + print BODY &q(<<'EOT'); +: #ifdef SAWNEXT +: } +: continue { +: #endif +: #ifdef PRINTIT +: #ifdef DSEEN +: #ifdef ASSUMEP +: print if $printit++; +: #else +: if ($printit) +: { print; } +: else +: { $printit++ unless $nflag; } +: #endif +: #else +: print if $printit; +: #endif +: #else +: print; +: #endif +: #ifdef TSEEN +: $tflag = 0; +: #endif +: #ifdef APPENDSEEN +: if ($atext) { chop $atext; print $atext; $atext = ''; } +: #endif +EOT + +print BODY &q(<<'EOT'); +: } +EOT +} + +close BODY; + +unless ($debug) { + open(HEAD,">/tmp/sperl2$$.c") + || &Die("Can't open temp file 2: $!\n"); + print HEAD "#define PRINTIT\n" if $printit; + print HEAD "#define APPENDSEEN\n" if $appendseen; + print HEAD "#define TSEEN\n" if $tseen; + print HEAD "#define DSEEN\n" if $dseen; + print HEAD "#define ASSUMEN\n" if $assumen; + print HEAD "#define ASSUMEP\n" if $assumep; + print HEAD "#define TOPLABEL\n" if $toplabel; + print HEAD "#define SAWNEXT\n" if $sawnext; + if ($opens) {print HEAD "$opens\n";} + open(BODY,"/tmp/sperl$$") + || &Die("Can't reopen temp file: $!\n"); + while (<BODY>) { + print HEAD $_; + } + close HEAD; + + print &q(<<"EOT"); +: #!$bin/perl +: eval 'exec $bin/perl -S \$0 \${1+"\$@"}' +: if \$running_under_some_shell; +: +EOT + open(BODY,"cc -E /tmp/sperl2$$.c |") || + &Die("Can't reopen temp file: $!\n"); + while (<BODY>) { + /^# [0-9]/ && next; + /^[ \t]*$/ && next; + s/^<><>//; + print; + } +} + +&Cleanup; +exit; + +sub Cleanup { + chdir "/tmp"; + unlink "sperl$$", "sperl2$$", "sperl2$$.c"; +} +sub Die { + &Cleanup; + die $_[0]; +} +sub tab { + "\t" x ($indent / 8) . ' ' x ($indent % 8); +} +sub make_filehandle { + local($_) = $_[0]; + local($fname) = $_; + if (!$seen{$fname}) { + $_ = "FH_" . $_ if /^\d/; + s/[^a-zA-Z0-9]/_/g; + s/^_*//; + $_ = "\U$_"; + if ($fhseen{$_}) { + for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {} + $_ .= $tmp; + } + $fhseen{$_} = 1; + $opens .= &q(<<"EOT"); +: open($_, '>$fname') || die "Can't create $fname: \$!"; +EOT + $seen{$fname} = $_; + } + $seen{$fname}; +} + +sub make_label { + local($label) = @_; + $label =~ s/[^a-zA-Z0-9]/_/g; + if ($label =~ /^[0-9_]/) { $label = 'L' . $label; } + $label = substr($label,0,8); + + # Could be a reserved word, so capitalize it. + substr($label,0,1) =~ y/a-z/A-Z/ + if $label =~ /^[a-z]/; + + $label; +} + +sub transmogrify { + { # case + if (/^d/) { + $dseen++; + chop($_ = &q(<<'EOT')); +: <<--#ifdef PRINTIT +: $printit = 0; +: <<--#endif +: next LINE; +EOT + $sawnext++; + next; + } + + if (/^n/) { + chop($_ = &q(<<'EOT')); +: <<--#ifdef PRINTIT +: <<--#ifdef DSEEN +: <<--#ifdef ASSUMEP +: print if $printit++; +: <<--#else +: if ($printit) +: { print; } +: else +: { $printit++ unless $nflag; } +: <<--#endif +: <<--#else +: print if $printit; +: <<--#endif +: <<--#else +: print; +: <<--#endif +: <<--#ifdef APPENDSEEN +: if ($atext) {chop $atext; print $atext; $atext = '';} +: <<--#endif +: $_ = <>; +: chop; +: <<--#ifdef TSEEN +: $tflag = 0; +: <<--#endif +EOT + next; + } + + if (/^a/) { + $appendseen++; + $command = $space . "\$atext .= <<'End_Of_Text';\n<<--"; + $lastline = 0; + while (<>) { + s/^[ \t]*//; + s/^[\\]//; + unless (s|\\$||) { $lastline = 1;} + s/^([ \t]*\n)/<><>$1/; + $command .= $_; + $command .= '<<--'; + last if $lastline; + } + $_ = $command . "End_Of_Text"; + last; + } + + if (/^[ic]/) { + if (/^c/) { $change = 1; } + $addr1 = 1 if $addr1 eq ''; + $addr1 = '$iter = (' . $addr1 . ')'; + $command = $space . + " if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--"; + $lastline = 0; + while (<>) { + s/^[ \t]*//; + s/^[\\]//; + unless (s/\\$//) { $lastline = 1;} + s/'/\\'/g; + s/^([ \t]*\n)/<><>$1/; + $command .= $_; + $command .= '<<--'; + last if $lastline; + } + $_ = $command . "End_Of_Text"; + if ($change) { + $dseen++; + $change = "$_\n"; + chop($_ = &q(<<"EOT")); +: <<--#ifdef PRINTIT +: $space\$printit = 0; +: <<--#endif +: ${space}next LINE; +EOT + $sawnext++; + } + last; + } + + if (/^s/) { + $delim = substr($_,1,1); + $len = length($_); + $repl = $end = 0; + $inbracket = 0; + for ($i = 2; $i < $len; $i++) { + $c = substr($_,$i,1); + if ($c eq $delim) { + if ($inbracket) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + else { + if ($repl) { + $end = $i; + last; + } else { + $repl = $i; + } + } + } + elsif ($c eq '\\') { + $i++; + if ($i >= $len) { + $_ .= 'n'; + $_ .= <>; + $len = length($_); + $_ = substr($_,0,--$len); + } + elsif (substr($_,$i,1) =~ /^[n]$/) { + ; + } + elsif (!$repl && + substr($_,$i,1) =~ /^[(){}\w]$/) { + $i--; + $len--; + substr($_, $i, 1) = ''; + } + elsif (!$repl && + substr($_,$i,1) =~ /^[<>]$/) { + substr($_,$i,1) = 'b'; + } + elsif ($repl && substr($_,$i,1) =~ /^\d$/) { + substr($_,$i-1,1) = '$'; + } + } + elsif ($c eq '&' && $repl) { + substr($_, $i, 0) = '$'; + $i++; + $len++; + } + elsif ($c eq '$' && $repl) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + elsif ($c eq '[' && !$repl) { + $i++ if substr($_,$i,1) eq '^'; + $i++ if substr($_,$i,1) eq ']'; + $inbracket = 1; + } + elsif ($c eq ']') { + $inbracket = 0; + } + elsif ($c eq "\t") { + substr($_, $i, 1) = '\\t'; + $i++; + $len++; + } + elsif (!$repl && index("()+",$c) >= 0) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + } + &Die("Malformed substitution at line $.\n") + unless $end; + $pat = substr($_, 0, $repl + 1); + $repl = substr($_, $repl+1, $end-$repl-1); + $end = substr($_, $end + 1, 1000); + &simplify($pat); + $dol = '$'; + $subst = "$pat$repl$delim"; + $cmd = ''; + while ($end) { + if ($end =~ s/^g//) { + $subst .= 'g'; + next; + } + if ($end =~ s/^p//) { + $cmd .= ' && (print)'; + next; + } + if ($end =~ s/^w[ \t]*//) { + $fh = &make_filehandle($end); + $cmd .= " && (print $fh \$_)"; + $end = ''; + next; + } + &Die("Unrecognized substitution command". + "($end) at line $.\n"); + } + chop ($_ = &q(<<"EOT")); +: <<--#ifdef TSEEN +: $subst && \$tflag++$cmd; +: <<--#else +: $subst$cmd; +: <<--#endif +EOT + next; + } + + if (/^p/) { + $_ = 'print;'; + next; + } + + if (/^w/) { + s/^w[ \t]*//; + $fh = &make_filehandle($_); + $_ = "print $fh \$_;"; + next; + } + + if (/^r/) { + $appendseen++; + s/^r[ \t]*//; + $file = $_; + $_ = "\$atext .= `cat $file 2>/dev/null`;"; + next; + } + + if (/^P/) { + $_ = 'print $1 if /^(.*)/;'; + next; + } + + if (/^D/) { + chop($_ = &q(<<'EOT')); +: s/^.*\n?//; +: redo LINE if $_; +: next LINE; +EOT + $sawnext++; + next; + } + + if (/^N/) { + chop($_ = &q(<<'EOT')); +: $_ .= "\n"; +: $len1 = length; +: $_ .= <>; +: chop if $len1 < length; +: <<--#ifdef TSEEN +: $tflag = 0; +: <<--#endif +EOT + next; + } + + if (/^h/) { + $_ = '$hold = $_;'; + next; + } + + if (/^H/) { + $_ = '$hold .= "\n"; $hold .= $_;'; + next; + } + + if (/^g/) { + $_ = '$_ = $hold;'; + next; + } + + if (/^G/) { + $_ = '$_ .= "\n"; $_ .= $hold;'; + next; + } + + if (/^x/) { + $_ = '($_, $hold) = ($hold, $_);'; + next; + } + + if (/^b$/) { + $_ = 'next LINE;'; + $sawnext++; + next; + } + + if (/^b/) { + s/^b[ \t]*//; + $lab = &make_label($_); + if ($lab eq $toplabel) { + $_ = 'redo LINE;'; + } else { + $_ = "goto $lab;"; + } + next; + } + + if (/^t$/) { + $_ = 'next LINE if $tflag;'; + $sawnext++; + $tseen++; + next; + } + + if (/^t/) { + s/^t[ \t]*//; + $lab = &make_label($_); + $_ = q/if ($tflag) {$tflag = 0; /; + if ($lab eq $toplabel) { + $_ .= 'redo LINE;}'; + } else { + $_ .= "goto $lab;}"; + } + $tseen++; + next; + } + + if (/^y/) { + s/abcdefghijklmnopqrstuvwxyz/a-z/g; + s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g; + s/abcdef/a-f/g; + s/ABCDEF/A-F/g; + s/0123456789/0-9/g; + s/01234567/0-7/g; + $_ .= ';'; + } + + if (/^=/) { + $_ = 'print $.;'; + next; + } + + if (/^q/) { + chop($_ = &q(<<'EOT')); +: close(ARGV); +: @ARGV = (); +: next LINE; +EOT + $sawnext++; + next; + } + } continue { + if ($space) { + s/^/$space/; + s/(\n)(.)/$1$space$2/g; + } + last; + } + $_; +} + +sub fetchpat { + local($outer) = @_; + local($addr) = $outer; + local($inbracket); + local($prefix,$delim,$ch); + + # Process pattern one potential delimiter at a time. + + DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) { + $prefix = $1; + $delim = $2; + if ($delim eq '\\') { + s/(.)//; + $ch = $1; + $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/; + $ch = 'b' if $ch =~ /^[<>]$/; + $delim .= $ch; + } + elsif ($delim eq '[') { + $inbracket = 1; + s/^\^// && ($delim .= '^'); + s/^]// && ($delim .= ']'); + } + elsif ($delim eq ']') { + $inbracket = 0; + } + elsif ($inbracket || $delim ne $outer) { + $delim = '\\' . $delim; + } + $addr .= $prefix; + $addr .= $delim; + if ($delim eq $outer && !$inbracket) { + last DELIM; + } + } + $addr =~ s/\t/\\t/g; + &simplify($addr); + $addr; +} + +sub q { + local($string) = @_; + local($*) = 1; + $string =~ s/^:\t?//g; + $string; +} + +sub simplify { + $_[0] =~ s/_a-za-z0-9/\\w/ig; + $_[0] =~ s/a-z_a-z0-9/\\w/ig; + $_[0] =~ s/a-za-z_0-9/\\w/ig; + $_[0] =~ s/a-za-z0-9_/\\w/ig; + $_[0] =~ s/_0-9a-za-z/\\w/ig; + $_[0] =~ s/0-9_a-za-z/\\w/ig; + $_[0] =~ s/0-9a-z_a-z/\\w/ig; + $_[0] =~ s/0-9a-za-z_/\\w/ig; + $_[0] =~ s/\[\\w\]/\\w/g; + $_[0] =~ s/\[^\\w\]/\\W/g; + $_[0] =~ s/\[0-9\]/\\d/g; + $_[0] =~ s/\[^0-9\]/\\D/g; + $_[0] =~ s/\\d\\d\*/\\d+/g; + $_[0] =~ s/\\D\\D\*/\\D+/g; + $_[0] =~ s/\\w\\w\*/\\w+/g; + $_[0] =~ s/\\t\\t\*/\\t+/g; + $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g; + $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g; +} + diff --git a/x2p/s2p.SH b/x2p/s2p.SH index 6bb8c51c68..1f892aeb60 100644..100755 --- a/x2p/s2p.SH +++ b/x2p/s2p.SH @@ -33,9 +33,11 @@ eval 'exec $bin/perl -S \$0 \${1+"\$@"}' : In the following dollars and backticks do not need the extra backslash. $spitshell >>s2p <<'!NO!SUBS!' -# $RCSfile: s2p.SH,v $$Revision: 4.0.1.2 $$Date: 92/06/08 17:26:31 $ +# $RCSfile: s2p.SH,v $$Revision: 4.1 $$Date: 92/08/07 18:29:23 $ # # $Log: s2p.SH,v $ +# Revision 4.1 92/08/07 18:29:23 lwall +# # Revision 4.0.1.2 92/06/08 17:26:31 lwall # patch20: s2p didn't output portable startup code # patch20: added ... as variant on .. diff --git a/x2p/s2p.man b/x2p/s2p.man index 6ece802ce1..1374dff928 100644 --- a/x2p/s2p.man +++ b/x2p/s2p.man @@ -1,7 +1,9 @@ .rn '' }` -''' $RCSfile: s2p.man,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:19:57 $ +''' $RCSfile: s2p.man,v $$Revision: 4.1 $$Date: 92/08/07 18:29:24 $ ''' ''' $Log: s2p.man,v $ +''' Revision 4.1 92/08/07 18:29:24 lwall +''' ''' Revision 4.0.1.1 91/06/07 12:19:57 lwall ''' patch4: s2p now handles embedded newlines better and optimizes common idioms ''' @@ -1,4 +1,4 @@ -/* $RCSfile: str.c,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:20:08 $ +/* $RCSfile: str.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:26 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: str.c,v $ + * Revision 4.1 92/08/07 18:29:26 lwall + * * Revision 4.0.1.1 91/06/07 12:20:08 lwall * patch4: new copyright notice * @@ -1,4 +1,4 @@ -/* $RCSfile: str.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:20:22 $ +/* $RCSfile: str.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:27 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: str.h,v $ + * Revision 4.1 92/08/07 18:29:27 lwall + * * Revision 4.0.1.1 91/06/07 12:20:22 lwall * patch4: new copyright notice * diff --git a/x2p/util.c b/x2p/util.c index 7c2485aab1..5fd96f831c 100644 --- a/x2p/util.c +++ b/x2p/util.c @@ -1,4 +1,4 @@ -/* $RCSfile: util.c,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:20:35 $ +/* $RCSfile: util.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:29 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: util.c,v $ + * Revision 4.1 92/08/07 18:29:29 lwall + * * Revision 4.0.1.1 91/06/07 12:20:35 lwall * patch4: new copyright notice * diff --git a/x2p/util.h b/x2p/util.h index e40625171d..b088e4a98a 100644 --- a/x2p/util.h +++ b/x2p/util.h @@ -1,4 +1,4 @@ -/* $RCSfile: util.h,v $$Revision: 4.0.1.2 $$Date: 91/11/05 19:21:20 $ +/* $RCSfile: util.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:30 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: util.h,v $ + * Revision 4.1 92/08/07 18:29:30 lwall + * * Revision 4.0.1.2 91/11/05 19:21:20 lwall * patch11: various portability fixes * diff --git a/x2p/walk.c b/x2p/walk.c index 4e11076b57..55ba719b23 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -1,4 +1,4 @@ -/* $RCSfile: walk.c,v $$Revision: 4.0.1.3 $$Date: 92/06/08 17:33:46 $ +/* $RCSfile: walk.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:31 $ * * Copyright (c) 1991, Larry Wall * @@ -6,6 +6,8 @@ * License or the Artistic License, as specified in the README file. * * $Log: walk.c,v $ + * Revision 4.1 92/08/07 18:29:31 lwall + * * Revision 4.0.1.3 92/06/08 17:33:46 lwall * patch20: in a2p, simplified the filehandle model * patch20: in a2p, made RS="" translate to $/ = "\n\n" |