pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/lang/nawk
Module Name: pkgsrc
Committed By: vins
Date: Fri Feb 24 20:57:50 UTC 2023
Modified Files:
pkgsrc/lang/nawk: Makefile
pkgsrc/lang/nawk/files: FIXES Makefile README README.pkgsrc awk.h
awkgram.y b.c lex.c lib.c main.c maketab.c nawk.1 parse.c proctab.c
proto.h run.c tran.c
Added Files:
pkgsrc/lang/nawk/files: LICENSE awkgram.tab.c awkgram.tab.h
Removed Files:
pkgsrc/lang/nawk/files: awk.1 ytab.c ytab.h
Log Message:
lang/nawk: update to release 20220122.
## CHANGES
2020-07-30 Arnold D. Robbins <arnold%skeeve.com@localhost>
By fiat, we use bison for $(YACC). Trying to accommodate
different versions didn't work.
* makefile: Significant cleanup. Replace all ytab* references
with awkgram.tab.* and simplify definition of YACC.
* .gitignore: Remove ytab* references.
* b.c, lex.c, maketab.c, parse.c, run.c: Replace include of ytab.h
with awkgram.tab.h.
* lib.c, main.c, tran.c: Remove include of ytab.h, wasn't needed.
2020-01-20 Arnold D. Robbins <arnold%skeeve.com@localhost>
* run.c (openfile): Set the close-on-exec flag for file
and pipe redirections that aren't stdin/stdout/stderr.
2020-01-06 Arnold D. Robbins <arnold%skeeve.com@localhost>
Minor fixes.
* b.c (replace_repeat): Turn init_q back into an int.
* lex.c (string): Use \a instead of \007.
* tran.c (catstr): Use snprintf instead of sprintf.
2020-01-01 Arnold D. Robbins <arnold%skeeve.com@localhost>
* tran.c (syminit, arginit, envinit): Free sval member before
setting it. Thanks to valgrind.
* b.c: Small formatting cleanups in several routines.
2019-12-27 Arnold D. Robbins <arnold%skeeve.com@localhost>
* b.c (replace_repeat): Fix a bug whereby a{0,3} could match
four a's. Thanks to Anonymous AWK fan <awkfan77%mailfence.com@localhost>
for the report. Also, minor code formatting cleanups.
* testdir/T.int-expr: New file.
2019-12-11 Arnold D. Robbins <arnold%skeeve.com@localhost>
* README: Renamed to ...
* README.md: ... this. Cleaned up some as well,
including moving to Markdown.
2019-11-08 Arnold D. Robbins <arnold%skeeve.com@localhost>
* test/T.chem: Use $oldawk instead of hardwiring 'awk'.
* test/T.lilly: Remove gawk warnings from output, improves
portability.
2019-10-07 Arnold D. Robbins <arnold%skeeve.com@localhost>
* b.c (fnematch): Change type of pbuf from unsigned char to char.
* proto.h (fnematch): Ditto.
2019-10-06 Arnold D. Robbins <arnold%skeeve.com@localhost>
* lib.c (readrec): Allow RS a regular expression. Imported
the code from the NetBSD awk.
* b.c (fnematch): New function for implementing the feature.
* awk.1: Updated.
* main.c (version): Updated.
2019-06-24 Arnold D. Robbins <arnold%skeeve.com@localhost>
* makefile: Revise to take into account there is no more awktest.tar,
add targets 'check' and 'test', and also 'testclean' to clean up
after test run. Have 'clean' and 'cleaner' depend upon 'testclean'.
2019-06-23 Arnold D. Robbins <arnold%skeeve.com@localhost>
* testdir: Extracted from awktest.tar and added to Git.
* awktest.tar: Removed.
2019-06-06 Arnold D. Robbins <arnold%skeeve.com@localhost>
* awk.1: Fix a typo, minor edits.
2019-06-05 Arnold D. Robbins <arnold%skeeve.com@localhost>
* b.c (relex): Count parentheses and treat umatched right paren
as a literal character.
* awktest.tar (testdir/T.re): Added a test case.
* main.c (version): Updated.
2019-05-29 Arnold D. Robbins <arnold%skeeve.com@localhost>
* lib.c (isclvar): Remove check for additional '=' after
first one. No longer needed.
2019-01-26 Arnold D. Robbins <arnold%skeeve.com@localhost>
* main.c (version): Updated.
2019-01-25 Arnold D. Robbins <arnold%skeeve.com@localhost>
* run.c (awkgetline): Check for numeric value in all getline
variants. See the numeric-getline.* files in bugs-fixed directory.
2018-08-29 Arnold D. Robbins <arnold%skeeve.com@localhost>
* REGRESS: Check for existence of a.out. If not there, run
make. Enable core dumps for T.arnold system status test
to work on MacOS X.
2018-08-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* awktest.tar (testdir/T.expr): Fix test for unary plus.
2018-08-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* REGRESS: Extract tests if necessary, set PATH to include '.'.
* regdir/beebe.tar (Makefile): Fix longwrds test to prefix
sort with LC_ALL=C.
* awktest.tar: Updated from fixed test suite, directory
it extracts is now called 'testdir' to match what's in top-level
REGRESS script.
* regdir: Removed, as Brian wants to keep the test suite in
the tar file.
2018-08-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* FIXES, lib.c, run.c, makefile, main.c: Merge from Brian's tree.
* REGRESS: New file, from Brian.
* awktest.tar: Restored from Brian's tree.
2018-08-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* awkgram.y (UPLUS): New token. In the grammar, call op1()
with it.
* maketab.c (proc): Add entry for UPLUS.
* run.c (arith): Handle UPLUS.
* main.c (version): Updated.
* bugs-fixed/unary-plus.awk, bugs-fixed/unary-plus.bad,
bugs-fixed/unary-plus.ok: New files.
2018-08-10 Arnold D. Robbins <arnold%skeeve.com@localhost>
* TODO: Updated.
* awk.1: Improve use of macros, add some additional explanation
in a few places, alphabetize list of variables.
2018-08-08 Arnold D. Robbins <arnold%skeeve.com@localhost>
* awk.h (Cell): Add new field `fmt' to track xFMT value used
for a string conversion.
[CONVC, CONVO]: New flag macros.
* bugs-fixed/README: Updated.
* bugs-fixed/string-conv.awk, bugs-fixed/string-conv.bad,
bugs-fixed/string-conv.ok: New files.
* main.c (version): Updated.
* proto.h (flags2str): Add declaration.
* tran.c (setfval): Clear CONVC and CONVO flags and set vp->fmt
to NULL.
(setsval): Ditto. Add large comment and new code to manage
correct conversion of number to string based on various flags
and the value of vp->fmt. The idea is to not convert again
if xFMT is the same as before and we're doing the same conversion.
Otherwise, clear the old flags, set the new, and reconvert.
(flags2str): New function. For debug prints and for use from a debugger.
2018-08-05 Arnold D. Robbins <arnold%skeeve.com@localhost>
Fix filename conflicts in regdir where the only difference was
in letter case. This caused problems on Windows systems.
* regdir/Compare.T1: Renamed from regdir/Compare.T.
* regdir/t.delete0: Renamed from regdir/t.delete.
* regdir/t.getline1: Renamed from regdir/t.getline.
* regdir/t.redir1: Renamed from regdir/t.redir.
* regdir/t.split1: Renamed from regdir/t.split.
* regdir/t.sub0: Renamed from regdir/t.sub.
* regdir/REGRESS: Adjusted.
2018-08-04 Arnold D. Robbins <arnold%skeeve.com@localhost>
With scalpel, tweasers, magnifying glass and bated breath,
borrow code from the NetBSD version of nawk to fix the years-old
bug whereby decrementing the value of NF did not change the
record.
* lib.c (fldbld): Set donerec to 1 when done.
(setlastfld): New function.
* proto.h (setlastfld): Add declaration.
* run.c (copycell): Make code smarter about flags (from NetBSD code).
* tran.c (setfree): New function.
* tran.c (setfval): Normalize negative zero to positive zero.
If setting NF, clear donerec and call setlastfld().
(setsval): Remove call to save_old_OFS(). If setting OFS, call
recbld(). If setting NF, clear donerec and call setlastfld().
As part of the process, revert OFS-related changes of 2018-05-22:
* awk.h (saveOFS, saveOFSlen, save_old_OFS): Remove declarations.
* lib.c (recbld): Use *OFS instead of saveOFS.
* run.c (saveOFS, saveOFSlen, save_old_OFS): Remove.
* tran.c (syminit): Remove initialization of saveOFS and saveOFSlen.
General stuff that goes along with all this:
* bugs-fixed/README: Updated.
* bugs-fixed/decr-NF.awk, bugs-fixed/decr-NF.bad,
bugs-fixed/decr-NF.ok: New files.
* main.c (version): Updated.
* regdir/README.TESTS: Fix awk book title.
* regdir/T.misc: Revise test to match fixed code.
* run.c (format): Increase size of buffer used for %a test. (Unrelated
to NF or OFS, but fixes a compiler complaint.)
2018-06-07 Arnold D. Robbins <arnold%skeeve.com@localhost>
* regdir/beebe.tar: Fix longwrds.ok so that the test will pass.
The file was incorrectly sorted.
2018-06-06 Arnold D. Robbins <arnold%skeeve.com@localhost>
* regdir/T.lilly: Fix the bug again in the second instance
of the code. Thanks to BWK for pointing this out.
2018-05-31 Arnold D. Robbins <arnold%skeeve.com@localhost>
* regdir/T.lilly: Fix a syntax error and ordering bug
in creating the 'foo' file.
2018-05-23 Arnold D. Robbins <arnold%skeeve.com@localhost>
* awk.1: Remove standalone 'awk' at the top of file, it messed up
the formatting. Arrange built-in variable list in alphabetical
order.
2018-05-23 Arnold D. Robbins <arnold%skeeve.com@localhost>
* main.c (version): Add my email address and a date so that
users can tell this isn't straight BWK awk.
* README.md: Minor updates.
* TODO: Updated.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
Add POSIX-required formats %a and %A.
* run.c (format): Check for %a support in C library. If there,
allow %a and %A as valid formats.
* TODO: Updated.
* bugs-fixed/README: Updated.
* bugs-fixed/a-format.awk, bugs-fixed/a-format.bad,
bugs-fixed/a-format.ok: New files.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* FIXES: Restored a line from a much earlier version that
apparently got lost when the dates were reordered.
* TODO: Updated.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* README.md: New file.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* regdir/echo.c, regdir/time.c: Minor fixes to compile without
warning on current GCC / Linux.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* TODO: New file.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* makefile (gitadd, gitpush): Remove these targets. They
should not be automated and were incorrect for things that
would be done regularly.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
Fix nawk so that [[:blank:]] only matches space and tab instead
of any whitespace character, originally made May 10, 2018.
See bugs-fixed/space.awk.
This appears to have been a thinko on Brian's part.
* b.c (charclasses): Use xisblank() function for [[:blank:]].
* bugs-fixed/README: Updated.
* bugs-fixed/space.awk, bugs-fixed/space.bad,
bugs-fixed/space.ok: New files.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* .gitignore: New file.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
Fix nawk to provide reasonable exit status for system(),
a la gawk, originally made March 12, 2016. See
bugs-fixed/system-status.awk.
* run.c (bltin): For FSYSTEM, use the macros defined for wait(2)
to produce a reasonable exit value, instead of doing a floating-point
division by 256.
* awk.1: Document the return status values.
* bugs-fixed/README: Updated.
* bugs-fixed/system-status.awk, bugs-fixed/system-status.bad,
bugs-fixed/system-status.ok: New files.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
Bug fix with respect to rebuilding a record, originally
made August 19, 2014. See bugs-fixed/ofs-rebuild.awk.
* awk.h (saveOFS, saveOFSlen): Declare new variables.
* lib.c (recbld): Use them when rebuilding the record.
* run.c (saveOFS, saveOFSlen): Define new variables.
(save_old_OFS): New function to save OFS aside.
* tran.c (syminit): Initialize saveOFS and saveOFSlen.
(setsval): If setting a field, call save_old_OFS().
* bugs-fixed/README, bugs-fixed/ofs-rebuild.awk,
bugs-fixed/ofs-rebuild.bad, bugs-fixed/ofs-rebuild.ok: New files.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* makefile (YACC): Use bison.
2018-05-22 Arnold D. Robbins <arnold%skeeve.com@localhost>
* ChangeLog: Created.
* regdir: Created. Based on contents of awktest.a.
* .gitattributes: Created, to preserve CR LF in regdir/t.crlf.
* awktest.a: Removed.
* regdir/T.gawk, regdir/T.latin1: Updated from awktest.tar.
* awktest.tar: Removed.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 pkgsrc/lang/nawk/Makefile
cvs rdiff -u -r1.2 -r1.3 pkgsrc/lang/nawk/files/FIXES \
pkgsrc/lang/nawk/files/README pkgsrc/lang/nawk/files/awkgram.y \
pkgsrc/lang/nawk/files/lex.c pkgsrc/lang/nawk/files/main.c \
pkgsrc/lang/nawk/files/maketab.c
cvs rdiff -u -r0 -r1.1 pkgsrc/lang/nawk/files/LICENSE \
pkgsrc/lang/nawk/files/awkgram.tab.c pkgsrc/lang/nawk/files/awkgram.tab.h
cvs rdiff -u -r1.3 -r1.4 pkgsrc/lang/nawk/files/Makefile \
pkgsrc/lang/nawk/files/README.pkgsrc pkgsrc/lang/nawk/files/awk.h \
pkgsrc/lang/nawk/files/b.c pkgsrc/lang/nawk/files/proctab.c \
pkgsrc/lang/nawk/files/run.c
cvs rdiff -u -r1.1 -r0 pkgsrc/lang/nawk/files/awk.1
cvs rdiff -u -r1.4 -r1.5 pkgsrc/lang/nawk/files/lib.c \
pkgsrc/lang/nawk/files/proto.h pkgsrc/lang/nawk/files/tran.c
cvs rdiff -u -r1.1 -r1.2 pkgsrc/lang/nawk/files/nawk.1 \
pkgsrc/lang/nawk/files/parse.c
cvs rdiff -u -r1.2 -r0 pkgsrc/lang/nawk/files/ytab.c \
pkgsrc/lang/nawk/files/ytab.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/lang/nawk/Makefile
diff -u pkgsrc/lang/nawk/Makefile:1.43 pkgsrc/lang/nawk/Makefile:1.44
--- pkgsrc/lang/nawk/Makefile:1.43 Sun Jan 26 17:31:30 2020
+++ pkgsrc/lang/nawk/Makefile Fri Feb 24 20:57:50 2023
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.43 2020/01/26 17:31:30 rillig Exp $
+# $NetBSD: Makefile,v 1.44 2023/02/24 20:57:50 vins Exp $
-DISTNAME= nawk-20121220
-PKGREVISION= 1
+DISTNAME= nawk-20220122
CATEGORIES= lang
MASTER_SITES= # empty
DISTFILES= # empty
@@ -9,6 +8,7 @@ DISTFILES= # empty
MAINTAINER= pkgsrc-users%NetBSD.org@localhost
HOMEPAGE= https://www.cs.princeton.edu/~bwk/btl.mirror/
COMMENT= Brian Kernighan's pattern-directed scanning and processing language
+LICENSE= mit
BOOTSTRAP_PKG= yes
@@ -20,7 +20,7 @@ BUILD_TARGET= a.out
INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
do-extract:
- @${CP} -R ${FILESDIR} ${WRKSRC}
+ ${RUN}${CP} -R ${FILESDIR} ${WRKSRC}
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/a.out ${DESTDIR}${PREFIX}/bin/nawk
Index: pkgsrc/lang/nawk/files/FIXES
diff -u pkgsrc/lang/nawk/files/FIXES:1.2 pkgsrc/lang/nawk/files/FIXES:1.3
--- pkgsrc/lang/nawk/files/FIXES:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/FIXES Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-$NetBSD: FIXES,v 1.2 2014/03/12 14:20:43 ryoon Exp $
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -27,6 +25,368 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+December 8, 2021:
+ The error handling in closefile and closeall was mangled. Long
+ standing warnings had been made fatal and some fatal errors went
+ undetected. Thanks to Miguel Pineiro Jr. <mpj%pineiro.cc@localhost>.
+
+Nov 03, 2021:
+ getline accesses uninitialized data after getrec()
+ returns 0 on EOF and leaves the contents of buf unchanged.
+ Thanks to Volodymyr Gubarkov, and Todd C Miller.
+
+Oct 12, 2021:
+ The fix for #83 changed the code to insert 2 chars, but the
+ call to adjbuf just above it only allows for 1 char. This can
+ cause a heap buffer overflow.
+
+July 27, 2021:
+ As per IEEE Std 1003.1-2008, -F "str" is now consistent with
+ -v FS="str" when str is null. Thanks to Warner Losh.
+
+July 24, 2021:
+ Fix readrec's definition of a record. This fixes an issue
+ with NetBSD's RS regular expression support that can cause
+ an infinite read loop. Thanks to Miguel Pineiro Jr.
+
+ Fix regular expression RS ^-anchoring. RS ^-anchoring needs to
+ know if it is reading the first record of a file. This change
+ restores a missing line that was overlooked when porting NetBSD's
+ RS regex functionality. Thanks to Miguel Pineiro Jr.
+
+ Fix size computation in replace_repeat() for special case
+ REPEAT_WITH_Q. Thanks to Todd C. Miller.
+
+February 15, 2021:
+ Small fix so that awk will compile again with g++. Thanks to
+ Arnold Robbins.
+
+January 06, 2021:
+ Fix a decision bug with trailing stuff in lib.c:is_valid_number
+ after recent changes. Thanks to Ozan Yigit.
+
+December 18, 2020:
+ Fix problems converting inf and NaN values in lib.c:is_valid_number.
+ Enhance number to string conversion to do the right thing for
+ NaN and inf values. Things are now pretty much the same as in
+ gawk. (Found a gawk bug while we're at it.) Added a torture
+ test for these values. Thanks to Arnold Robbins. Allows closing
+ of PR #101.
+
+December 15, 2020:
+ Merge PR #99, which gets the right header for strcasecmp.
+ Thanks to GitHub user michaelforney.
+
+December 8, 2020:
+ Merge PR #98: Disallow hex data. Allow only +nan, -nan,
+ +inf, -inf (case independent) to give NaN and infinity values.
+ Improve things so that string to double conversion is only
+ done once, yielding something of a speedup. This obviate
+ PR #95. Thanks to Arnold Robbins.
+
+December 3, 2020:
+ Fix to argument parsing to avoid printing spurious newlines.
+ Thanks to Todd Miller. Merges PR #97.
+
+October 13, 2020:
+ Add casts before all the calls to malloc/calloc/realloc in order
+ to get it to compile with g++. Thanks to Arnold Robbins.
+
+August 16, 2020:
+ Additional fixes for DJGPP. Thanks to Eli Zaretskii for
+ the testing.
+
+August 7, 2020:
+ Merge PR #93, which adds casts to (void*) for debug prints
+ using the %p format specifier. Thanks to GitHub user YongHaoWu
+ ("Chris") for the fixes.
+
+August 4, 2020:
+ In run.c, use non-restartable multibyte routines to attain
+ portability to DJGPP. Should fix Issue 92. Thanks to Albert Wik
+ for the report and to Todd Miller for the suggested fix.
+
+July 30, 2020:
+ Merge PRs 88-91 which fix small bugs. Thanks to Todd Miller and
+ Tim van der Molen for the fixes.
+
+ In order to make life easier, we move exclusively to bison
+ as the parser generator.
+
+July 2, 2020:
+ Merge PRs 85 and 86 which fix regressions. Thanks to
+ Tim van der Molen for the fixes.
+
+June 25, 2020:
+ Merge PRs 82 and 84. The latter fixes issue #83. Thanks to
+ Todd Miller and awkfan77.
+
+June 12, 2020:
+ Clear errno before calling errcheck to avoid any spurious errors
+ left over from previous calls that may have set it. Thanks to
+ Todd Miller for the fix, from PR #80.
+
+ Fix Issue #78 by allowing \r to follow floating point numbers in
+ lib.c:is_number. Thanks to GitHub user ajcarr for the report
+ and to Arnold Robbins for the fix.
+
+June 5, 2020:
+ In fldbld(), make sure that inputFS is set before trying to
+ use it. Thanks to Steffen Nurpmeso <steffen%sdaoden.eu@localhost>
+ for the report.
+
+May 5, 2020:
+ Fix checks for compilers that can handle noreturn. Thanks to
+ GitHub user enh-google for pointing it out. Closes Issue #79.
+
+April 16, 2020:
+ Handle old compilers that don't support C11 (for noreturn).
+ Thanks to Arnold Robbins.
+
+April 5, 2020:
+ Use <stdnoreturn.h> and noreturn instead of GCC attributes.
+ Thanks to GitHub user awkfan77. Closes PR #77.
+
+February 28, 2020:
+ More cleanups from Christos Zoulas: notably backslash continuation
+ inside strings removes the newline and a fix for RS = "^a".
+ Fix for address sanitizer-found problem. Thanks to GitHub user
+ enh-google.
+
+February 19, 2020:
+ More small cleanups from Christos Zoulas.
+
+February 18, 2020:
+ Additional cleanups from Christos Zoulas. It's no longer necessary
+ to use the -y flag to bison.
+
+February 6, 2020:
+ Additional small cleanups from Christos Zoulas. awk is now
+ a little more robust about reporting I/O errors upon exit.
+
+January 31, 2020:
+ Merge PR #70, which avoids use of variable length arrays. Thanks
+ to GitHub user michaelforney. Fix issue #60 ({0} in interval
+ expressions doesn't work). Also get all tests working again.
+ Thanks to Arnold Robbins.
+
+January 24, 2020:
+ A number of small cleanups from Christos Zoulas. Add the close
+ on exec flag to files/pipes opened for redirection; courtesy of
+ Arnold Robbins.
+
+January 19, 2020:
+ If POSIXLY_CORRECT is set in the environment, then sub and gsub
+ use POSIX rules for multiple backslashes. This fixes Issue #66,
+ while maintaining backwards compatibility.
+
+January 9, 2020:
+ Input/output errors on closing files are now fatal instead of
+ mere warnings. Thanks to Martijn Dekker <martijn%inlv.org@localhost>.
+
+January 5, 2020:
+ Fix a bug in the concatentation of two string constants into
+ one done in the grammar. Fixes GitHub issue #61. Thanks
+ to GitHub user awkfan77 for pointing out the direction for
+ the fix. New test T.concat added to the test suite.
+ Fix a few memory leaks reported by valgrind, as well.
+
+December 27, 2019:
+ Fix a bug whereby a{0,3} could match four a's. Thanks to
+ "Anonymous AWK fan" for the report.
+
+December 11, 2019:
+ Further printf-related fixes for 32 bit systems.
+ Thanks again to Christos Zoulas.
+
+December 8, 2019:
+ Fix the return value of sprintf("%d") on 32 bit systems.
+ Thanks to Jim Lowe for the report and to Christos Zoulas
+ for the fix.
+
+November 10, 2019:
+ Convert a number of Boolean integer variables into
+ actual bools. Convert compile_time variable into an
+ enum and simplify some of the related code. Thanks
+ to Arnold Robbins.
+
+November 8, 2019:
+ Fix from Ori Bernstein to get UTF-8 characters instead of
+ bytes when FS = "". This is currently the only bit of
+ the One True Awk that understands multibyte characters.
+ From Arnold Robbins, apply some cleanups in the test suite.
+
+October 25, 2019:
+ More fixes and cleanups from NetBSD, courtesy of Christos
+ Zoulas. Merges PRs 54 and 55.
+
+October 24, 2019:
+ Import second round of code cleanups from NetBSD. Much thanks
+ to Christos Zoulas (GitHub user zoulasc). Merges PR 53.
+ Add an optimization for string concatenation, also from
+ Christos.
+
+October 17, 2019:
+ Import code cleanups from NetBSD. Much thanks to Christos
+ Zoulas (GitHub user zoulasc). Merges PR 51.
+
+October 6, 2019:
+ Import code from NetBSD awk that implements RS as a regular
+ expression.
+
+September 10, 2019:
+ Fixes for various array / memory overruns found via gcc's
+ -fsanitize=unknown. Thanks to Alexander Richardson (GitHub
+ user arichardson). Merges PRs 47 and 48.
+
+July 28, 2019:
+ Import grammar optimization from NetBSD: Two string constants
+ concatenated together get turned into a single string.
+
+July 26, 2019:
+ Support POSIX-specified C-style escape sequences "\a" (alarm)
+ and "\v" (vertical tab) in command line arguments and regular
+ expressions, further to the support for them in strings added on
+ Apr 9, 1989. These now no longer match as literal "a" and "v"
+ characters (as they don't on other awk implementations).
+ Thanks to Martijn Dekker.
+
+July 17, 2019:
+ Pull in a number of code cleanups and minor fixes from
+ Warner Losh's bsd-ota branch. The only user visible change
+ is the use of random(3) as the random number generator.
+ Thanks to Warner Losh for collecting all these fixes in
+ one easy place to get them from.
+
+July 16, 2019:
+ Fix field splitting to use FS value as of the time a record
+ was read or assigned to. Thanks to GitHub user Cody Mello (melloc)
+ for the fix. (Merged from his branch, via PR #42.) Updated
+ testdir/T.split per said PR as well.
+
+June 24, 2019:
+ Extract awktest.tar into testdir directory. Add some very
+ simple mechanics to the makefile for running the tests and
+ for cleaning up. No changes to awk itself.
+
+June 17, 2019:
+ Disallow deleting SYMTAB and its elements, which creates
+ use-after-free bugs. Thanks to GitHub user Cody Mello (melloc)
+ for the fix. (Merged from PR #43.)
+
+June 5, 2019:
+ Allow unmatched right parenthesis in a regular expression to
+ be treated literally. Fixes Issue #40. Thanks to GitHub user
+ Warner Losh (bsdimp) for the report. Thanks to Arnold Robbins
+ for the fix.
+
+May 29,2019:
+ Fix check for command line arguments to no longer require that
+ first character after '=' not be another '='. Reverts change of
+ August 11, 1989. Thanks to GitHub user Jamie Landeg Jones for
+ pointing out the issue; from Issue #38.
+
+Apr 7, 2019:
+ Update awktest.tar(p.50) to use modern options to sort. Needed
+ for Android development. Thanks to GitHub user mohd-akram (Mohamed
+ Akram). From Issue #33.
+
+Mar 12, 2019:
+ Added very simplistic support for cross-compiling in the
+ makefile. We are NOT going to go in the direction of the
+ autotools, though. Thanks to GitHub user nee-san for
+ the basic change. (Merged from PR #34.)
+
+Mar 5, 2019:
+ Added support for POSIX-standard interval expressions (a.k.a.
+ bounds, a.k.a. repetition expressions) in regular expressions,
+ backported (via NetBSD) from Apple awk-24 (20070501).
+ Thanks to Martijn Dekker <martijn%inlv.org@localhost> for the port.
+ (Merged from PR #30.)
+
+Mar 3, 2019:
+ Merge PRs as follows:
+ #12: Avoid undefined behaviour when using ctype(3) functions in
+ relex(). Thanks to GitHub user iamleot.
+ #31: Make getline handle numeric strings, and update FIXES. Thanks
+ to GitHub user arnoldrobbins.
+ #32: maketab: support build systems with read-only source. Thanks
+ to GitHub user enh.
+
+Jan 25, 2019:
+ Make getline handle numeric strings properly in all cases.
+ (Thanks, Arnold.)
+
+Jan 21, 2019:
+ Merged a number of small fixes from GitHub pull requests.
+ Thanks to GitHub users Arnold Robbins (arnoldrobbins),
+ Cody Mello (melloc) and Christoph Junghans (junghans).
+ PR numbers: 13-21, 23, 24, 27.
+
+Oct 25, 2018:
+ Added test in maketab.c to prevent generating a proctab entry
+ for YYSTYPE_IS_DEFINED. It was harmless but some gcc settings
+ generated a warning message. Thanks to Nan Xiao for report.
+
+Aug 27, 2018:
+ Disallow '$' in printf formats; arguments evaluated in order
+ and printed in order.
+
+ Added some casts to silence warnings on debugging printfs.
+ (Thanks, Arnold.)
+
+Aug 23, 2018:
+ A long list of fixes courtesy of Arnold Robbins,
+ to whom profound thanks.
+
+ 1. ofs-rebuild: OFS value used to rebuild the record was incorrect.
+ Fixed August 19, 2014. Revised fix August 2018.
+
+ 2. system-status: Instead of a floating-point division by 256, use
+ the wait(2) macros to create a reasonable exit status.
+ Fixed March 12, 2016.
+
+ 3. space: Use provided xisblank() function instead of ispace() for
+ matching [[:blank:]].
+
+ 4. a-format: Add POSIX standard %a and %A to supported formats. Check
+ at runtime that this format is available.
+
+ 5. decr-NF: Decrementing NF did not change $0. This is a decades-old
+ bug. There are interactions with the old and new value of OFS as well.
+ Most of the fix came from the NetBSD awk.
+
+ 6. string-conv: String conversions of scalars were sticky. Once a
+ conversion to string happened, even with OFMT, that value was used until
+ a new numeric value was assigned, even if OFMT differed from CONVFMT,
+ and also if CONVFMT changed.
+
+ 7. unary-plus: Unary plus on a string constant returned the string.
+ Instead, it should convert the value to numeric and give that value.
+
+ Also added Arnold's tests for these to awktest.tar as T.arnold.
+
+Aug 15, 2018:
+ fixed mangled awktest.tar (thanks, Arnold), posted all
+ current (very minor) fixes to github / onetrueawk
+
+Jun 7, 2018:
+ (yes, a long layoff)
+ Updated some broken tests (beebe.tar, T.lilly)
+ [thanks to Arnold Robbins]
+
+Mar 26, 2015:
+ buffer overflow in error reporting; thanks to tobias ulmer
+ and john-mark gurney for spotting it and the fix.
+
+Feb 4, 2013:
+ cleaned up a handful of tests that didn't seem to actually
+ test for correct behavior: T.latin1, T.gawk.
+
+Jan 5, 2013:
+ added ,NULL initializer to static Cells in run.c; not really
+ needed but cleaner. Thanks to Michael Bombardieri.
+
Dec 20, 2012:
fiddled makefile to get correct yacc and bison flags. pick yacc
(linux) or bison (mac) as necessary.
@@ -54,10 +414,10 @@ Jun 12, 2011:
/pat/, \n /pat/ {...} is now legal, though bad style to use.
added checks to new -v code that permits -vnospace; thanks to
- ruslan ermilov for spotting this and providing the patch.
+ ruslan ermilov for spotting this and providing the patch.
removed fixed limit on number of open files; thanks to aleksey
- cheusov and christos zoulos.
+ cheusov and christos zoulos.
fixed day 1 bug that resurrected deleted elements of ARGV when
used as filenames (in lib.c).
@@ -75,10 +435,10 @@ May 1, 2011:
and arnold robbins, changed srand() to return the previous
seed (which is 1 on the first call of srand). the seed is
an Awkfloat internally though converted to unsigned int to
- pass to the library srand(). thanks, everyone.
+ pass to the library srand(). thanks, everyone.
fixed a subtle (and i hope low-probability) overflow error
- in fldbld, by adding space for one extra \0. thanks to
+ in fldbld, by adding space for one extra \0. thanks to
robert bassett for spotting this one and providing a fix.
removed the files related to compilation on windows. i no
@@ -115,7 +475,7 @@ Oct 8, 2008:
Oct 23, 2007:
minor fix in lib.c: increase inputFS to 100, change malloc
- for fields to n+1.
+ for fields to n+1.
fixed memory fault caused by out of order test in setsval.
@@ -162,7 +522,7 @@ Jan 17, 2006:
core dump on linux with BEGIN {nextfile}, now fixed.
- removed some #ifdef's in run.c and lex.c that appear to no
+ removed some #ifdef's in run.c and lex.c that appear to no
longer be necessary.
Apr 24, 2005:
@@ -176,8 +536,8 @@ Jan 14, 2005:
rethinking it.
Dec 31, 2004:
- prevent overflow of -f array in main, head off potential error in
- call of SYNTAX(), test malloc return in lib.c, all with thanks to
+ prevent overflow of -f array in main, head off potential error in
+ call of SYNTAX(), test malloc return in lib.c, all with thanks to
todd miller.
Dec 22, 2004:
@@ -205,8 +565,8 @@ Nov 22, 2003:
code known to man.
fixed a storage leak in call() that appears to have been there since
- 1983 or so -- a function without an explicit return that assigns a
- string to a parameter leaked a Cell. thanks to moinak ghosh for
+ 1983 or so -- a function without an explicit return that assigns a
+ string to a parameter leaked a Cell. thanks to moinak ghosh for
spotting this very subtle one.
Jul 31, 2003:
@@ -228,7 +588,7 @@ Jul 28, 2003:
radix character in programs and command line arguments regardless of
the locale; otherwise, the locale should prevail for input and output
of numbers. so it's intended to work that way.
-
+
i have rescinded the attempt to use strcoll in expanding shorthands in
regular expressions (cclenter). its properties are much too
surprising; for example [a-c] matches aAbBc in locale en_US but abBcC
@@ -292,7 +652,7 @@ Nov 29, 2002:
Jun 28, 2002:
modified run/format() and tran/getsval() to do a slightly better
job on using OFMT for output from print and CONVFMT for other
- number->string conversions, as promised by posix and done by
+ number->string conversions, as promised by posix and done by
gawk and mawk. there are still places where it doesn't work
right if CONVFMT is changed; by then the STR attribute of the
variable has been irrevocably set. thanks to arnold robbins for
@@ -324,7 +684,7 @@ Feb 10, 2002:
Jan 1, 2002:
fflush() or fflush("") flushes all files and pipes.
- length(arrayname) returns number of elements; thanks to
+ length(arrayname) returns number of elements; thanks to
arnold robbins for suggestion.
added a makefile.win to make it easier to build on windows.
@@ -374,7 +734,7 @@ July 5, 2000:
May 25, 2000:
yet another attempt at making 8-bit input work, with another
- band-aid in b.c (member()), and some (uschar) casts to head
+ band-aid in b.c (member()), and some (uschar) casts to head
off potential errors in subscripts (like isdigit). also
changed HAT to NCHARS-2. thanks again to santiago vila.
@@ -421,7 +781,7 @@ Apr 21, 1999:
the test case.)
Apr 16, 1999:
- with code kindly provided by Bruce Lilly, awk now parses
+ with code kindly provided by Bruce Lilly, awk now parses
/=/ and similar constructs more sensibly in more places.
Bruce also provided some helpful test cases.
@@ -478,7 +838,7 @@ Jan 13, 1999:
Oct 19, 1998:
fixed a couple of bugs in getrec: could fail to update $0
- after a getline var; because inputFS wasn't initialized,
+ after a getline var; because inputFS wasn't initialized,
could split $0 on every character, a misleading diversion.
fixed caching bug in makedfa: LRU was actually removing
@@ -495,6 +855,8 @@ May 12, 1998:
Mar 12, 1998:
added -V to print version number and die.
+[notify dave kerns, dkerns%dacsoup.ih.lucent.com@localhost]
+
Feb 11, 1998:
subtle silent bug in lex.c: if the program ended with a number
longer than 1 digit, part of the input would be pushed back and
@@ -624,7 +986,7 @@ May 2, 1996:
input file. (thanks to arnold robbins for inspiration and code).
small fixes to regexpr code: can now handle []], [[], and
- variants; [] is now a syntax error, rather than matching
+ variants; [] is now a syntax error, rather than matching
everything; [z-a] is now empty, not z. far from complete
or correct, however. (thanks to jeffrey friedl for pointing out
some awful behaviors.)
Index: pkgsrc/lang/nawk/files/README
diff -u pkgsrc/lang/nawk/files/README:1.2 pkgsrc/lang/nawk/files/README:1.3
--- pkgsrc/lang/nawk/files/README:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/README Fri Feb 24 20:57:50 2023
@@ -1,7 +1,12 @@
-$NetBSD: README,v 1.2 2014/03/12 14:20:43 ryoon Exp $
+# The One True Awk
-/****************************************************************
-Copyright (C) Lucent Technologies 1997
+This is the version of `awk` described in _The AWK Programming Language_,
+by Al Aho, Brian Kernighan, and Peter Weinberger
+(Addison-Wesley, 1988, ISBN 0-201-07981-X).
+
+## Copyright
+
+Copyright (C) Lucent Technologies 1997<br/>
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
@@ -22,24 +27,48 @@ WHATSOEVER RESULTING FROM LOSS OF USE, D
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
-****************************************************************/
-This is the version of awk described in "The AWK Programming Language",
-by Al Aho, Brian Kernighan, and Peter Weinberger
-(Addison-Wesley, 1988, ISBN 0-201-07981-X).
+## Distribution and Reporting Problems
Changes, mostly bug fixes and occasional enhancements, are listed
-in FIXES. If you distribute this code further, please please please
-distribute FIXES with it. If you find errors, please report them
-to bwk%cs.princeton.edu@localhost. Thanks.
+in `FIXES`. If you distribute this code further, please please please
+distribute `FIXES` with it.
+
+If you find errors, please report them
+to bwk%cs.princeton.edu@localhost.
+Please _also_ open an issue in the GitHub issue tracker, to make
+it easy to track issues.
+Thanks.
+
+## Submitting Pull Requests
+
+Pull requests are welcome. Some guidelines:
+
+* Please do not use functions or facilities that are not standard (e.g.,
+`strlcpy()`, `fpurge()`).
+
+* Please run the test suite and make sure that your changes pass before
+posting the pull request. To do so:
+
+ 1. Save the previous version of `awk` somewhere in your path. Call it `nawk` (for example).
+ 1. Run `oldawk=nawk make check > check.out 2>&1`.
+ 1. Search for `BAD` or `error` in the result. In general, look over it manually to make sure there are no errors.
+
+* Please create the pull request with a request
+to merge into the `staging` branch instead of into the `master` branch.
+This allows us to do testing, and to make any additional edits or changes
+after the merge but before merging to `master`.
+
+## Building
The program itself is created by
+
make
+
which should produce a sequence of messages roughly like this:
yacc -d awkgram.y
-
-conflicts: 43 shift/reduce, 85 reduce/reduce
+ conflicts: 43 shift/reduce, 85 reduce/reduce
mv y.tab.c ytab.c
mv y.tab.h ytab.h
cc -c ytab.c
@@ -55,42 +84,40 @@ conflicts: 43 shift/reduce, 85 reduce/re
cc -c lex.c
cc ytab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
-This produces an executable a.out; you will eventually want to
-move this to some place like /usr/bin/awk.
+This produces an executable `a.out`; you will eventually want to
+move this to some place like `/usr/bin/awk`.
-If your system does not have yacc or bison (the GNU
-equivalent), you must compile the pieces manually. We have
-included yacc output in ytab.c and ytab.h, and backup copies in
-case you overwrite them. We have also included a copy of
-proctab.c so you do not need to run maketab.
+If your system does not have `yacc` or `bison` (the GNU
+equivalent), you need to install one of them first.
-NOTE: This version uses ANSI C, as you should also. We have
-compiled this without any changes using gcc -Wall and/or local C
+NOTE: This version uses ANSI C (C 99), as you should also. We have
+compiled this without any changes using `gcc -Wall` and/or local C
compilers on a variety of systems, but new systems or compilers
may raise some new complaint; reports of difficulties are
welcome.
-This also compiles with Visual C++ on all flavors of Windows,
-*if* you provide versions of popen and pclose. The file
-missing95.c contains versions that can be used to get started
-with, though the underlying support has mysterious properties,
-the symptom of which can be truncated pipe output. Beware. The
-file makefile.win gives hints on how to proceed; if you run
-vcvars32.bat, it will set up necessary paths and parameters so
-you can subsequently run nmake -f makefile.win. Beware also that
-when running on Windows under command.com, various quoting
-conventions are different from Unix systems: single quotes won't
-work around arguments, and various characters like % are
-interpreted within double quotes.
-
-This compiles without change on Macintosh OS X using gcc and
+This compiles without change on Macintosh OS X using `gcc` and
the standard developer tools.
-This is also said to compile on Macintosh OS 9 systems, using the
-file "buildmac" provided by Dan Allen (danallen%microsoft.com@localhost),
-to whom many thanks.
+You can also use `make CC=g++` to build with the GNU C++ compiler,
+should you choose to do so.
-The version of malloc that comes with some systems is sometimes
-astonishly slow. If awk seems slow, you might try fixing that.
+The version of `malloc` that comes with some systems is sometimes
+astonishly slow. If `awk` seems slow, you might try fixing that.
More generally, turning on optimization can significantly improve
-awk's speed, perhaps by 1/3 for highest levels.
+`awk`'s speed, perhaps by 1/3 for highest levels.
+
+## A Note About Releases
+
+We don't do releases.
+
+## A Note About Maintenance
+
+NOTICE! Maintenance of this program is on a ''best effort''
+basis. We try to get to issues and pull requests as quickly
+as we can. Unfortunately, however, keeping this program going
+is not at the top of our priority list.
+
+#### Last Updated
+
+Sat Jul 25 14:00:07 EDT 2021
Index: pkgsrc/lang/nawk/files/awkgram.y
diff -u pkgsrc/lang/nawk/files/awkgram.y:1.2 pkgsrc/lang/nawk/files/awkgram.y:1.3
--- pkgsrc/lang/nawk/files/awkgram.y:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/awkgram.y Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: awkgram.y,v 1.2 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -34,8 +32,8 @@ int yywrap(void) { return(1); }
Node *beginloc = 0;
Node *endloc = 0;
-int infunc = 0; /* = 1 if in arglist or body of func */
-int inloop = 0; /* = 1 if in while, for, do */
+bool infunc = false; /* = true if in arglist or body of func */
+int inloop = 0; /* >= 1 if in while, for, do; can't be bool, since loops can next */
char *curfname = 0; /* current function name */
Node *arglist = 0; /* list of args for current function */
%}
@@ -52,9 +50,9 @@ Node *arglist = 0; /* list of args for c
%token <i> NL ',' '{' '(' '|' ';' '/' ')' '}' '[' ']'
%token <i> ARRAY
%token <i> MATCH NOTMATCH MATCHOP
-%token <i> FINAL DOT ALL CCL NCCL CHAR OR STAR QUEST PLUS EMPTYRE
+%token <i> FINAL DOT ALL CCL NCCL CHAR OR STAR QUEST PLUS EMPTYRE ZERO
%token <i> AND BOR APPEND EQ GE GT LE LT NE IN
-%token <i> ARG BLTIN BREAK CLOSE CONTINUE DELETE DO EXIT FOR FUNC
+%token <i> ARG BLTIN BREAK CLOSE CONTINUE DELETE DO EXIT FOR FUNC
%token <i> SUB GSUB IF INDEX LSUBSTR MATCHFCN NEXT NEXTFILE
%token <i> ADD MINUS MULT DIVIDE MOD
%token <i> ASSIGN ASGNOP ADDEQ SUBEQ MULTEQ DIVEQ MODEQ POWEQ
@@ -73,6 +71,7 @@ Node *arglist = 0; /* list of args for c
%type <i> do st
%type <i> pst opt_pst lbrace rbrace rparen comma nl opt_nl and bor
%type <i> subop print
+%type <cp> string
%right ASGNOP
%right '?'
@@ -81,14 +80,14 @@ Node *arglist = 0; /* list of args for c
%left AND
%left GETLINE
%nonassoc APPEND EQ GE GT LE LT NE MATCHOP IN '|'
-%left ARG BLTIN BREAK CALL CLOSE CONTINUE DELETE DO EXIT FOR FUNC
+%left ARG BLTIN BREAK CALL CLOSE CONTINUE DELETE DO EXIT FOR FUNC
%left GSUB IF INDEX LSUBSTR MATCHFCN NEXT NUMBER
%left PRINT PRINTF RETURN SPLIT SPRINTF STRING SUB SUBSTR
%left REGEXPR VAR VARNF IVAR WHILE '('
%left CAT
%left '+' '-'
%left '*' '/' '%'
-%left NOT UMINUS
+%left NOT UMINUS UPLUS
%right POWER
%right DECR INCR
%left INDIRECT
@@ -183,8 +182,8 @@ pa_stat:
{ beginloc = linkum(beginloc, $3); $$ = 0; }
| XEND lbrace stmtlist '}'
{ endloc = linkum(endloc, $3); $$ = 0; }
- | FUNC funcname '(' varlist rparen {infunc++;} lbrace stmtlist '}'
- { infunc--; curfname=0; defn((Cell *)$2, $4, $8); $$ = 0; }
+ | FUNC funcname '(' varlist rparen {infunc = true;} lbrace stmtlist '}'
+ { infunc = false; curfname=0; defn((Cell *)$2, $4, $8); $$ = 0; }
;
pa_stats:
@@ -240,10 +239,10 @@ pattern:
$$ = op3($2, (Node *)1, $1, $3); }
| pattern IN varname { $$ = op2(INTEST, $1, makearr($3)); }
| '(' plist ')' IN varname { $$ = op2(INTEST, $2, makearr($5)); }
- | pattern '|' GETLINE var {
+ | pattern '|' GETLINE var {
if (safe) SYNTAX("cmd | getline is unsafe");
else $$ = op3(GETLINE, $4, itonp($2), $1); }
- | pattern '|' GETLINE {
+ | pattern '|' GETLINE {
if (safe) SYNTAX("cmd | getline is unsafe");
else $$ = op3(GETLINE, (Node*)0, itonp($2), $1); }
| pattern term %prec CAT { $$ = op2(CAT, $1, $2); }
@@ -294,7 +293,7 @@ rparen:
;
simple_stmt:
- print prarg '|' term {
+ print prarg '|' term {
if (safe) SYNTAX("print | is unsafe");
else $$ = stat3($1, $2, itonp($3), $4); }
| print prarg APPEND term {
@@ -350,6 +349,11 @@ subop:
SUB | GSUB
;
+string:
+ STRING
+ | string STRING { $$ = catstr($1, $2); }
+ ;
+
term:
term '/' ASGNOP term { $$ = op2(DIVEQ, $1, $4); }
| term '+' term { $$ = op2(ADD, $1, $3); }
@@ -359,7 +363,7 @@ term:
| term '%' term { $$ = op2(MOD, $1, $3); }
| term POWER term { $$ = op2(POWER, $1, $3); }
| '-' term %prec UMINUS { $$ = op1(UMINUS, $2); }
- | '+' term %prec UMINUS { $$ = $2; }
+ | '+' term %prec UMINUS { $$ = op1(UPLUS, $2); }
| NOT term %prec UMINUS { $$ = op1(NOT, notnull($2)); }
| BLTIN '(' ')' { $$ = op2(BLTIN, itonp($1), rectonode()); }
| BLTIN '(' patlist ')' { $$ = op2(BLTIN, itonp($1), $3); }
@@ -396,7 +400,7 @@ term:
| SPLIT '(' pattern comma varname ')'
{ $$ = op4(SPLIT, $3, makearr($5), NIL, (Node*)STRING); } /* default */
| SPRINTF '(' patlist ')' { $$ = op1($1, $3); }
- | STRING { $$ = celltonode($1, CCON); }
+ | string { $$ = celltonode($1, CCON); }
| subop '(' reg_expr comma pattern ')'
{ $$ = op4($1, NIL, (Node*)makedfa($3, 1), $5, rectonode()); }
| subop '(' pattern comma pattern ')'
@@ -423,7 +427,7 @@ var:
| varname '[' patlist ']' { $$ = op2(ARRAY, makearr($1), $3); }
| IVAR { $$ = op1(INDIRECT, celltonode($1, CVAR)); }
| INDIRECT term { $$ = op1(INDIRECT, $2); }
- ;
+ ;
varlist:
/* nothing */ { arglist = $$ = 0; }
Index: pkgsrc/lang/nawk/files/lex.c
diff -u pkgsrc/lang/nawk/files/lex.c:1.2 pkgsrc/lang/nawk/files/lex.c:1.3
--- pkgsrc/lang/nawk/files/lex.c:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/lex.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: lex.c,v 1.2 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -29,10 +27,10 @@ THIS SOFTWARE.
#include <string.h>
#include <ctype.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.tab.h"
extern YYSTYPE yylval;
-extern int infunc;
+extern bool infunc;
int lineno = 1;
int bracecnt = 0;
@@ -45,7 +43,7 @@ typedef struct Keyword {
int type;
} Keyword;
-Keyword keywords[] ={ /* keep sorted: binary searched */
+const Keyword keywords[] = { /* keep sorted: binary searched */
{ "BEGIN", XBEGIN, XBEGIN },
{ "END", XEND, XEND },
{ "NF", VARNF, VARNF },
@@ -93,14 +91,14 @@ Keyword keywords[] ={ /* keep sorted: bi
#define RET(x) { if(dbg)printf("lex %s\n", tokname(x)); return(x); }
-int peek(void)
+static int peek(void)
{
int c = input();
unput(c);
return c;
}
-int gettok(char **pbuf, int *psz) /* get next input token */
+static int gettok(char **pbuf, int *psz) /* get next input token */
{
int c, retc;
char *buf = *pbuf;
@@ -138,7 +136,7 @@ int gettok(char **pbuf, int *psz) /* get
if (bp-buf >= sz)
if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, "gettok"))
FATAL( "out of space for number %.10s...", buf );
- if (isdigit(c) || c == 'e' || c == 'E'
+ if (isdigit(c) || c == 'e' || c == 'E'
|| c == '.' || c == '+' || c == '-')
*bp++ = c;
else {
@@ -150,7 +148,7 @@ int gettok(char **pbuf, int *psz) /* get
strtod(buf, &rem); /* parse the number */
if (rem == buf) { /* it wasn't a valid number at all */
buf[1] = 0; /* return one character as token */
- retc = buf[0]; /* character is its own type */
+ retc = (uschar)buf[0]; /* character is its own type */
unputstr(rem+1); /* put rest back for later */
} else { /* some prefix was a number */
unputstr(rem); /* put rest back for later */
@@ -166,23 +164,23 @@ int gettok(char **pbuf, int *psz) /* get
int word(char *);
int string(void);
int regexpr(void);
-int sc = 0; /* 1 => return a } right now */
-int reg = 0; /* 1 => return a REGEXPR now */
+bool sc = false; /* true => return a } right now */
+bool reg = false; /* true => return a REGEXPR now */
int yylex(void)
{
int c;
- static char *buf = 0;
+ static char *buf = NULL;
static int bufsize = 5; /* BUG: setting this small causes core dump! */
- if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL)
+ if (buf == NULL && (buf = (char *) malloc(bufsize)) == NULL)
FATAL( "out of space in yylex" );
if (sc) {
- sc = 0;
+ sc = false;
RET('}');
}
if (reg) {
- reg = 0;
+ reg = false;
return regexpr();
}
for (;;) {
@@ -192,14 +190,22 @@ int yylex(void)
if (isalpha(c) || c == '_')
return word(buf);
if (isdigit(c)) {
- yylval.cp = setsymtab(buf, tostring(buf), atof(buf), CON|NUM, symtab);
+ char *cp = tostring(buf);
+ double result;
+
+ if (is_number(cp, & result))
+ yylval.cp = setsymtab(buf, cp, result, CON|NUM, symtab);
+ else
+ yylval.cp = setsymtab(buf, cp, 0.0, STR, symtab);
+ free(cp);
/* should this also have STR set? */
RET(NUMBER);
}
-
+
yylval.i = c;
switch (c) {
case '\n': /* {EOL} */
+ lineno++;
RET(NL);
case '\r': /* assume \n is coming */
case ' ': /* {WS}+ */
@@ -209,12 +215,18 @@ int yylex(void)
while ((c = input()) != '\n' && c != 0)
;
unput(c);
+ /*
+ * Next line is a hack, itcompensates for
+ * unput's treatment of \n.
+ */
+ lineno++;
break;
case ';':
RET(';');
case '\\':
if (peek() == '\n') {
input();
+ lineno++;
} else if (peek() == '\r') {
input(); input(); /* \n */
lineno++;
@@ -225,7 +237,7 @@ int yylex(void)
case '&':
if (peek() == '&') {
input(); RET(AND);
- } else
+ } else
RET('&');
case '|':
if (peek() == '|') {
@@ -323,11 +335,11 @@ int yylex(void)
unputstr(buf);
RET(INDIRECT);
}
-
+
case '}':
if (--bracecnt < 0)
SYNTAX( "extra }" );
- sc = 1;
+ sc = true;
RET(';');
case ']':
if (--brackcnt < 0)
@@ -346,10 +358,10 @@ int yylex(void)
case '(':
parencnt++;
RET('(');
-
+
case '"':
return string(); /* BUG: should be like tran.c ? */
-
+
default:
RET(c);
}
@@ -360,10 +372,10 @@ int string(void)
{
int c, n;
char *s, *bp;
- static char *buf = 0;
+ static char *buf = NULL;
static int bufsz = 500;
- if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
+ if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of space for strings");
for (bp = buf; (c = input()) != '"'; ) {
if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, "string"))
@@ -372,22 +384,24 @@ int string(void)
case '\n':
case '\r':
case 0:
+ *bp = '\0';
SYNTAX( "non-terminated string %.10s...", buf );
- lineno++;
if (c == 0) /* hopeless */
FATAL( "giving up" );
+ lineno++;
break;
case '\\':
c = input();
switch (c) {
+ case '\n': break;
case '"': *bp++ = '"'; break;
- case 'n': *bp++ = '\n'; break;
+ case 'n': *bp++ = '\n'; break;
case 't': *bp++ = '\t'; break;
case 'f': *bp++ = '\f'; break;
case 'r': *bp++ = '\r'; break;
case 'b': *bp++ = '\b'; break;
case 'v': *bp++ = '\v'; break;
- case 'a': *bp++ = '\007'; break;
+ case 'a': *bp++ = '\a'; break;
case '\\': *bp++ = '\\'; break;
case '0': case '1': case '2': /* octal: \d \dd \ddd */
@@ -418,7 +432,7 @@ int string(void)
break;
}
- default:
+ default:
*bp++ = c;
break;
}
@@ -428,15 +442,16 @@ int string(void)
break;
}
}
- *bp = 0;
+ *bp = 0;
s = tostring(buf);
- *bp++ = ' '; *bp++ = 0;
+ *bp++ = ' '; *bp++ = '\0';
yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab);
+ free(s);
RET(STRING);
}
-int binsearch(char *w, Keyword *kp, int n)
+static int binsearch(char *w, const Keyword *kp, int n)
{
int cond, low, mid, high;
@@ -454,15 +469,14 @@ int binsearch(char *w, Keyword *kp, int
return -1;
}
-int word(char *w)
+int word(char *w)
{
- Keyword *kp;
+ const Keyword *kp;
int c, n;
n = binsearch(w, keywords, sizeof(keywords)/sizeof(keywords[0]));
-/* BUG: this ought to be inside the if; in theory could fault (daniel barrett) */
- kp = keywords + n;
if (n != -1) { /* found in table */
+ kp = keywords + n;
yylval.i = kp->sub;
switch (kp->type) { /* special handling */
case BLTIN:
@@ -500,28 +514,29 @@ int word(char *w)
void startreg(void) /* next call to yylex will return a regular expression */
{
- reg = 1;
+ reg = true;
}
int regexpr(void)
{
int c;
- static char *buf = 0;
+ static char *buf = NULL;
static int bufsz = 500;
char *bp;
- if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
+ if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of space for rex expr");
bp = buf;
for ( ; (c = input()) != '/' && c != 0; ) {
if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr"))
FATAL("out of space for reg expr %.10s...", buf);
if (c == '\n') {
- SYNTAX( "newline in regular expression %.10s...", buf );
+ *bp = '\0';
+ SYNTAX( "newline in regular expression %.10s...", buf );
unput('\n');
break;
} else if (c == '\\') {
- *bp++ = '\\';
+ *bp++ = '\\';
*bp++ = input();
} else {
*bp++ = c;
@@ -541,7 +556,7 @@ char ebuf[300];
char *ep = ebuf;
char yysbuf[100]; /* pushback buffer */
char *yysptr = yysbuf;
-FILE *yyin = 0;
+FILE *yyin = NULL;
int input(void) /* get next lexical input character */
{
@@ -555,18 +570,20 @@ int input(void) /* get next lexical inpu
lexprog++;
} else /* awk -f ... */
c = pgetc();
- if (c == '\n')
- lineno++;
- else if (c == EOF)
+ if (c == EOF)
c = 0;
if (ep >= ebuf + sizeof ebuf)
ep = ebuf;
- return *ep++ = c;
+ *ep = c;
+ if (c != 0) {
+ ep++;
+ }
+ return (c);
}
void unput(int c) /* put lexical character back on input */
{
- if (c == '\n')
+ if (c == '\n')
lineno--;
if (yysptr >= yysbuf + sizeof(yysbuf))
FATAL("pushed back too much: %.20s...", yysbuf);
Index: pkgsrc/lang/nawk/files/main.c
diff -u pkgsrc/lang/nawk/files/main.c:1.2 pkgsrc/lang/nawk/files/main.c:1.3
--- pkgsrc/lang/nawk/files/main.c:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/main.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: main.c,v 1.2 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -24,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20121220";
+const char *version = "version 20211208";
#define DEBUG
#include <stdio.h>
@@ -34,7 +32,6 @@ const char *version = "version 20121220"
#include <string.h>
#include <signal.h>
#include "awk.h"
-#include "ytab.h"
extern char **environ;
extern int nfields;
@@ -45,44 +42,110 @@ char *cmdname; /* gets argv[0] for error
extern FILE *yyin; /* lex input file */
char *lexprog; /* points to program argument if it exists */
extern int errorflag; /* non-zero if any syntax errors; set by yyerror */
-int compile_time = 2; /* for error printing: */
- /* 2 = cmdline, 1 = compile, 0 = running */
+enum compile_states compile_time = ERROR_PRINTING;
-#define MAX_PFILE 20 /* max number of -f's */
+static char **pfile; /* program filenames from -f's */
+static size_t maxpfile; /* max program filename */
+static size_t npfile; /* number of filenames */
+static size_t curpfile; /* current filename */
+
+bool safe = false; /* true => "safe" mode */
+
+static noreturn void fpecatch(int n
+#ifdef SA_SIGINFO
+ , siginfo_t *si, void *uc
+#endif
+)
+{
+#ifdef SA_SIGINFO
+ static const char *emsg[] = {
+ [0] = "Unknown error",
+ [FPE_INTDIV] = "Integer divide by zero",
+ [FPE_INTOVF] = "Integer overflow",
+ [FPE_FLTDIV] = "Floating point divide by zero",
+ [FPE_FLTOVF] = "Floating point overflow",
+ [FPE_FLTUND] = "Floating point underflow",
+ [FPE_FLTRES] = "Floating point inexact result",
+ [FPE_FLTINV] = "Invalid Floating point operation",
+ [FPE_FLTSUB] = "Subscript out of range",
+ };
+#endif
+ FATAL("floating point exception"
+#ifdef SA_SIGINFO
+ ": %s", (size_t)si->si_code < sizeof(emsg) / sizeof(emsg[0]) &&
+ emsg[si->si_code] ? emsg[si->si_code] : emsg[0]
+#endif
+ );
+}
-char *pfile[MAX_PFILE]; /* program filenames from -f's */
-int npfile = 0; /* number of filenames */
-int curpfile = 0; /* current filename */
+/* Can this work with recursive calls? I don't think so.
+void segvcatch(int n)
+{
+ FATAL("segfault. Do you have an unbounded recursive call?", n);
+}
+*/
+
+static const char *
+setfs(char *p)
+{
+ /* wart: t=>\t */
+ if (p[0] == 't' && p[1] == '\0')
+ return "\t";
+ return p;
+}
-int safe = 0; /* 1 => "safe" mode */
+static char *
+getarg(int *argc, char ***argv, const char *msg)
+{
+ if ((*argv)[1][2] != '\0') { /* arg is -fsomething */
+ return &(*argv)[1][2];
+ } else { /* arg is -f something */
+ (*argc)--; (*argv)++;
+ if (*argc <= 1)
+ FATAL("%s", msg);
+ return (*argv)[1];
+ }
+}
int main(int argc, char *argv[])
{
const char *fs = NULL;
+ char *fn, *vn;
setlocale(LC_CTYPE, "");
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
cmdname = argv[0];
if (argc == 1) {
- fprintf(stderr,
- "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n",
+ fprintf(stderr,
+ "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n",
cmdname);
exit(1);
}
- signal(SIGFPE, fpecatch);
+#ifdef SA_SIGINFO
+ {
+ struct sigaction sa;
+ sa.sa_sigaction = fpecatch;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+ (void)sigaction(SIGFPE, &sa, NULL);
+ }
+#else
+ (void)signal(SIGFPE, fpecatch);
+#endif
+ /*signal(SIGSEGV, segvcatch); experiment */
+ /* Set and keep track of the random seed */
srand_seed = 1;
- srand(srand_seed);
+ srandom((unsigned long) srand_seed);
yyin = NULL;
symtab = makesymtab(NSYMTAB/NSYMTAB);
while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') {
- if (strcmp(argv[1],"-version") == 0 || strcmp(argv[1],"--version") == 0) {
+ if (strcmp(argv[1], "-version") == 0 || strcmp(argv[1], "--version") == 0) {
printf("awk %s\n", version);
- exit(0);
- break;
+ return 0;
}
- if (strncmp(argv[1], "--", 2) == 0) { /* explicit end of args */
+ if (strcmp(argv[1], "--") == 0) { /* explicit end of args */
argc--;
argv++;
break;
@@ -90,53 +153,27 @@ int main(int argc, char *argv[])
switch (argv[1][1]) {
case 's':
if (strcmp(argv[1], "-safe") == 0)
- safe = 1;
+ safe = true;
break;
case 'f': /* next argument is program filename */
- if (argv[1][2] != 0) { /* arg is -fsomething */
- if (npfile >= MAX_PFILE - 1)
- FATAL("too many -f options");
- pfile[npfile++] = &argv[1][2];
- } else { /* arg is -f something */
- argc--; argv++;
- if (argc <= 1)
- FATAL("no program filename");
- if (npfile >= MAX_PFILE - 1)
- FATAL("too many -f options");
- pfile[npfile++] = argv[1];
- }
- break;
+ fn = getarg(&argc, &argv, "no program filename");
+ if (npfile >= maxpfile) {
+ maxpfile += 20;
+ pfile = (char **) realloc(pfile, maxpfile * sizeof(*pfile));
+ if (pfile == NULL)
+ FATAL("error allocating space for -f options");
+ }
+ pfile[npfile++] = fn;
+ break;
case 'F': /* set field separator */
- if (argv[1][2] != 0) { /* arg is -Fsomething */
- if (argv[1][2] == 't' && argv[1][3] == 0) /* wart: t=>\t */
- fs = "\t";
- else if (argv[1][2] != 0)
- fs = &argv[1][2];
- } else { /* arg is -F something */
- argc--; argv++;
- if (argc > 1 && argv[1][0] == 't' && argv[1][1] == 0) /* wart: t=>\t */
- fs = "\t";
- else if (argc > 1 && argv[1][0] != 0)
- fs = &argv[1][0];
- }
- if (fs == NULL || *fs == '\0')
- WARNING("field separator FS is empty");
+ fs = setfs(getarg(&argc, &argv, "no field separator"));
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
- if (argv[1][2] != 0) { /* arg is -vsomething */
- if (isclvar(&argv[1][2]))
- setclvar(&argv[1][2]);
- else
- FATAL("invalid -v option argument: %s", &argv[1][2]);
- } else { /* arg is -v something */
- argc--; argv++;
- if (argc <= 1)
- FATAL("no variable name");
- if (isclvar(argv[1]))
- setclvar(argv[1]);
- else
- FATAL("invalid -v option argument: %s", argv[1]);
- }
+ vn = getarg(&argc, &argv, "no variable name");
+ if (isclvar(vn))
+ setclvar(vn);
+ else
+ FATAL("invalid -v option argument: %s", vn);
break;
case 'd':
dbg = atoi(&argv[1][2]);
@@ -158,26 +195,30 @@ int main(int argc, char *argv[])
exit(0);
FATAL("no program given");
}
- dprintf( ("program = |%s|\n", argv[1]) );
+ DPRINTF("program = |%s|\n", argv[1]);
lexprog = argv[1];
argc--;
argv++;
}
recinit(recsize);
syminit();
- compile_time = 1;
+ compile_time = COMPILING;
argv[0] = cmdname; /* put prog name at front of arglist */
- dprintf( ("argc=%d, argv[0]=%s\n", argc, argv[0]) );
+ DPRINTF("argc=%d, argv[0]=%s\n", argc, argv[0]);
arginit(argc, argv);
if (!safe)
envinit(environ);
yyparse();
+#if 0
+ // Doing this would comply with POSIX, but is not compatible with
+ // other awks and with what most users expect. So comment it out.
setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
+#endif
if (fs)
*FS = qstring(fs, '\0');
- dprintf( ("errorflag=%d\n", errorflag) );
+ DPRINTF("errorflag=%d\n", errorflag);
if (errorflag == 0) {
- compile_time = 0;
+ compile_time = RUNNING;
run(winner);
} else
bracecheck();
@@ -210,7 +251,7 @@ int pgetc(void) /* get 1 character from
char *cursource(void) /* current source file name */
{
if (npfile > 0)
- return pfile[curpfile];
+ return pfile[curpfile < npfile ? curpfile : curpfile - 1];
else
return NULL;
}
Index: pkgsrc/lang/nawk/files/maketab.c
diff -u pkgsrc/lang/nawk/files/maketab.c:1.2 pkgsrc/lang/nawk/files/maketab.c:1.3
--- pkgsrc/lang/nawk/files/maketab.c:1.2 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/maketab.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: maketab.c,v 1.2 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -27,14 +25,14 @@ THIS SOFTWARE.
/*
* this program makes the table to link function names
* and type indices that is used by execute() in run.c.
- * it finds the indices in ytab.h, produced by yacc.
+ * it finds the indices in awkgram.tab.h, produced by bison.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.tab.h"
struct xx
{ int token;
@@ -64,6 +62,7 @@ struct xx
{ DIVIDE, "arith", " / " },
{ MOD, "arith", " % " },
{ UMINUS, "arith", " -" },
+ { UPLUS, "arith", " +" },
{ POWER, "arith", " **" },
{ PREINCR, "incrdecr", "++" },
{ POSTINCR, "incrdecr", "++" },
@@ -119,30 +118,55 @@ int main(int argc, char *argv[])
char c;
FILE *fp;
char buf[200], name[200], def[200];
+ enum { TOK_UNKNOWN, TOK_ENUM, TOK_DEFINE } tokentype = TOK_UNKNOWN;
printf("#include <stdio.h>\n");
printf("#include \"awk.h\"\n");
- printf("#include \"ytab.h\"\n\n");
- for (i = SIZE; --i >= 0; )
- names[i] = "";
+ printf("#include \"awkgram.tab.h\"\n\n");
- if ((fp = fopen("ytab.h", "r")) == NULL) {
- fprintf(stderr, "maketab can't open ytab.h!\n");
+ if (argc != 2) {
+ fprintf(stderr, "usage: maketab YTAB_H\n");
+ exit(1);
+ }
+ if ((fp = fopen(argv[1], "r")) == NULL) {
+ fprintf(stderr, "maketab can't open %s!\n", argv[1]);
exit(1);
}
- printf("static char *printname[%d] = {\n", SIZE);
+ printf("static const char * const printname[%d] = {\n", SIZE);
i = 0;
while (fgets(buf, sizeof buf, fp) != NULL) {
- n = sscanf(buf, "%1c %s %s %d", &c, def, name, &tok);
- if (c != '#' || (n != 4 && strcmp(def,"define") != 0)) /* not a valid #define */
+ // 199 is sizeof(def) - 1
+ if (tokentype != TOK_ENUM) {
+ n = sscanf(buf, "%1c %199s %199s %d", &c, def, name,
+ &tok);
+ if (n == 4 && c == '#' && strcmp(def, "define") == 0) {
+ tokentype = TOK_DEFINE;
+ } else if (tokentype != TOK_UNKNOWN) {
+ continue;
+ }
+ }
+ if (tokentype != TOK_DEFINE) {
+ /* not a valid #define, bison uses enums now */
+ n = sscanf(buf, "%199s = %d,\n", name, &tok);
+ if (n != 2)
+ continue;
+ tokentype = TOK_ENUM;
+ }
+ if (strcmp(name, "YYSTYPE_IS_DECLARED") == 0) {
+ tokentype = TOK_UNKNOWN;
continue;
+ }
if (tok < FIRSTTOKEN || tok > LASTTOKEN) {
+ tokentype = TOK_UNKNOWN;
/* fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf); */
continue;
}
- names[tok-FIRSTTOKEN] = (char *) malloc(strlen(name)+1);
- strcpy(names[tok-FIRSTTOKEN], name);
- printf("\t(char *) \"%s\",\t/* %d */\n", name, tok);
+ names[tok-FIRSTTOKEN] = strdup(name);
+ if (names[tok-FIRSTTOKEN] == NULL) {
+ fprintf(stderr, "maketab out of space copying %s", name);
+ continue;
+ }
+ printf("\t\"%s\",\t/* %d */\n", name, tok);
i++;
}
printf("};\n\n");
@@ -151,20 +175,18 @@ int main(int argc, char *argv[])
table[p->token-FIRSTTOKEN] = p->name;
printf("\nCell *(*proctab[%d])(Node **, int) = {\n", SIZE);
for (i=0; i<SIZE; i++)
- if (table[i]==0)
- printf("\tnullproc,\t/* %s */\n", names[i]);
- else
- printf("\t%s,\t/* %s */\n", table[i], names[i]);
+ printf("\t%s,\t/* %s */\n",
+ table[i] ? table[i] : "nullproc", names[i] ? names[i] : "");
printf("};\n\n");
- printf("char *tokname(int n)\n"); /* print a tokname() function */
+ printf("const char *tokname(int n)\n"); /* print a tokname() function */
printf("{\n");
- printf(" static char buf[100];\n\n");
- printf(" if (n < FIRSTTOKEN || n > LASTTOKEN) {\n");
- printf(" sprintf(buf, \"token %%d\", n);\n");
- printf(" return buf;\n");
- printf(" }\n");
- printf(" return printname[n-FIRSTTOKEN];\n");
+ printf("\tstatic char buf[100];\n\n");
+ printf("\tif (n < FIRSTTOKEN || n > LASTTOKEN) {\n");
+ printf("\t\tsnprintf(buf, sizeof(buf), \"token %%d\", n);\n");
+ printf("\t\treturn buf;\n");
+ printf("\t}\n");
+ printf("\treturn printname[n-FIRSTTOKEN];\n");
printf("}\n");
return 0;
}
Index: pkgsrc/lang/nawk/files/Makefile
diff -u pkgsrc/lang/nawk/files/Makefile:1.3 pkgsrc/lang/nawk/files/Makefile:1.4
--- pkgsrc/lang/nawk/files/Makefile:1.3 Sun May 27 09:55:53 2007
+++ pkgsrc/lang/nawk/files/Makefile Fri Feb 24 20:57:50 2023
@@ -1,41 +1,43 @@
-# $NetBSD: Makefile,v 1.3 2007/05/27 09:55:53 schmonz Exp $
+# $NetBSD: Makefile,v 1.4 2023/02/24 20:57:50 vins Exp $
#
# This file is copied from "makefile.orig" with the following
# modifications for pkgsrc:
#
-# * Some problematic comments lines were stripped.
-# * Use the supplied ytab.[ch] files instead of regenerating them
-# with yacc.
+# * Some problematic comment lines and unnecessary make targets have
+# been stripped.
+# * Use the supplied awkgram.tab.[ch] files instead of regenerating
+# them with yacc.
# * Use the supplied proctab.c file instead of regenerating it
# with maketab.
#
+CFLAGS = -fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls
CFLAGS = -g
-CFLAGS = -O2
CFLAGS =
+CFLAGS = -O2
-CC = gcc -Wall -g -Wwrite-strings
-CC = gcc -fprofile-arcs -ftest-coverage
-CC = gcc -Wall -g
+CC = gcc -g -Wall -pedantic -Wcast-qual
CC = cc
-YACC = bison -y
-YACC = yacc
-YFLAGS = -d
+YACC = yacc -d -b awkgram
+YACC = bison -d
OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
-SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \
- maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c
+SOURCE = awk.h awkgram.tab.c awkgram.tab.h proto.h awkgram.y lex.c b.c main.c \
+ maketab.c parse.c lib.c run.c tran.c proctab.c
LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
- lib.c run.c tran.c missing95.c
+ lib.c run.c tran.c
+
+SHIP = README FIXES $(SOURCE) awkgram.tab.[ch].bak makefile \
+ awk.1
-SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \
- vcvars32.bat buildwin.bat mac.code awk.1
+a.out: awkgram.tab.o $(OFILES)
+ $(CC) $(CFLAGS) awkgram.tab.o $(OFILES) $(ALLOC) -lm -o $@
-a.out: ytab.o $(OFILES)
- $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm -o $@
+maketab: awkgram.tab.h maketab.c
+ $(CC) $(CFLAGS) maketab.c -o maketab
clean:
- rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov # proctab.c
+ rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda
Index: pkgsrc/lang/nawk/files/README.pkgsrc
diff -u pkgsrc/lang/nawk/files/README.pkgsrc:1.3 pkgsrc/lang/nawk/files/README.pkgsrc:1.4
--- pkgsrc/lang/nawk/files/README.pkgsrc:1.3 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/README.pkgsrc Fri Feb 24 20:57:50 2023
@@ -1,4 +1,4 @@
-$NetBSD: README.pkgsrc,v 1.3 2014/03/12 14:20:43 ryoon Exp $
+$NetBSD: README.pkgsrc,v 1.4 2023/02/24 20:57:50 vins Exp $
The following changes were made to the standard distribution:
@@ -8,11 +8,4 @@ The following changes were made to the s
* The file "awk.1" was copied to "nawk.1" and modified. See the
comments at the head of "nawk.1" for a list of the changes.
- * The *.bak files were removed. The were only used to preserve
- the original contents of ytab.[ch] in case they were regenerted
- by yacc/bison.
-
- * The *.bat files were removed. These files are only used on
- MS Windows.
-
* A "NetBSD" CVS Id tag was added to each file.
Index: pkgsrc/lang/nawk/files/awk.h
diff -u pkgsrc/lang/nawk/files/awk.h:1.3 pkgsrc/lang/nawk/files/awk.h:1.4
--- pkgsrc/lang/nawk/files/awk.h:1.3 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/awk.h Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: awk.h,v 1.3 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -25,6 +23,13 @@ THIS SOFTWARE.
****************************************************************/
#include <assert.h>
+#include <stdint.h>
+#include <stdbool.h>
+#if __STDC_VERSION__ <= 199901L
+#define noreturn
+#else
+#include <stdnoreturn.h>
+#endif
typedef double Awkfloat;
@@ -32,24 +37,34 @@ typedef double Awkfloat;
typedef unsigned char uschar;
-#define xfree(a) { if ((a) != NULL) { free((void *) (a)); (a) = NULL; } }
+#define xfree(a) { if ((a) != NULL) { free((void *)(intptr_t)(a)); (a) = NULL; } }
+/*
+ * We sometimes cheat writing read-only pointers to NUL-terminate them
+ * and then put back the original value
+ */
+#define setptr(ptr, a) (*(char *)(intptr_t)(ptr)) = (a)
-#define NN(p) ((p) ? (p) : "(null)") /* guaranteed non-null for dprintf
+#define NN(p) ((p) ? (p) : "(null)") /* guaranteed non-null for DPRINTF
*/
#define DEBUG
#ifdef DEBUG
- /* uses have to be doubly parenthesized */
-# define dprintf(x) if (dbg) printf x
+# define DPRINTF(...) if (dbg) printf(__VA_ARGS__)
#else
-# define dprintf(x)
+# define DPRINTF(...)
#endif
-extern int compile_time; /* 1 if compiling, 0 if running */
-extern int safe; /* 0 => unsafe, 1 => safe */
+extern enum compile_states {
+ RUNNING,
+ COMPILING,
+ ERROR_PRINTING
+} compile_time;
+
+extern bool safe; /* false => unsafe, true => safe */
#define RECSIZE (8 * 1024) /* sets limit on records, fields, etc., etc. */
extern int recsize; /* size of current record, orig RECSIZE */
+extern char EMPTY[]; /* this avoid -Wwritable-strings issues */
extern char **FS;
extern char **RS;
extern char **ORS;
@@ -66,12 +81,11 @@ extern Awkfloat *RLENGTH;
extern char *record; /* points to $0 */
extern int lineno; /* line number in awk program */
extern int errorflag; /* 1 if error has occurred */
-extern int donefld; /* 1 if record broken into fields */
-extern int donerec; /* 1 if record is valid (no fld has changed */
-
+extern bool donefld; /* true if record broken into fields */
+extern bool donerec; /* true if record is valid (no fld has changed */
extern int dbg;
-extern char *patbeg; /* beginning of pattern matched */
+extern const char *patbeg; /* beginning of pattern matched */
extern int patlen; /* length of pattern matched. set in b.c */
/* Cell: all information about a variable or constant */
@@ -82,7 +96,8 @@ typedef struct Cell {
char *nval; /* name, for variables only */
char *sval; /* string value */
Awkfloat fval; /* value as number */
- int tval; /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
+ int tval; /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE|CONVC|CONVO */
+ char *fmt; /* CONVFMT/OFMT value used to convert from number */
struct Cell *cnext; /* ptr to next if chained */
} Cell;
@@ -97,9 +112,15 @@ extern Array *symtab;
extern Cell *nrloc; /* NR */
extern Cell *fnrloc; /* FNR */
+extern Cell *fsloc; /* FS */
extern Cell *nfloc; /* NF */
+extern Cell *ofsloc; /* OFS */
+extern Cell *orsloc; /* ORS */
+extern Cell *rsloc; /* RS */
extern Cell *rstartloc; /* RSTART */
extern Cell *rlengthloc; /* RLENGTH */
+extern Cell *subseploc; /* SUBSEP */
+extern Cell *symtabloc; /* SYMTAB */
/* Cell.tval values: */
#define NUM 01 /* number value is valid */
@@ -110,6 +131,8 @@ extern Cell *rlengthloc; /* RLENGTH */
#define FCN 040 /* this is a function name */
#define FLD 0100 /* this is a field $1, $2, ... */
#define REC 0200 /* this is $0 */
+#define CONVC 0400 /* string was converted from number via CONVFMT */
+#define CONVO 01000 /* string was converted from number via OFMT */
/* function types */
@@ -154,7 +177,7 @@ extern Node *nullnode;
#define CCOPY 6
#define CCON 5
#define CTEMP 4
-#define CNAME 3
+#define CNAME 3
#define CVAR 2
#define CFLD 1
#define CUNK 0
@@ -204,6 +227,7 @@ extern int pairstack[], paircnt;
#define NCHARS (256+3) /* 256 handles 8-bit chars; 128 does 7-bit */
/* watch out in match(), etc. */
+#define HAT (NCHARS+2) /* matches ^ in regular expr */
#define NSTATES 32
typedef struct rrow {
@@ -217,16 +241,16 @@ typedef struct rrow {
} rrow;
typedef struct fa {
- uschar gototab[NSTATES][NCHARS];
- uschar out[NSTATES];
+ unsigned int **gototab;
+ uschar *out;
uschar *restr;
- int *posns[NSTATES];
- int anchor;
+ int **posns;
+ int state_count;
+ bool anchor;
int use;
int initstat;
int curstat;
int accept;
- int reset;
struct rrow re[1]; /* variable: actual size set by calling malloc */
} fa;
Index: pkgsrc/lang/nawk/files/b.c
diff -u pkgsrc/lang/nawk/files/b.c:1.3 pkgsrc/lang/nawk/files/b.c:1.4
--- pkgsrc/lang/nawk/files/b.c:1.3 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/b.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: b.c,v 1.3 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -29,14 +27,13 @@ THIS SOFTWARE.
#define DEBUG
#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.tab.h"
-#define HAT (NCHARS+2) /* matches ^ in regular expr */
- /* NCHARS is 2**n */
#define MAXLIN 22
#define type(v) (v)->nobj /* badly overloaded here */
@@ -64,35 +61,99 @@ int maxsetvec = 0;
int rtok; /* next token in current re */
int rlxval;
-static uschar *rlxstr;
-static uschar *prestr; /* current position in current re */
-static uschar *lastre; /* origin of last re */
+static const uschar *rlxstr;
+static const uschar *prestr; /* current position in current re */
+static const uschar *lastre; /* origin of last re */
+static const uschar *lastatom; /* origin of last Atom */
+static const uschar *starttok;
+static const uschar *basestr; /* starts with original, replaced during
+ repetition processing */
+static const uschar *firstbasestr;
static int setcnt;
static int poscnt;
-char *patbeg;
+const char *patbeg;
int patlen;
-#define NFA 20 /* cache this many dynamic fa's */
+#define NFA 128 /* cache this many dynamic fa's */
fa *fatab[NFA];
int nfatab = 0; /* entries in fatab */
-fa *makedfa(const char *s, int anchor) /* returns dfa for reg expr s */
+static int *
+intalloc(size_t n, const char *f)
+{
+ int *p = (int *) calloc(n, sizeof(int));
+ if (p == NULL)
+ overflo(f);
+ return p;
+}
+
+static void
+resizesetvec(const char *f)
+{
+ if (maxsetvec == 0)
+ maxsetvec = MAXLIN;
+ else
+ maxsetvec *= 4;
+ setvec = (int *) realloc(setvec, maxsetvec * sizeof(*setvec));
+ tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(*tmpset));
+ if (setvec == NULL || tmpset == NULL)
+ overflo(f);
+}
+
+static void
+resize_state(fa *f, int state)
+{
+ unsigned int **p;
+ uschar *p2;
+ int **p3;
+ int i, new_count;
+
+ if (++state < f->state_count)
+ return;
+
+ new_count = state + 10; /* needs to be tuned */
+
+ p = (unsigned int **) realloc(f->gototab, new_count * sizeof(f->gototab[0]));
+ if (p == NULL)
+ goto out;
+ f->gototab = p;
+
+ p2 = (uschar *) realloc(f->out, new_count * sizeof(f->out[0]));
+ if (p2 == NULL)
+ goto out;
+ f->out = p2;
+
+ p3 = (int **) realloc(f->posns, new_count * sizeof(f->posns[0]));
+ if (p3 == NULL)
+ goto out;
+ f->posns = p3;
+
+ for (i = f->state_count; i < new_count; ++i) {
+ f->gototab[i] = (unsigned int *) calloc(NCHARS, sizeof(**f->gototab));
+ if (f->gototab[i] == NULL)
+ goto out;
+ f->out[i] = 0;
+ f->posns[i] = NULL;
+ }
+ f->state_count = new_count;
+ return;
+out:
+ overflo(__func__);
+}
+
+fa *makedfa(const char *s, bool anchor) /* returns dfa for reg expr s */
{
int i, use, nuse;
fa *pfa;
static int now = 1;
- if (setvec == 0) { /* first time through any RE */
- maxsetvec = MAXLIN;
- setvec = (int *) malloc(maxsetvec * sizeof(int));
- tmpset = (int *) malloc(maxsetvec * sizeof(int));
- if (setvec == 0 || tmpset == 0)
- overflo("out of space initializing makedfa");
+ if (setvec == NULL) { /* first time through any RE */
+ resizesetvec(__func__);
}
- if (compile_time) /* a constant for sure */
+ if (compile_time != RUNNING) /* a constant for sure */
return mkdfa(s, anchor);
for (i = 0; i < nfatab; i++) /* is it there already? */
if (fatab[i]->anchor == anchor
@@ -120,12 +181,14 @@ fa *makedfa(const char *s, int anchor) /
return pfa;
}
-fa *mkdfa(const char *s, int anchor) /* does the real work of making a dfa */
- /* anchor = 1 for anchored matches, else 0 */
+fa *mkdfa(const char *s, bool anchor) /* does the real work of making a dfa */
+ /* anchor = true for anchored matches, else false */
{
Node *p, *p1;
fa *f;
+ firstbasestr = (const uschar *) s;
+ basestr = firstbasestr;
p = reparse(s);
p1 = op2(CAT, op2(STAR, op2(ALL, NIL, NIL), NIL), p);
/* put ALL STAR in front of reg. exp. */
@@ -134,44 +197,45 @@ fa *mkdfa(const char *s, int anchor) /*
poscnt = 0;
penter(p1); /* enter parent pointers and leaf indices */
- if ((f = (fa *) calloc(1, sizeof(fa) + poscnt*sizeof(rrow))) == NULL)
- overflo("out of space for fa");
+ if ((f = (fa *) calloc(1, sizeof(fa) + poscnt * sizeof(rrow))) == NULL)
+ overflo(__func__);
f->accept = poscnt-1; /* penter has computed number of positions in re */
cfoll(f, p1); /* set up follow sets */
freetr(p1);
- if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL)
- overflo("out of space in makedfa");
- if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL)
- overflo("out of space in makedfa");
+ resize_state(f, 1);
+ f->posns[0] = intalloc(*(f->re[0].lfollow), __func__);
+ f->posns[1] = intalloc(1, __func__);
*f->posns[1] = 0;
f->initstat = makeinit(f, anchor);
f->anchor = anchor;
f->restr = (uschar *) tostring(s);
+ if (firstbasestr != basestr) {
+ if (basestr)
+ xfree(basestr);
+ }
return f;
}
-int makeinit(fa *f, int anchor)
+int makeinit(fa *f, bool anchor)
{
int i, k;
f->curstat = 2;
f->out[2] = 0;
- f->reset = 0;
k = *(f->re[0].lfollow);
- xfree(f->posns[2]);
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
- overflo("out of space in makeinit");
- for (i=0; i <= k; i++) {
+ xfree(f->posns[2]);
+ f->posns[2] = intalloc(k + 1, __func__);
+ for (i = 0; i <= k; i++) {
(f->posns[2])[i] = (f->re[0].lfollow)[i];
}
if ((f->posns[2])[1] == f->accept)
f->out[2] = 1;
- for (i=0; i < NCHARS; i++)
+ for (i = 0; i < NCHARS; i++)
f->gototab[2][i] = 0;
f->curstat = cgoto(f, 2, HAT);
if (anchor) {
*f->posns[2] = k-1; /* leave out position 0 */
- for (i=0; i < k; i++) {
+ for (i = 0; i < k; i++) {
(f->posns[0])[i] = (f->posns[2])[i];
}
@@ -201,6 +265,8 @@ void penter(Node *p) /* set up parent po
parent(left(p)) = p;
parent(right(p)) = p;
break;
+ case ZERO:
+ break;
default: /* can't happen */
FATAL("can't happen: unknown type %d in penter", type(p));
break;
@@ -215,6 +281,7 @@ void freetr(Node *p) /* free parse tree
xfree(p);
break;
UNARY
+ case ZERO:
freetr(left(p));
xfree(p);
break;
@@ -233,13 +300,13 @@ void freetr(Node *p) /* free parse tree
/* in the parsing of regular expressions, metacharacters like . have */
/* to be seen literally; \056 is not a metacharacter. */
-int hexstr(uschar **pp) /* find and eval hex string at pp, return new p */
+int hexstr(const uschar **pp) /* find and eval hex string at pp, return new p */
{ /* only pick up one 8-bit byte (2 chars) */
- uschar *p;
+ const uschar *p;
int n = 0;
int i;
- for (i = 0, p = (uschar *) *pp; i < 2 && isxdigit(*p); i++, p++) {
+ for (i = 0, p = *pp; i < 2 && isxdigit(*p); i++, p++) {
if (isdigit(*p))
n = 16 * n + *p - '0';
else if (*p >= 'a' && *p <= 'f')
@@ -247,16 +314,16 @@ int hexstr(uschar **pp) /* find and eval
else if (*p >= 'A' && *p <= 'F')
n = 16 * n + *p - 'A' + 10;
}
- *pp = (uschar *) p;
+ *pp = p;
return n;
}
#define isoctdigit(c) ((c) >= '0' && (c) <= '7') /* multiple use of arg */
-int quoted(uschar **pp) /* pick up next thing after a \\ */
+int quoted(const uschar **pp) /* pick up next thing after a \\ */
/* and increment *pp */
{
- uschar *p = *pp;
+ const uschar *p = *pp;
int c;
if ((c = *p++) == 't')
@@ -269,6 +336,10 @@ int quoted(uschar **pp) /* pick up next
c = '\r';
else if (c == 'b')
c = '\b';
+ else if (c == 'v')
+ c = '\v';
+ else if (c == 'a')
+ c = '\a';
else if (c == '\\')
c = '\\';
else if (c == 'x') { /* hexadecimal goo follows */
@@ -290,13 +361,13 @@ int quoted(uschar **pp) /* pick up next
char *cclenter(const char *argp) /* add a character class */
{
int i, c, c2;
- uschar *p = (uschar *) argp;
- uschar *op, *bp;
- static uschar *buf = 0;
+ const uschar *op, *p = (const uschar *) argp;
+ uschar *bp;
+ static uschar *buf = NULL;
static int bufsz = 100;
op = p;
- if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
+ if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL)
FATAL("out of space for character class [%.10s...] 1", p);
bp = buf;
for (i = 0; (c = *p++) != 0; ) {
@@ -328,14 +399,14 @@ char *cclenter(const char *argp) /* add
i++;
}
*bp = 0;
- dprintf( ("cclenter: in = |%s|, out = |%s|\n", op, buf) );
+ DPRINTF("cclenter: in = |%s|, out = |%s|\n", op, buf);
xfree(op);
return (char *) tostring((char *) buf);
}
void overflo(const char *s)
{
- FATAL("regular expression too big: %.30s...", s);
+ FATAL("regular expression too big: out of space in %.30s...", s);
}
void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfollow[leaf] */
@@ -349,18 +420,13 @@ void cfoll(fa *f, Node *v) /* enter foll
f->re[info(v)].ltype = type(v);
f->re[info(v)].lval.np = right(v);
while (f->accept >= maxsetvec) { /* guessing here! */
- maxsetvec *= 4;
- setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
- tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
- if (setvec == 0 || tmpset == 0)
- overflo("out of space in cfoll()");
+ resizesetvec(__func__);
}
for (i = 0; i <= f->accept; i++)
setvec[i] = 0;
setcnt = 0;
follow(v); /* computes setvec and setcnt */
- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL)
- overflo("out of space building follow set");
+ p = intalloc(setcnt + 1, __func__);
f->re[info(v)].lfollow = p;
*p = setcnt;
for (i = f->accept; i >= 0; i--)
@@ -375,6 +441,8 @@ void cfoll(fa *f, Node *v) /* enter foll
cfoll(f,left(v));
cfoll(f,right(v));
break;
+ case ZERO:
+ break;
default: /* can't happen */
FATAL("can't happen: unknown type %d in cfoll", type(v));
}
@@ -390,11 +458,7 @@ int first(Node *p) /* collects initially
LEAF
lp = info(p); /* look for high-water mark of subscripts */
while (setcnt >= maxsetvec || lp >= maxsetvec) { /* guessing here! */
- maxsetvec *= 4;
- setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
- tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
- if (setvec == 0 || tmpset == 0)
- overflo("out of space in first()");
+ resizesetvec(__func__);
}
if (type(p) == EMPTYRE) {
setvec[lp] = 0;
@@ -406,9 +470,10 @@ int first(Node *p) /* collects initially
}
if (type(p) == CCL && (*(char *) right(p)) == '\0')
return(0); /* empty CCL */
- else return(1);
+ return(1);
case PLUS:
- if (first(left(p)) == 0) return(0);
+ if (first(left(p)) == 0)
+ return(0);
return(1);
case STAR:
case QUEST:
@@ -421,6 +486,8 @@ int first(Node *p) /* collects initially
b = first(right(p));
if (first(left(p)) == 0 || b == 0) return(0);
return(1);
+ case ZERO:
+ return 0;
}
FATAL("can't happen: unknown type %d in first", type(p)); /* can't happen */
return(-1);
@@ -459,7 +526,7 @@ void follow(Node *v) /* collects leaves
int member(int c, const char *sarg) /* is c in s? */
{
- uschar *s = (uschar *) sarg;
+ const uschar *s = (const uschar *) sarg;
while (*s)
if (c == *s++)
@@ -470,9 +537,11 @@ int member(int c, const char *sarg) /* i
int match(fa *f, const char *p0) /* shortest match ? */
{
int s, ns;
- uschar *p = (uschar *) p0;
+ const uschar *p = (const uschar *) p0;
+
+ s = f->initstat;
+ assert (s < f->state_count);
- s = f->reset ? makeinit(f,0) : f->initstat;
if (f->out[s])
return(1);
do {
@@ -490,17 +559,13 @@ int match(fa *f, const char *p0) /* shor
int pmatch(fa *f, const char *p0) /* longest match, for sub */
{
int s, ns;
- uschar *p = (uschar *) p0;
- uschar *q;
- int i, k;
+ const uschar *p = (const uschar *) p0;
+ const uschar *q;
- /* s = f->reset ? makeinit(f,1) : f->initstat; */
- if (f->reset) {
- f->initstat = s = makeinit(f,1);
- } else {
- s = f->initstat;
- }
- patbeg = (char *) p;
+ s = f->initstat;
+ assert(s < f->state_count);
+
+ patbeg = (const char *)p;
patlen = -1;
do {
q = p;
@@ -512,9 +577,12 @@ int pmatch(fa *f, const char *p0) /* lon
s = ns;
else
s = cgoto(f, s, *q);
+
+ assert(s < f->state_count);
+
if (s == 1) { /* no transition */
if (patlen >= 0) {
- patbeg = (char *) p;
+ patbeg = (const char *) p;
return(1);
}
else
@@ -524,41 +592,25 @@ int pmatch(fa *f, const char *p0) /* lon
if (f->out[s])
patlen = q-p-1; /* don't count $ */
if (patlen >= 0) {
- patbeg = (char *) p;
+ patbeg = (const char *) p;
return(1);
}
nextin:
s = 2;
- if (f->reset) {
- for (i = 2; i <= f->curstat; i++)
- xfree(f->posns[i]);
- k = *f->posns[0];
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
- overflo("out of space in pmatch");
- for (i = 0; i <= k; i++)
- (f->posns[2])[i] = (f->posns[0])[i];
- f->initstat = f->curstat = 2;
- f->out[2] = f->out[0];
- for (i = 0; i < NCHARS; i++)
- f->gototab[2][i] = 0;
- }
- } while (*p++ != 0);
+ } while (*p++);
return (0);
}
int nematch(fa *f, const char *p0) /* non-empty match, for sub */
{
int s, ns;
- uschar *p = (uschar *) p0;
- uschar *q;
- int i, k;
+ const uschar *p = (const uschar *) p0;
+ const uschar *q;
- /* s = f->reset ? makeinit(f,1) : f->initstat; */
- if (f->reset) {
- f->initstat = s = makeinit(f,1);
- } else {
- s = f->initstat;
- }
+ s = f->initstat;
+ assert(s < f->state_count);
+
+ patbeg = (const char *)p;
patlen = -1;
while (*p) {
q = p;
@@ -572,7 +624,7 @@ int nematch(fa *f, const char *p0) /* no
s = cgoto(f, s, *q);
if (s == 1) { /* no transition */
if (patlen > 0) {
- patbeg = (char *) p;
+ patbeg = (const char *) p;
return(1);
} else
goto nnextin; /* no nonempty match */
@@ -581,35 +633,110 @@ int nematch(fa *f, const char *p0) /* no
if (f->out[s])
patlen = q-p-1; /* don't count $ */
if (patlen > 0 ) {
- patbeg = (char *) p;
+ patbeg = (const char *) p;
return(1);
}
nnextin:
s = 2;
- if (f->reset) {
- for (i = 2; i <= f->curstat; i++)
- xfree(f->posns[i]);
- k = *f->posns[0];
- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL)
- overflo("out of state space");
- for (i = 0; i <= k; i++)
- (f->posns[2])[i] = (f->posns[0])[i];
- f->initstat = f->curstat = 2;
- f->out[2] = f->out[0];
- for (i = 0; i < NCHARS; i++)
- f->gototab[2][i] = 0;
- }
p++;
}
return (0);
}
+
+/*
+ * NAME
+ * fnematch
+ *
+ * DESCRIPTION
+ * A stream-fed version of nematch which transfers characters to a
+ * null-terminated buffer. All characters up to and including the last
+ * character of the matching text or EOF are placed in the buffer. If
+ * a match is found, patbeg and patlen are set appropriately.
+ *
+ * RETURN VALUES
+ * false No match found.
+ * true Match found.
+ */
+
+bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
+{
+ char *buf = *pbuf;
+ int bufsize = *pbufsize;
+ int c, i, j, k, ns, s;
+
+ s = pfa->initstat;
+ patlen = 0;
+
+ /*
+ * All indices relative to buf.
+ * i <= j <= k <= bufsize
+ *
+ * i: origin of active substring
+ * j: current character
+ * k: destination of next getc()
+ */
+ i = -1, k = 0;
+ do {
+ j = i++;
+ do {
+ if (++j == k) {
+ if (k == bufsize)
+ if (!adjbuf((char **) &buf, &bufsize, bufsize+1, quantum, 0, "fnematch"))
+ FATAL("stream '%.30s...' too long", buf);
+ buf[k++] = (c = getc(f)) != EOF ? c : 0;
+ }
+ c = (uschar)buf[j];
+ /* assert(c < NCHARS); */
+
+ if ((ns = pfa->gototab[s][c]) != 0)
+ s = ns;
+ else
+ s = cgoto(pfa, s, c);
+
+ if (pfa->out[s]) { /* final state */
+ patlen = j - i + 1;
+ if (c == 0) /* don't count $ */
+ patlen--;
+ }
+ } while (buf[j] && s != 1);
+ s = 2;
+ } while (buf[i] && !patlen);
+
+ /* adjbuf() may have relocated a resized buffer. Inform the world. */
+ *pbuf = buf;
+ *pbufsize = bufsize;
+
+ if (patlen) {
+ patbeg = (char *) buf + i;
+ /*
+ * Under no circumstances is the last character fed to
+ * the automaton part of the match. It is EOF's nullbyte,
+ * or it sent the automaton into a state with no further
+ * transitions available (s==1), or both. Room for a
+ * terminating nullbyte is guaranteed.
+ *
+ * ungetc any chars after the end of matching text
+ * (except for EOF's nullbyte, if present) and null
+ * terminate the buffer.
+ */
+ do
+ if (buf[--k] && ungetc(buf[k], f) == EOF)
+ FATAL("unable to ungetc '%c'", buf[k]);
+ while (k > i + patlen);
+ buf[k] = '\0';
+ return true;
+ }
+ else
+ return false;
+}
+
Node *reparse(const char *p) /* parses regular expression pointed to by p */
{ /* uses relex() to scan regular expression */
Node *np;
- dprintf( ("reparse <%s>\n", p) );
- lastre = prestr = (uschar *) p; /* prestr points to string to be parsed */
+ DPRINTF("reparse <%s>\n", p);
+ lastre = prestr = (const uschar *) p; /* prestr points to string to be parsed */
rtok = relex();
/* GNU compatibility: an empty regexp matches anything */
if (rtok == '\0') {
@@ -630,9 +757,11 @@ Node *regexp(void) /* top-level parse of
Node *primary(void)
{
Node *np;
+ int savelastatom;
switch (rtok) {
case CHAR:
+ lastatom = starttok;
np = op2(CHAR, NIL, itonp(rlxval));
rtok = relex();
return (unary(np));
@@ -641,16 +770,19 @@ Node *primary(void)
return (unary(op2(ALL, NIL, NIL)));
case EMPTYRE:
rtok = relex();
- return (unary(op2(ALL, NIL, NIL)));
+ return (unary(op2(EMPTYRE, NIL, NIL)));
case DOT:
+ lastatom = starttok;
rtok = relex();
return (unary(op2(DOT, NIL, NIL)));
case CCL:
- np = op2(CCL, NIL, (Node*) cclenter((char *) rlxstr));
+ np = op2(CCL, NIL, (Node*) cclenter((const char *) rlxstr));
+ lastatom = starttok;
rtok = relex();
return (unary(np));
case NCCL:
- np = op2(NCCL, NIL, (Node *) cclenter((char *) rlxstr));
+ np = op2(NCCL, NIL, (Node *) cclenter((const char *) rlxstr));
+ lastatom = starttok;
rtok = relex();
return (unary(np));
case '^':
@@ -660,6 +792,8 @@ Node *primary(void)
rtok = relex();
return (unary(op2(CHAR, NIL, NIL)));
case '(':
+ lastatom = starttok;
+ savelastatom = starttok - basestr; /* Retain over recursion */
rtok = relex();
if (rtok == ')') { /* special pleading for () */
rtok = relex();
@@ -667,6 +801,7 @@ Node *primary(void)
}
np = regexp();
if (rtok == ')') {
+ lastatom = basestr + savelastatom; /* Restore */
rtok = relex();
return (unary(np));
}
@@ -681,8 +816,12 @@ Node *primary(void)
Node *concat(Node *np)
{
switch (rtok) {
- case CHAR: case DOT: case ALL: case EMPTYRE: case CCL: case NCCL: case '$': case '(':
+ case CHAR: case DOT: case ALL: case CCL: case NCCL: case '$': case '(':
return (concat(op2(CAT, np, primary())));
+ case EMPTYRE:
+ rtok = relex();
+ return (concat(op2(CAT, op2(CCL, NIL, (Node *) tostring("")),
+ primary())));
}
return (np);
}
@@ -708,6 +847,9 @@ Node *unary(Node *np)
case QUEST:
rtok = relex();
return (unary(op2(QUEST, np, NIL)));
+ case ZERO:
+ rtok = relex();
+ return (unary(op2(ZERO, np, NIL)));
default:
return (np);
}
@@ -733,7 +875,8 @@ Node *unary(Node *np)
* to nelson beebe for the suggestion; let's see if it works everywhere.
*/
-#if !defined(HAS_ISBLANK) && !defined(__APPLE__)
+/* #define HAS_ISBLANK */
+#ifndef HAS_ISBLANK
int (xisblank)(int c)
{
@@ -742,7 +885,7 @@ int (xisblank)(int c)
#endif
-struct charclass {
+static const struct charclass {
const char *cc_name;
int cc_namelen;
int (*cc_func)(int);
@@ -750,7 +893,7 @@ struct charclass {
{ "alnum", 5, isalnum },
{ "alpha", 5, isalpha },
#ifndef HAS_ISBLANK
- { "blank", 5, isspace }, /* was isblank */
+ { "blank", 5, xisblank },
#else
{ "blank", 5, isblank },
#endif
@@ -766,16 +909,132 @@ struct charclass {
{ NULL, 0, NULL },
};
+#define REPEAT_SIMPLE 0
+#define REPEAT_PLUS_APPENDED 1
+#define REPEAT_WITH_Q 2
+#define REPEAT_ZERO 3
+
+static int
+replace_repeat(const uschar *reptok, int reptoklen, const uschar *atom,
+ int atomlen, int firstnum, int secondnum, int special_case)
+{
+ int i, j;
+ uschar *buf = 0;
+ int ret = 1;
+ int init_q = (firstnum == 0); /* first added char will be ? */
+ int n_q_reps = secondnum-firstnum; /* m>n, so reduce until {1,m-n} left */
+ int prefix_length = reptok - basestr; /* prefix includes first rep */
+ int suffix_length = strlen((const char *) reptok) - reptoklen; /* string after rep specifier */
+ int size = prefix_length + suffix_length;
+
+ if (firstnum > 1) { /* add room for reps 2 through firstnum */
+ size += atomlen*(firstnum-1);
+ }
+
+ /* Adjust size of buffer for special cases */
+ if (special_case == REPEAT_PLUS_APPENDED) {
+ size++; /* for the final + */
+ } else if (special_case == REPEAT_WITH_Q) {
+ size += init_q + (atomlen+1)* (n_q_reps-init_q);
+ } else if (special_case == REPEAT_ZERO) {
+ size += 2; /* just a null ERE: () */
+ }
+ if ((buf = (uschar *) malloc(size + 1)) == NULL)
+ FATAL("out of space in reg expr %.10s..", lastre);
+ memcpy(buf, basestr, prefix_length); /* copy prefix */
+ j = prefix_length;
+ if (special_case == REPEAT_ZERO) {
+ j -= atomlen;
+ buf[j++] = '(';
+ buf[j++] = ')';
+ }
+ for (i = 1; i < firstnum; i++) { /* copy x reps */
+ memcpy(&buf[j], atom, atomlen);
+ j += atomlen;
+ }
+ if (special_case == REPEAT_PLUS_APPENDED) {
+ buf[j++] = '+';
+ } else if (special_case == REPEAT_WITH_Q) {
+ if (init_q)
+ buf[j++] = '?';
+ for (i = init_q; i < n_q_reps; i++) { /* copy x? reps */
+ memcpy(&buf[j], atom, atomlen);
+ j += atomlen;
+ buf[j++] = '?';
+ }
+ }
+ memcpy(&buf[j], reptok+reptoklen, suffix_length);
+ j += suffix_length;
+ buf[j] = '\0';
+ /* free old basestr */
+ if (firstbasestr != basestr) {
+ if (basestr)
+ xfree(basestr);
+ }
+ basestr = buf;
+ prestr = buf + prefix_length;
+ if (special_case == REPEAT_ZERO) {
+ prestr -= atomlen;
+ ret++;
+ }
+ return ret;
+}
+
+static int repeat(const uschar *reptok, int reptoklen, const uschar *atom,
+ int atomlen, int firstnum, int secondnum)
+{
+ /*
+ In general, the repetition specifier or "bound" is replaced here
+ by an equivalent ERE string, repeating the immediately previous atom
+ and appending ? and + as needed. Note that the first copy of the
+ atom is left in place, except in the special_case of a zero-repeat
+ (i.e., {0}).
+ */
+ if (secondnum < 0) { /* means {n,} -> repeat n-1 times followed by PLUS */
+ if (firstnum < 2) {
+ /* 0 or 1: should be handled before you get here */
+ FATAL("internal error");
+ } else {
+ return replace_repeat(reptok, reptoklen, atom, atomlen,
+ firstnum, secondnum, REPEAT_PLUS_APPENDED);
+ }
+ } else if (firstnum == secondnum) { /* {n} or {n,n} -> simply repeat n-1 times */
+ if (firstnum == 0) { /* {0} or {0,0} */
+ /* This case is unusual because the resulting
+ replacement string might actually be SMALLER than
+ the original ERE */
+ return replace_repeat(reptok, reptoklen, atom, atomlen,
+ firstnum, secondnum, REPEAT_ZERO);
+ } else { /* (firstnum >= 1) */
+ return replace_repeat(reptok, reptoklen, atom, atomlen,
+ firstnum, secondnum, REPEAT_SIMPLE);
+ }
+ } else if (firstnum < secondnum) { /* {n,m} -> repeat n-1 times then alternate */
+ /* x{n,m} => xx...x{1, m-n+1} => xx...x?x?x?..x? */
+ return replace_repeat(reptok, reptoklen, atom, atomlen,
+ firstnum, secondnum, REPEAT_WITH_Q);
+ } else { /* Error - shouldn't be here (n>m) */
+ FATAL("internal error");
+ }
+ return 0;
+}
int relex(void) /* lexical analyzer for reparse */
{
int c, n;
int cflag;
- static uschar *buf = 0;
+ static uschar *buf = NULL;
static int bufsz = 100;
uschar *bp;
- struct charclass *cc;
+ const struct charclass *cc;
int i;
+ int num, m;
+ bool commafound, digitfound;
+ const uschar *startreptok;
+ static int parens = 0;
+
+rescan:
+ starttok = prestr;
switch (c = *prestr++) {
case '|': return OR;
@@ -786,17 +1045,26 @@ int relex(void) /* lexical analyzer for
case '\0': prestr--; return '\0';
case '^':
case '$':
+ return c;
case '(':
- case ')':
+ parens++;
return c;
+ case ')':
+ if (parens) {
+ parens--;
+ return c;
+ }
+ /* unmatched close parenthesis; per POSIX, treat as literal */
+ rlxval = c;
+ return CHAR;
case '\\':
rlxval = quoted(&prestr);
return CHAR;
default:
rlxval = c;
return CHAR;
- case '[':
- if (buf == 0 && (buf = (uschar *) malloc(bufsz)) == NULL)
+ case '[':
+ if (buf == NULL && (buf = (uschar *) malloc(bufsz)) == NULL)
FATAL("out of space in reg expr %.10s..", lastre);
bp = buf;
if (*prestr == '^') {
@@ -824,16 +1092,64 @@ int relex(void) /* lexical analyzer for
if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
- for (i = 0; i < NCHARS; i++) {
- if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
+ /*
+ * BUG: We begin at 1, instead of 0, since we
+ * would otherwise prematurely terminate the
+ * string for classes like [[:cntrl:]]. This
+ * means that we can't match the NUL character,
+ * not without first adapting the entire
+ * program to track each string's length.
+ */
+ for (i = 1; i <= UCHAR_MAX; i++) {
+ if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg expr %.10s...", lastre);
if (cc->cc_func(i)) {
+ /* escape backslash */
+ if (i == '\\') {
+ *bp++ = '\\';
+ n++;
+ }
+
*bp++ = i;
n++;
}
}
} else
*bp++ = c;
+ } else if (c == '[' && *prestr == '.') {
+ char collate_char;
+ prestr++;
+ collate_char = *prestr++;
+ if (*prestr == '.' && prestr[1] == ']') {
+ prestr += 2;
+ /* Found it: map via locale TBD: for
+ now, simply return this char. This
+ is sufficient to pass conformance
+ test awk.ex 156
+ */
+ if (*prestr == ']') {
+ prestr++;
+ rlxval = collate_char;
+ return CHAR;
+ }
+ }
+ } else if (c == '[' && *prestr == '=') {
+ char equiv_char;
+ prestr++;
+ equiv_char = *prestr++;
+ if (*prestr == '=' && prestr[1] == ']') {
+ prestr += 2;
+ /* Found it: map via locale TBD: for now
+ simply return this char. This is
+ sufficient to pass conformance test
+ awk.ex 156
+ */
+ if (*prestr == ']') {
+ prestr++;
+ rlxval = equiv_char;
+ return CHAR;
+ }
+ }
} else if (c == '\0') {
FATAL("nonterminated character class %.20s", lastre);
} else if (bp == buf) { /* 1st char is special */
@@ -848,25 +1164,93 @@ int relex(void) /* lexical analyzer for
} else
*bp++ = c;
}
+ break;
+ case '{':
+ if (isdigit(*(prestr))) {
+ num = 0; /* Process as a repetition */
+ n = -1; m = -1;
+ commafound = false;
+ digitfound = false;
+ startreptok = prestr-1;
+ /* Remember start of previous atom here ? */
+ } else { /* just a { char, not a repetition */
+ rlxval = c;
+ return CHAR;
+ }
+ for (; ; ) {
+ if ((c = *prestr++) == '}') {
+ if (commafound) {
+ if (digitfound) { /* {n,m} */
+ m = num;
+ if (m < n)
+ FATAL("illegal repetition expression: class %.20s",
+ lastre);
+ if (n == 0 && m == 1) {
+ return QUEST;
+ }
+ } else { /* {n,} */
+ if (n == 0)
+ return STAR;
+ else if (n == 1)
+ return PLUS;
+ }
+ } else {
+ if (digitfound) { /* {n} same as {n,n} */
+ n = num;
+ m = num;
+ } else { /* {} */
+ FATAL("illegal repetition expression: class %.20s",
+ lastre);
+ }
+ }
+ if (repeat(starttok, prestr-starttok, lastatom,
+ startreptok - lastatom, n, m) > 0) {
+ if (n == 0 && m == 0) {
+ return ZERO;
+ }
+ /* must rescan input for next token */
+ goto rescan;
+ }
+ /* Failed to replace: eat up {...} characters
+ and treat like just PLUS */
+ return PLUS;
+ } else if (c == '\0') {
+ FATAL("nonterminated character class %.20s",
+ lastre);
+ } else if (isdigit(c)) {
+ num = 10 * num + c - '0';
+ digitfound = true;
+ } else if (c == ',') {
+ if (commafound)
+ FATAL("illegal repetition expression: class %.20s",
+ lastre);
+ /* looking for {n,} or {n,m} */
+ commafound = true;
+ n = num;
+ digitfound = false; /* reset */
+ num = 0;
+ } else {
+ FATAL("illegal repetition expression: class %.20s",
+ lastre);
+ }
+ }
+ break;
}
}
int cgoto(fa *f, int s, int c)
{
- int i, j, k;
int *p, *q;
+ int i, j, k;
assert(c == HAT || c < NCHARS);
while (f->accept >= maxsetvec) { /* guessing here! */
- maxsetvec *= 4;
- setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
- tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
- if (setvec == 0 || tmpset == 0)
- overflo("out of space in cgoto()");
+ resizesetvec(__func__);
}
for (i = 0; i <= f->accept; i++)
setvec[i] = 0;
setcnt = 0;
+ resize_state(f, s);
/* compute positions of gototab[s,c] into setvec */
p = f->posns[s];
for (i = 1; i <= *p; i++) {
@@ -880,11 +1264,7 @@ int cgoto(fa *f, int s, int c)
q = f->re[p[i]].lfollow;
for (j = 1; j <= *q; j++) {
if (q[j] >= maxsetvec) {
- maxsetvec *= 4;
- setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
- tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
- if (setvec == 0 || tmpset == 0)
- overflo("cgoto overflow");
+ resizesetvec(__func__);
}
if (setvec[q[j]] == 0) {
setcnt++;
@@ -901,6 +1281,7 @@ int cgoto(fa *f, int s, int c)
if (setvec[i]) {
tmpset[j++] = i;
}
+ resize_state(f, f->curstat > s ? f->curstat : s);
/* tmpset == previous state? */
for (i = 1; i <= f->curstat; i++) {
p = f->posns[i];
@@ -910,27 +1291,23 @@ int cgoto(fa *f, int s, int c)
if (tmpset[j] != p[j])
goto different;
/* setvec is state i */
- f->gototab[s][c] = i;
+ if (c != HAT)
+ f->gototab[s][c] = i;
return i;
different:;
}
/* add tmpset to current set of states */
- if (f->curstat >= NSTATES-1) {
- f->curstat = 2;
- f->reset = 1;
- for (i = 2; i < NSTATES; i++)
- xfree(f->posns[i]);
- } else
- ++(f->curstat);
+ ++(f->curstat);
+ resize_state(f, f->curstat);
for (i = 0; i < NCHARS; i++)
f->gototab[f->curstat][i] = 0;
xfree(f->posns[f->curstat]);
- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL)
- overflo("out of space in cgoto");
+ p = intalloc(setcnt + 1, __func__);
f->posns[f->curstat] = p;
- f->gototab[s][c] = f->curstat;
+ if (c != HAT)
+ f->gototab[s][c] = f->curstat;
for (i = 0; i <= setcnt; i++)
p[i] = tmpset[i];
if (setvec[f->accept])
@@ -947,13 +1324,18 @@ void freefa(fa *f) /* free a finite auto
if (f == NULL)
return;
+ for (i = 0; i < f->state_count; i++)
+ xfree(f->gototab[i])
for (i = 0; i <= f->curstat; i++)
xfree(f->posns[i]);
for (i = 0; i <= f->accept; i++) {
xfree(f->re[i].lfollow);
if (f->re[i].ltype == CCL || f->re[i].ltype == NCCL)
- xfree((f->re[i].lval.np));
+ xfree(f->re[i].lval.np);
}
xfree(f->restr);
+ xfree(f->out);
+ xfree(f->posns);
+ xfree(f->gototab);
xfree(f);
}
Index: pkgsrc/lang/nawk/files/proctab.c
diff -u pkgsrc/lang/nawk/files/proctab.c:1.3 pkgsrc/lang/nawk/files/proctab.c:1.4
--- pkgsrc/lang/nawk/files/proctab.c:1.3 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/proctab.c Fri Feb 24 20:57:50 2023
@@ -1,107 +1,107 @@
-/* $NetBSD: proctab.c,v 1.3 2014/03/12 14:20:43 ryoon Exp $ */
-
#include <stdio.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.tab.h"
-static char *printname[93] = {
- (char *) "FIRSTTOKEN", /* 57346 */
- (char *) "PROGRAM", /* 57347 */
- (char *) "PASTAT", /* 57348 */
- (char *) "PASTAT2", /* 57349 */
- (char *) "XBEGIN", /* 57350 */
- (char *) "XEND", /* 57351 */
- (char *) "NL", /* 57352 */
- (char *) "ARRAY", /* 57353 */
- (char *) "MATCH", /* 57354 */
- (char *) "NOTMATCH", /* 57355 */
- (char *) "MATCHOP", /* 57356 */
- (char *) "FINAL", /* 57357 */
- (char *) "DOT", /* 57358 */
- (char *) "ALL", /* 57359 */
- (char *) "CCL", /* 57360 */
- (char *) "NCCL", /* 57361 */
- (char *) "CHAR", /* 57362 */
- (char *) "OR", /* 57363 */
- (char *) "STAR", /* 57364 */
- (char *) "QUEST", /* 57365 */
- (char *) "PLUS", /* 57366 */
- (char *) "EMPTYRE", /* 57367 */
- (char *) "AND", /* 57368 */
- (char *) "BOR", /* 57369 */
- (char *) "APPEND", /* 57370 */
- (char *) "EQ", /* 57371 */
- (char *) "GE", /* 57372 */
- (char *) "GT", /* 57373 */
- (char *) "LE", /* 57374 */
- (char *) "LT", /* 57375 */
- (char *) "NE", /* 57376 */
- (char *) "IN", /* 57377 */
- (char *) "ARG", /* 57378 */
- (char *) "BLTIN", /* 57379 */
- (char *) "BREAK", /* 57380 */
- (char *) "CLOSE", /* 57381 */
- (char *) "CONTINUE", /* 57382 */
- (char *) "DELETE", /* 57383 */
- (char *) "DO", /* 57384 */
- (char *) "EXIT", /* 57385 */
- (char *) "FOR", /* 57386 */
- (char *) "FUNC", /* 57387 */
- (char *) "SUB", /* 57388 */
- (char *) "GSUB", /* 57389 */
- (char *) "IF", /* 57390 */
- (char *) "INDEX", /* 57391 */
- (char *) "LSUBSTR", /* 57392 */
- (char *) "MATCHFCN", /* 57393 */
- (char *) "NEXT", /* 57394 */
- (char *) "NEXTFILE", /* 57395 */
- (char *) "ADD", /* 57396 */
- (char *) "MINUS", /* 57397 */
- (char *) "MULT", /* 57398 */
- (char *) "DIVIDE", /* 57399 */
- (char *) "MOD", /* 57400 */
- (char *) "ASSIGN", /* 57401 */
- (char *) "ASGNOP", /* 57402 */
- (char *) "ADDEQ", /* 57403 */
- (char *) "SUBEQ", /* 57404 */
- (char *) "MULTEQ", /* 57405 */
- (char *) "DIVEQ", /* 57406 */
- (char *) "MODEQ", /* 57407 */
- (char *) "POWEQ", /* 57408 */
- (char *) "PRINT", /* 57409 */
- (char *) "PRINTF", /* 57410 */
- (char *) "SPRINTF", /* 57411 */
- (char *) "ELSE", /* 57412 */
- (char *) "INTEST", /* 57413 */
- (char *) "CONDEXPR", /* 57414 */
- (char *) "POSTINCR", /* 57415 */
- (char *) "PREINCR", /* 57416 */
- (char *) "POSTDECR", /* 57417 */
- (char *) "PREDECR", /* 57418 */
- (char *) "VAR", /* 57419 */
- (char *) "IVAR", /* 57420 */
- (char *) "VARNF", /* 57421 */
- (char *) "CALL", /* 57422 */
- (char *) "NUMBER", /* 57423 */
- (char *) "STRING", /* 57424 */
- (char *) "REGEXPR", /* 57425 */
- (char *) "GETLINE", /* 57426 */
- (char *) "RETURN", /* 57427 */
- (char *) "SPLIT", /* 57428 */
- (char *) "SUBSTR", /* 57429 */
- (char *) "WHILE", /* 57430 */
- (char *) "CAT", /* 57431 */
- (char *) "NOT", /* 57432 */
- (char *) "UMINUS", /* 57433 */
- (char *) "POWER", /* 57434 */
- (char *) "DECR", /* 57435 */
- (char *) "INCR", /* 57436 */
- (char *) "INDIRECT", /* 57437 */
- (char *) "LASTTOKEN", /* 57438 */
+static const char * const printname[95] = {
+ "FIRSTTOKEN", /* 258 */
+ "PROGRAM", /* 259 */
+ "PASTAT", /* 260 */
+ "PASTAT2", /* 261 */
+ "XBEGIN", /* 262 */
+ "XEND", /* 263 */
+ "NL", /* 264 */
+ "ARRAY", /* 265 */
+ "MATCH", /* 266 */
+ "NOTMATCH", /* 267 */
+ "MATCHOP", /* 268 */
+ "FINAL", /* 269 */
+ "DOT", /* 270 */
+ "ALL", /* 271 */
+ "CCL", /* 272 */
+ "NCCL", /* 273 */
+ "CHAR", /* 274 */
+ "OR", /* 275 */
+ "STAR", /* 276 */
+ "QUEST", /* 277 */
+ "PLUS", /* 278 */
+ "EMPTYRE", /* 279 */
+ "ZERO", /* 280 */
+ "AND", /* 281 */
+ "BOR", /* 282 */
+ "APPEND", /* 283 */
+ "EQ", /* 284 */
+ "GE", /* 285 */
+ "GT", /* 286 */
+ "LE", /* 287 */
+ "LT", /* 288 */
+ "NE", /* 289 */
+ "IN", /* 290 */
+ "ARG", /* 291 */
+ "BLTIN", /* 292 */
+ "BREAK", /* 293 */
+ "CLOSE", /* 294 */
+ "CONTINUE", /* 295 */
+ "DELETE", /* 296 */
+ "DO", /* 297 */
+ "EXIT", /* 298 */
+ "FOR", /* 299 */
+ "FUNC", /* 300 */
+ "SUB", /* 301 */
+ "GSUB", /* 302 */
+ "IF", /* 303 */
+ "INDEX", /* 304 */
+ "LSUBSTR", /* 305 */
+ "MATCHFCN", /* 306 */
+ "NEXT", /* 307 */
+ "NEXTFILE", /* 308 */
+ "ADD", /* 309 */
+ "MINUS", /* 310 */
+ "MULT", /* 311 */
+ "DIVIDE", /* 312 */
+ "MOD", /* 313 */
+ "ASSIGN", /* 314 */
+ "ASGNOP", /* 315 */
+ "ADDEQ", /* 316 */
+ "SUBEQ", /* 317 */
+ "MULTEQ", /* 318 */
+ "DIVEQ", /* 319 */
+ "MODEQ", /* 320 */
+ "POWEQ", /* 321 */
+ "PRINT", /* 322 */
+ "PRINTF", /* 323 */
+ "SPRINTF", /* 324 */
+ "ELSE", /* 325 */
+ "INTEST", /* 326 */
+ "CONDEXPR", /* 327 */
+ "POSTINCR", /* 328 */
+ "PREINCR", /* 329 */
+ "POSTDECR", /* 330 */
+ "PREDECR", /* 331 */
+ "VAR", /* 332 */
+ "IVAR", /* 333 */
+ "VARNF", /* 334 */
+ "CALL", /* 335 */
+ "NUMBER", /* 336 */
+ "STRING", /* 337 */
+ "REGEXPR", /* 338 */
+ "GETLINE", /* 339 */
+ "RETURN", /* 340 */
+ "SPLIT", /* 341 */
+ "SUBSTR", /* 342 */
+ "WHILE", /* 343 */
+ "CAT", /* 344 */
+ "NOT", /* 345 */
+ "UMINUS", /* 346 */
+ "UPLUS", /* 347 */
+ "POWER", /* 348 */
+ "DECR", /* 349 */
+ "INCR", /* 350 */
+ "INDIRECT", /* 351 */
+ "LASTTOKEN", /* 352 */
};
-Cell *(*proctab[93])(Node **, int) = {
+Cell *(*proctab[95])(Node **, int) = {
nullproc, /* FIRSTTOKEN */
program, /* PROGRAM */
pastat, /* PASTAT */
@@ -124,6 +124,7 @@ Cell *(*proctab[93])(Node **, int) = {
nullproc, /* QUEST */
nullproc, /* PLUS */
nullproc, /* EMPTYRE */
+ nullproc, /* ZERO */
boolop, /* AND */
boolop, /* BOR */
nullproc, /* APPEND */
@@ -190,6 +191,7 @@ Cell *(*proctab[93])(Node **, int) = {
cat, /* CAT */
boolop, /* NOT */
arith, /* UMINUS */
+ arith, /* UPLUS */
arith, /* POWER */
nullproc, /* DECR */
nullproc, /* INCR */
@@ -197,12 +199,12 @@ Cell *(*proctab[93])(Node **, int) = {
nullproc, /* LASTTOKEN */
};
-char *tokname(int n)
+const char *tokname(int n)
{
static char buf[100];
if (n < FIRSTTOKEN || n > LASTTOKEN) {
- sprintf(buf, "token %d", n);
+ snprintf(buf, sizeof(buf), "token %d", n);
return buf;
}
return printname[n-FIRSTTOKEN];
Index: pkgsrc/lang/nawk/files/run.c
diff -u pkgsrc/lang/nawk/files/run.c:1.3 pkgsrc/lang/nawk/files/run.c:1.4
--- pkgsrc/lang/nawk/files/run.c:1.3 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/run.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: run.c,v 1.3 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -27,20 +25,27 @@ THIS SOFTWARE.
#define DEBUG
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <fcntl.h>
#include <setjmp.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include "awk.h"
-#include "ytab.h"
-
-#define tempfree(x) if (istemp(x)) tfree(x); else
+#include "awkgram.tab.h"
-/*
-#undef tempfree
+static void stdinit(void);
+static void flush_all(void);
+#if 1
+#define tempfree(x) do { if (istemp(x)) tfree(x); } while (/*CONSTCOND*/0)
+#else
void tempfree(Cell *p) {
if (p->ctype == OCELL && (p->csub < CUNK || p->csub > CFREE)) {
WARNING("bad csub %d in Cell %d %s",
@@ -49,7 +54,7 @@ void tempfree(Cell *p) {
if (istemp(p))
tfree(p);
}
-*/
+#endif
/* do we really need these? */
/* #ifdef _NFILE */
@@ -73,23 +78,23 @@ extern Awkfloat srand_seed;
Node *winner = NULL; /* root of parse tree */
Cell *tmps; /* free temporary cells for execution */
-static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM };
+static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM, NULL, NULL };
Cell *True = &truecell;
-static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM };
+static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM, NULL, NULL };
Cell *False = &falsecell;
-static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM };
+static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jbreak = &breakcell;
-static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM };
+static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jcont = &contcell;
-static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM };
+static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jnext = &nextcell;
-static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM };
+static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jnextfile = &nextfilecell;
-static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM };
+static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jexit = &exitcell;
-static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM };
+static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM, NULL, NULL };
Cell *jret = &retcell;
-static Cell tempcell ={ OCELL, CTEMP, 0, "", 0.0, NUM|STR|DONTFREE };
+static Cell tempcell ={ OCELL, CTEMP, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL };
Node *curnode = NULL; /* the node being executed, for debugging */
@@ -114,7 +119,7 @@ int adjbuf(char **pbuf, int *psiz, int m
if (rminlen)
minlen += quantum - rminlen;
tbuf = (char *) realloc(*pbuf, minlen);
- dprintf( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) );
+ DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, (void*)*pbuf, (void*)tbuf);
if (tbuf == NULL) {
if (whatrtn)
FATAL("out of memory in %s", whatrtn);
@@ -130,7 +135,6 @@ int adjbuf(char **pbuf, int *psiz, int m
void run(Node *a) /* execution of parse tree starts here */
{
- extern void stdinit(void);
stdinit();
execute(a);
@@ -189,7 +193,7 @@ Cell *program(Node **a, int n) /* execut
tempfree(x);
}
if (a[1] || a[2])
- while (getrec(&record, &recsize, 1) > 0) {
+ while (getrec(&record, &recsize, true) > 0) {
x = execute(a[1]);
if (isexit(x))
break;
@@ -219,11 +223,11 @@ struct Frame { /* stack frame for awk fu
struct Frame *frame = NULL; /* base of stack frames; dynamically allocated */
int nframe = 0; /* number of frames allocated */
-struct Frame *fp = NULL; /* frame pointer. bottom level unused */
+struct Frame *frp = NULL; /* frame pointer. bottom level unused */
Cell *call(Node **a, int n) /* function call. very kludgy and fragile */
{
- static Cell newcopycell = { OCELL, CCOPY, 0, "", 0.0, NUM|STR|DONTFREE };
+ static const Cell newcopycell = { OCELL, CCOPY, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL };
int i, ncall, ndef;
int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */
Node *x;
@@ -236,25 +240,25 @@ Cell *call(Node **a, int n) /* function
if (!isfcn(fcn))
FATAL("calling undefined function %s", s);
if (frame == NULL) {
- fp = frame = (struct Frame *) calloc(nframe += 100, sizeof(struct Frame));
+ frp = frame = (struct Frame *) calloc(nframe += 100, sizeof(*frame));
if (frame == NULL)
FATAL("out of space for stack frames calling %s", s);
}
for (ncall = 0, x = a[1]; x != NULL; x = x->nnext) /* args in call */
ncall++;
ndef = (int) fcn->fval; /* args in defn */
- dprintf( ("calling %s, %d args (%d in defn), fp=%d\n", s, ncall, ndef, (int) (fp-frame)) );
+ DPRINTF("calling %s, %d args (%d in defn), frp=%d\n", s, ncall, ndef, (int) (frp-frame));
if (ncall > ndef)
WARNING("function %s called with %d args, uses only %d",
s, ncall, ndef);
if (ncall + ndef > NARGS)
FATAL("function %s has %d arguments, limit %d", s, ncall+ndef, NARGS);
for (i = 0, x = a[1]; x != NULL; i++, x = x->nnext) { /* get call args */
- dprintf( ("evaluate args[%d], fp=%d:\n", i, (int) (fp-frame)) );
+ DPRINTF("evaluate args[%d], frp=%d:\n", i, (int) (frp-frame));
y = execute(x);
oargs[i] = y;
- dprintf( ("args[%d]: %s %f <%s>, t=%o\n",
- i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval) );
+ DPRINTF("args[%d]: %s %f <%s>, t=%o\n",
+ i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval);
if (isfcn(y))
FATAL("can't use function %s as argument in %s", y->nval, s);
if (isarr(y))
@@ -267,26 +271,25 @@ Cell *call(Node **a, int n) /* function
args[i] = gettemp();
*args[i] = newcopycell;
}
- fp++; /* now ok to up frame */
- if (fp >= frame + nframe) {
- int dfp = fp - frame; /* old index */
- frame = (struct Frame *)
- realloc((char *) frame, (nframe += 100) * sizeof(struct Frame));
+ frp++; /* now ok to up frame */
+ if (frp >= frame + nframe) {
+ int dfp = frp - frame; /* old index */
+ frame = (struct Frame *) realloc(frame, (nframe += 100) * sizeof(*frame));
if (frame == NULL)
FATAL("out of space for stack frames in %s", s);
- fp = frame + dfp;
+ frp = frame + dfp;
}
- fp->fcncell = fcn;
- fp->args = args;
- fp->nargs = ndef; /* number defined with (excess are locals) */
- fp->retval = gettemp();
+ frp->fcncell = fcn;
+ frp->args = args;
+ frp->nargs = ndef; /* number defined with (excess are locals) */
+ frp->retval = gettemp();
- dprintf( ("start exec of %s, fp=%d\n", s, (int) (fp-frame)) );
+ DPRINTF("start exec of %s, frp=%d\n", s, (int) (frp-frame));
y = execute((Node *)(fcn->sval)); /* execute body */
- dprintf( ("finished exec of %s, fp=%d\n", s, (int) (fp-frame)) );
+ DPRINTF("finished exec of %s, frp=%d\n", s, (int) (frp-frame));
for (i = 0; i < ndef; i++) {
- Cell *t = fp->args[i];
+ Cell *t = frp->args[i];
if (isarr(t)) {
if (t->csub == CCOPY) {
if (i >= ncall) {
@@ -315,9 +318,9 @@ Cell *call(Node **a, int n) /* function
if (freed == 0) {
tempfree(y); /* don't free twice! */
}
- z = fp->retval; /* return value */
- dprintf( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) );
- fp--;
+ z = frp->retval; /* return value */
+ DPRINTF("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval);
+ frp--;
return(z);
}
@@ -325,14 +328,18 @@ Cell *copycell(Cell *x) /* make a copy o
{
Cell *y;
+ /* copy is not constant or field */
+
y = gettemp();
+ y->tval = x->tval & ~(CON|FLD|REC);
y->csub = CCOPY; /* prevents freeing until call is over */
y->nval = x->nval; /* BUG? */
- if (isstr(x))
+ if (isstr(x) /* || x->ctype == OCELL */) {
y->sval = tostring(x->sval);
+ y->tval &= ~DONTFREE;
+ } else
+ y->tval |= DONTFREE;
y->fval = x->fval;
- y->tval = x->tval & ~(CON|FLD|REC|DONTFREE); /* copy is not constant or field */
- /* is DONTFREE right? */
return y;
}
@@ -340,11 +347,11 @@ Cell *arg(Node **a, int n) /* nth argume
{
n = ptoi(a[0]); /* argument number, counting from 0 */
- dprintf( ("arg(%d), fp->nargs=%d\n", n, fp->nargs) );
- if (n+1 > fp->nargs)
+ DPRINTF("arg(%d), frp->nargs=%d\n", n, frp->nargs);
+ if (n+1 > frp->nargs)
FATAL("argument #%d of function %s was not supplied",
- n+1, fp->fcncell->nval);
- return fp->args[n];
+ n+1, frp->fcncell->nval);
+ return frp->args[n];
}
Cell *jump(Node **a, int n) /* break, continue, next, nextfile, return */
@@ -363,14 +370,14 @@ Cell *jump(Node **a, int n) /* break, co
if (a[0] != NULL) {
y = execute(a[0]);
if ((y->tval & (STR|NUM)) == (STR|NUM)) {
- setsval(fp->retval, getsval(y));
- fp->retval->fval = getfval(y);
- fp->retval->tval |= NUM;
+ setsval(frp->retval, getsval(y));
+ frp->retval->fval = getfval(y);
+ frp->retval->tval |= NUM;
}
else if (y->tval & STR)
- setsval(fp->retval, getsval(y));
+ setsval(frp->retval, getsval(y));
else if (y->tval & NUM)
- setfval(fp->retval, getfval(y));
+ setfval(frp->retval, getfval(y));
else /* can't happen */
FATAL("bad type variable %d", y->tval);
tempfree(y);
@@ -399,6 +406,8 @@ Cell *awkgetline(Node **a, int n) /* get
char *buf;
int bufsize = recsize;
int mode;
+ bool newflag;
+ double result;
if ((buf = (char *) malloc(bufsize)) == NULL)
FATAL("out of memory in getline");
@@ -410,33 +419,43 @@ Cell *awkgetline(Node **a, int n) /* get
mode = ptoi(a[1]);
if (mode == '|') /* input pipe */
mode = LE; /* arbitrary flag */
- fp = openfile(mode, getsval(x));
+ fp = openfile(mode, getsval(x), &newflag);
tempfree(x);
if (fp == NULL)
n = -1;
else
- n = readrec(&buf, &bufsize, fp);
+ n = readrec(&buf, &bufsize, fp, newflag);
if (n <= 0) {
;
} else if (a[0] != NULL) { /* getline var <file */
x = execute(a[0]);
setsval(x, buf);
+ if (is_number(x->sval, & result)) {
+ x->fval = result;
+ x->tval |= NUM;
+ }
tempfree(x);
} else { /* getline <file */
setsval(fldtab[0], buf);
- if (is_number(fldtab[0]->sval)) {
- fldtab[0]->fval = atof(fldtab[0]->sval);
+ if (is_number(fldtab[0]->sval, & result)) {
+ fldtab[0]->fval = result;
fldtab[0]->tval |= NUM;
}
}
} else { /* bare getline; use current input */
if (a[0] == NULL) /* getline */
- n = getrec(&record, &recsize, 1);
+ n = getrec(&record, &recsize, true);
else { /* getline var */
- n = getrec(&buf, &bufsize, 0);
- x = execute(a[0]);
- setsval(x, buf);
- tempfree(x);
+ n = getrec(&buf, &bufsize, false);
+ if (n > 0) {
+ x = execute(a[0]);
+ setsval(x, buf);
+ if (is_number(x->sval, & result)) {
+ x->fval = result;
+ x->tval |= NUM;
+ }
+ tempfree(x);
+ }
}
}
setfval(r, (Awkfloat) n);
@@ -446,37 +465,57 @@ Cell *awkgetline(Node **a, int n) /* get
Cell *getnf(Node **a, int n) /* get NF */
{
- if (donefld == 0)
+ if (!donefld)
fldbld();
return (Cell *) a[0];
}
-Cell *array(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts */
+static char *
+makearraystring(Node *p, const char *func)
{
- Cell *x, *y, *z;
- char *s;
- Node *np;
char *buf;
int bufsz = recsize;
- int nsub = strlen(*SUBSEP);
+ size_t blen;
- if ((buf = (char *) malloc(bufsz)) == NULL)
- FATAL("out of memory in array");
+ if ((buf = (char *) malloc(bufsz)) == NULL) {
+ FATAL("%s: out of memory", func);
+ }
- x = execute(a[0]); /* Cell* for symbol table */
- buf[0] = 0;
- for (np = a[1]; np; np = np->nnext) {
- y = execute(np); /* subscript */
- s = getsval(y);
- if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "array"))
- FATAL("out of memory for %s[%s...]", x->nval, buf);
- strcat(buf, s);
- if (np->nnext)
- strcat(buf, *SUBSEP);
- tempfree(y);
+ blen = 0;
+ buf[blen] = '\0';
+
+ for (; p; p = p->nnext) {
+ Cell *x = execute(p); /* expr */
+ char *s = getsval(x);
+ size_t seplen = strlen(getsval(subseploc));
+ size_t nsub = p->nnext ? seplen : 0;
+ size_t slen = strlen(s);
+ size_t tlen = blen + slen + nsub;
+
+ if (!adjbuf(&buf, &bufsz, tlen + 1, recsize, 0, func)) {
+ FATAL("%s: out of memory %s[%s...]",
+ func, x->nval, buf);
+ }
+ memcpy(buf + blen, s, slen);
+ if (nsub) {
+ memcpy(buf + blen + slen, *SUBSEP, nsub);
+ }
+ buf[tlen] = '\0';
+ blen = tlen;
+ tempfree(x);
}
+ return buf;
+}
+
+Cell *array(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts */
+{
+ Cell *x, *z;
+ char *buf;
+
+ x = execute(a[0]); /* Cell* for symbol table */
+ buf = makearraystring(a[1], __func__);
if (!isarr(x)) {
- dprintf( ("making %s into an array\n", NN(x->nval)) );
+ DPRINTF("making %s into an array\n", NN(x->nval));
if (freeable(x))
xfree(x->sval);
x->tval &= ~(STR|NUM|DONTFREE);
@@ -493,35 +532,21 @@ Cell *array(Node **a, int n) /* a[0] is
Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts */
{
- Cell *x, *y;
- Node *np;
- char *s;
- int nsub = strlen(*SUBSEP);
+ Cell *x;
x = execute(a[0]); /* Cell* for symbol table */
+ if (x == symtabloc) {
+ FATAL("cannot delete SYMTAB or its elements");
+ }
if (!isarr(x))
return True;
- if (a[1] == 0) { /* delete the elements, not the table */
+ if (a[1] == NULL) { /* delete the elements, not the table */
freesymtab(x);
x->tval &= ~STR;
x->tval |= ARR;
x->sval = (char *) makesymtab(NSYMTAB);
} else {
- int bufsz = recsize;
- char *buf;
- if ((buf = (char *) malloc(bufsz)) == NULL)
- FATAL("out of memory in adelete");
- buf[0] = 0;
- for (np = a[1]; np; np = np->nnext) {
- y = execute(np); /* subscript */
- s = getsval(y);
- if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "awkdelete"))
- FATAL("out of memory deleting %s[%s...]", x->nval, buf);
- strcat(buf, s);
- if (np->nnext)
- strcat(buf, *SUBSEP);
- tempfree(y);
- }
+ char *buf = makearraystring(a[1], __func__);
freeelem(x, buf);
free(buf);
}
@@ -531,36 +556,19 @@ Cell *awkdelete(Node **a, int n) /* a[0]
Cell *intest(Node **a, int n) /* a[0] is index (list), a[1] is symtab */
{
- Cell *x, *ap, *k;
- Node *p;
+ Cell *ap, *k;
char *buf;
- char *s;
- int bufsz = recsize;
- int nsub = strlen(*SUBSEP);
ap = execute(a[1]); /* array name */
if (!isarr(ap)) {
- dprintf( ("making %s into an array\n", ap->nval) );
+ DPRINTF("making %s into an array\n", ap->nval);
if (freeable(ap))
xfree(ap->sval);
ap->tval &= ~(STR|NUM|DONTFREE);
ap->tval |= ARR;
ap->sval = (char *) makesymtab(NSYMTAB);
}
- if ((buf = (char *) malloc(bufsz)) == NULL) {
- FATAL("out of memory in intest");
- }
- buf[0] = 0;
- for (p = a[0]; p; p = p->nnext) {
- x = execute(p); /* expr */
- s = getsval(x);
- if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "intest"))
- FATAL("out of memory deleting %s[%s...]", x->nval, buf);
- strcat(buf, s);
- tempfree(x);
- if (p->nnext)
- strcat(buf, *SUBSEP);
- }
+ buf = makearraystring(a[0], __func__);
k = lookup(buf, (Array *) ap->sval);
tempfree(ap);
free(buf);
@@ -585,7 +593,7 @@ Cell *matchop(Node **a, int n) /* ~ and
}
x = execute(a[1]); /* a[1] = target text */
s = getsval(x);
- if (a[0] == 0) /* a[1] == 0: already-compiled reg expr */
+ if (a[0] == NULL) /* a[1] == 0: already-compiled reg expr */
i = (*mf)((fa *) a[2], s);
else {
y = execute(a[2]); /* a[2] = regular expr */
@@ -682,7 +690,7 @@ Cell *relop(Node **a, int n) /* a[0 < a[
void tfree(Cell *a) /* free a tempcell */
{
if (freeable(a)) {
- dprintf( ("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval) );
+ DPRINTF("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval);
xfree(a->sval);
}
if (a == tmps)
@@ -696,12 +704,12 @@ Cell *gettemp(void) /* get a tempcell */
Cell *x;
if (!tmps) {
- tmps = (Cell *) calloc(100, sizeof(Cell));
+ tmps = (Cell *) calloc(100, sizeof(*tmps));
if (!tmps)
FATAL("out of space for temporaries");
- for(i = 1; i < 100; i++)
+ for (i = 1; i < 100; i++)
tmps[i-1].cnext = &tmps[i];
- tmps[i-1].cnext = 0;
+ tmps[i-1].cnext = NULL;
}
x = tmps;
tmps = x->cnext;
@@ -721,7 +729,7 @@ Cell *indirect(Node **a, int n) /* $( a[
if ((Awkfloat)INT_MAX < val)
FATAL("trying to access out of range field %s", x->nval);
m = (int) val;
- if (m == 0 && !is_number(s = getsval(x))) /* suspicion! */
+ if (m == 0 && !is_number(s = getsval(x), NULL)) /* suspicion! */
FATAL("illegal field $(%s), name \"%s\"", s, x->nval);
/* BUG: can x->nval ever be null??? */
tempfree(x);
@@ -736,18 +744,18 @@ Cell *substr(Node **a, int nnn) /* subs
int k, m, n;
char *s;
int temp;
- Cell *x, *y, *z = 0;
+ Cell *x, *y, *z = NULL;
x = execute(a[0]);
y = execute(a[1]);
- if (a[2] != 0)
+ if (a[2] != NULL)
z = execute(a[2]);
s = getsval(x);
k = strlen(s) + 1;
if (k <= 1) {
tempfree(x);
tempfree(y);
- if (a[2] != 0) {
+ if (a[2] != NULL) {
tempfree(z);
}
x = gettemp();
@@ -760,7 +768,7 @@ Cell *substr(Node **a, int nnn) /* subs
else if (m > k)
m = k;
tempfree(y);
- if (a[2] != 0) {
+ if (a[2] != NULL) {
n = (int) getfval(z);
tempfree(z);
} else
@@ -769,7 +777,7 @@ Cell *substr(Node **a, int nnn) /* subs
n = 0;
else if (n > k - m)
n = k - m;
- dprintf( ("substr: m=%d, n=%d, s=%s\n", m, n, s) );
+ DPRINTF("substr: m=%d, n=%d, s=%s\n", m, n, s);
y = gettemp();
temp = s[n+m-1]; /* with thanks to John Linderman */
s[n+m-1] = '\0';
@@ -792,8 +800,8 @@ Cell *sindex(Node **a, int nnn) /* inde
z = gettemp();
for (p1 = s1; *p1 != '\0'; p1++) {
- for (q=p1, p2=s2; *p2 != '\0' && *q == *p2; q++, p2++)
- ;
+ for (q = p1, p2 = s2; *p2 != '\0' && *q == *p2; q++, p2++)
+ continue;
if (*p2 == '\0') {
v = (Awkfloat) (p1 - s1 + 1); /* origin 1 */
break;
@@ -818,6 +826,19 @@ int format(char **pbuf, int *pbufsize, c
int fmtsz = recsize;
char *buf = *pbuf;
int bufsize = *pbufsize;
+#define FMTSZ(a) (fmtsz - ((a) - fmt))
+#define BUFSZ(a) (bufsize - ((a) - buf))
+
+ static bool first = true;
+ static bool have_a_format = false;
+
+ if (first) {
+ char xbuf[100];
+
+ snprintf(xbuf, sizeof(xbuf), "%a", 42.0);
+ have_a_format = (strcmp(xbuf, "0x1.5p+5") == 0);
+ first = false;
+ }
os = s;
p = buf;
@@ -842,12 +863,24 @@ int format(char **pbuf, int *pbufsize, c
for (t = fmt; (*t++ = *s) != '\0'; s++) {
if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3"))
FATAL("format item %.30s... ran format() out of memory", os);
- if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
- break; /* the ansi panoply */
+ /* Ignore size specifiers */
+ if (strchr("hjLlqtz", *s) != NULL) { /* the ansi panoply */
+ t--;
+ continue;
+ }
+ if (isalpha((uschar)*s))
+ break;
+ if (*s == '$') {
+ FATAL("'$' not permitted in awk formats");
+ }
if (*s == '*') {
+ if (a == NULL) {
+ FATAL("not enough args in printf(%s)", os);
+ }
x = execute(a);
a = a->nnext;
- sprintf(t-1, "%d", fmtwd=(int) getfval(x));
+ snprintf(t - 1, FMTSZ(t - 1),
+ "%d", fmtwd=(int) getfval(x));
if (fmtwd < 0)
fmtwd = -fmtwd;
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");
@@ -859,21 +892,22 @@ int format(char **pbuf, int *pbufsize, c
if (fmtwd < 0)
fmtwd = -fmtwd;
adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4");
-
switch (*s) {
+ case 'a': case 'A':
+ if (have_a_format)
+ flag = *s;
+ else
+ flag = 'f';
+ break;
case 'f': case 'e': case 'g': case 'E': case 'G':
flag = 'f';
break;
- case 'd': case 'i':
- flag = 'd';
- if(*(s-1) == 'l') break;
- *(t-1) = 'l';
- *t = 'd';
+ case 'd': case 'i': case 'o': case 'x': case 'X': case 'u':
+ flag = (*s == 'd' || *s == 'i') ? 'd' : 'u';
+ *(t-1) = 'j';
+ *t = *s;
*++t = '\0';
break;
- case 'o': case 'x': case 'X': case 'u':
- flag = *(s-1) == 'l' ? 'd' : 'u';
- break;
case 's':
flag = 's';
break;
@@ -894,18 +928,20 @@ int format(char **pbuf, int *pbufsize, c
n = fmtwd;
adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5");
switch (flag) {
- case '?': sprintf(p, "%s", fmt); /* unknown, so dump it too */
+ case '?': snprintf(p, BUFSZ(p), "%s", fmt); /* unknown, so dump it too */
t = getsval(x);
n = strlen(t);
if (fmtwd > n)
n = fmtwd;
adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6");
p += strlen(p);
- sprintf(p, "%s", t);
+ snprintf(p, BUFSZ(p), "%s", t);
break;
- case 'f': sprintf(p, fmt, getfval(x)); break;
- case 'd': sprintf(p, fmt, (long) getfval(x)); break;
- case 'u': sprintf(p, fmt, (int) getfval(x)); break;
+ case 'a':
+ case 'A':
+ case 'f': snprintf(p, BUFSZ(p), fmt, getfval(x)); break;
+ case 'd': snprintf(p, BUFSZ(p), fmt, (intmax_t) getfval(x)); break;
+ case 'u': snprintf(p, BUFSZ(p), fmt, (uintmax_t) getfval(x)); break;
case 's':
t = getsval(x);
n = strlen(t);
@@ -913,18 +949,18 @@ int format(char **pbuf, int *pbufsize, c
n = fmtwd;
if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7"))
FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);
- sprintf(p, fmt, t);
+ snprintf(p, BUFSZ(p), fmt, t);
break;
case 'c':
if (isnum(x)) {
- if (getfval(x))
- sprintf(p, fmt, (int) getfval(x));
+ if ((int)getfval(x))
+ snprintf(p, BUFSZ(p), fmt, (int) getfval(x));
else {
*p++ = '\0'; /* explicit null byte */
*p = '\0'; /* next output will start here */
}
} else
- sprintf(p, fmt, getsval(x)[0]);
+ snprintf(p, BUFSZ(p), fmt, getsval(x)[0]);
break;
default:
FATAL("can't happen: bad conversion %c in format()", flag);
@@ -1005,7 +1041,7 @@ Cell *arith(Node **a, int n) /* a[0] + a
x = execute(a[0]);
i = getfval(x);
tempfree(x);
- if (n != UMINUS) {
+ if (n != UMINUS && n != UPLUS) {
y = execute(a[1]);
j = getfval(y);
tempfree(y);
@@ -1035,11 +1071,15 @@ Cell *arith(Node **a, int n) /* a[0] + a
case UMINUS:
i = -i;
break;
+ case UPLUS: /* handled by getfval(), above */
+ break;
case POWER:
if (j >= 0 && modf(j, &v) == 0.0) /* pos integer exponent */
i = ipow(i, (int) j);
- else
+ else {
+ errno = 0;
i = errcheck(pow(i, j), "pow");
+ }
break;
default: /* can't happen */
FATAL("illegal arithmetic operator %d", n);
@@ -1090,8 +1130,8 @@ Cell *assign(Node **a, int n) /* a[0] =
y = execute(a[1]);
x = execute(a[0]);
if (n == ASSIGN) { /* ordinary assignment */
- if (x == y && !(x->tval & (FLD|REC))) /* self-assignment: */
- ; /* leave alone unless it's a field */
+ if (x == y && !(x->tval & (FLD|REC)) && x != nfloc)
+ ; /* self-assignment: leave alone unless it's a field or NF */
else if ((y->tval & (STR|NUM)) == (STR|NUM)) {
setsval(x, getsval(y));
x->fval = getfval(y);
@@ -1132,8 +1172,10 @@ Cell *assign(Node **a, int n) /* a[0] =
case POWEQ:
if (yf >= 0 && modf(yf, &v) == 0.0) /* pos integer exponent */
xf = ipow(xf, (int) yf);
- else
+ else {
+ errno = 0;
xf = errcheck(pow(xf, yf), "pow");
+ }
break;
default:
FATAL("illegal assignment operator %d", n);
@@ -1148,25 +1190,27 @@ Cell *cat(Node **a, int q) /* a[0] cat a
{
Cell *x, *y, *z;
int n1, n2;
- char *s;
+ char *s = NULL;
+ int ssz = 0;
x = execute(a[0]);
+ n1 = strlen(getsval(x));
+ adjbuf(&s, &ssz, n1, recsize, 0, "cat1");
+ memcpy(s, x->sval, n1);
+
y = execute(a[1]);
- getsval(x);
- getsval(y);
- n1 = strlen(x->sval);
- n2 = strlen(y->sval);
- s = (char *) malloc(n1 + n2 + 1);
- if (s == NULL)
- FATAL("out of space concatenating %.15s... and %.15s...",
- x->sval, y->sval);
- strcpy(s, x->sval);
- strcpy(s+n1, y->sval);
+ n2 = strlen(getsval(y));
+ adjbuf(&s, &ssz, n1 + n2 + 1, recsize, 0, "cat2");
+ memcpy(s + n1, y->sval, n2);
+ s[n1 + n2] = '\0';
+
tempfree(x);
tempfree(y);
+
z = gettemp();
z->sval = s;
z->tval = STR;
+
return(z);
}
@@ -1174,7 +1218,7 @@ Cell *pastat(Node **a, int n) /* a[0] {
{
Cell *x;
- if (a[0] == 0)
+ if (a[0] == NULL)
x = execute(a[1]);
else {
x = execute(a[0]);
@@ -1211,20 +1255,24 @@ Cell *dopa2(Node **a, int n) /* a[0], a[
Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
{
- Cell *x = 0, *y, *ap;
- char *s, *origs;
+ Cell *x = NULL, *y, *ap;
+ const char *s, *origs, *t;
+ const char *fs = NULL;
+ char *origfs = NULL;
int sep;
- char *t, temp, num[50], *fs = 0;
+ char temp, num[50];
int n, tempstat, arg3type;
+ double result;
y = execute(a[0]); /* source string */
origs = s = strdup(getsval(y));
arg3type = ptoi(a[3]);
- if (a[2] == 0) /* fs string */
- fs = *FS;
+ if (a[2] == NULL) /* fs string */
+ fs = getsval(fsloc);
else if (arg3type == STRING) { /* split(str,arr,"string") */
x = execute(a[2]);
- fs = getsval(x);
+ fs = origfs = strdup(getsval(x));
+ tempfree(x);
} else if (arg3type == REGEXPR)
fs = "(regexpr)"; /* split(str,arr,/regexpr/) */
else
@@ -1232,7 +1280,7 @@ Cell *split(Node **a, int nnn) /* split(
sep = *fs;
ap = execute(a[1]); /* array name */
freesymtab(ap);
- dprintf( ("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs) );
+ DPRINTF("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs);
ap->tval &= ~STR;
ap->tval |= ARR;
ap->sval = (char *) makesymtab(NSYMTAB);
@@ -1256,18 +1304,18 @@ Cell *split(Node **a, int nnn) /* split(
pfa->initstat = 2;
do {
n++;
- sprintf(num, "%d", n);
+ snprintf(num, sizeof(num), "%d", n);
temp = *patbeg;
- *patbeg = '\0';
- if (is_number(s))
- setsymtab(num, s, atof(s), STR|NUM, (Array *) ap->sval);
+ setptr(patbeg, '\0');
+ if (is_number(s, & result))
+ setsymtab(num, s, result, STR|NUM, (Array *) ap->sval);
else
setsymtab(num, s, 0.0, STR, (Array *) ap->sval);
- *patbeg = temp;
+ setptr(patbeg, temp);
s = patbeg + patlen;
- if (*(patbeg+patlen-1) == 0 || *s == 0) {
+ if (*(patbeg+patlen-1) == '\0' || *s == '\0') {
n++;
- sprintf(num, "%d", n);
+ snprintf(num, sizeof(num), "%d", n);
setsymtab(num, "", 0.0, STR, (Array *) ap->sval);
pfa->initstat = tempstat;
goto spdone;
@@ -1277,71 +1325,70 @@ Cell *split(Node **a, int nnn) /* split(
/* cf gsub and refldbld */
}
n++;
- sprintf(num, "%d", n);
- if (is_number(s))
- setsymtab(num, s, atof(s), STR|NUM, (Array *) ap->sval);
+ snprintf(num, sizeof(num), "%d", n);
+ if (is_number(s, & result))
+ setsymtab(num, s, result, STR|NUM, (Array *) ap->sval);
else
setsymtab(num, s, 0.0, STR, (Array *) ap->sval);
spdone:
pfa = NULL;
} else if (sep == ' ') {
for (n = 0; ; ) {
- while (*s == ' ' || *s == '\t' || *s == '\n')
+#define ISWS(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
+ while (ISWS(*s))
s++;
- if (*s == 0)
+ if (*s == '\0')
break;
n++;
t = s;
do
s++;
- while (*s!=' ' && *s!='\t' && *s!='\n' && *s!='\0');
+ while (*s != '\0' && !ISWS(*s));
temp = *s;
- *s = '\0';
- sprintf(num, "%d", n);
- if (is_number(t))
- setsymtab(num, t, atof(t), STR|NUM, (Array *) ap->sval);
+ setptr(s, '\0');
+ snprintf(num, sizeof(num), "%d", n);
+ if (is_number(t, & result))
+ setsymtab(num, t, result, STR|NUM, (Array *) ap->sval);
else
setsymtab(num, t, 0.0, STR, (Array *) ap->sval);
- *s = temp;
- if (*s != 0)
+ setptr(s, temp);
+ if (*s != '\0')
s++;
}
} else if (sep == 0) { /* new: split(s, a, "") => 1 char/elem */
- for (n = 0; *s != 0; s++) {
+ for (n = 0; *s != '\0'; s++) {
char buf[2];
n++;
- sprintf(num, "%d", n);
+ snprintf(num, sizeof(num), "%d", n);
buf[0] = *s;
- buf[1] = 0;
+ buf[1] = '\0';
if (isdigit((uschar)buf[0]))
setsymtab(num, buf, atof(buf), STR|NUM, (Array *) ap->sval);
else
setsymtab(num, buf, 0.0, STR, (Array *) ap->sval);
}
- } else if (*s != 0) {
+ } else if (*s != '\0') {
for (;;) {
n++;
t = s;
while (*s != sep && *s != '\n' && *s != '\0')
s++;
temp = *s;
- *s = '\0';
- sprintf(num, "%d", n);
- if (is_number(t))
- setsymtab(num, t, atof(t), STR|NUM, (Array *) ap->sval);
+ setptr(s, '\0');
+ snprintf(num, sizeof(num), "%d", n);
+ if (is_number(t, & result))
+ setsymtab(num, t, result, STR|NUM, (Array *) ap->sval);
else
setsymtab(num, t, 0.0, STR, (Array *) ap->sval);
- *s = temp;
- if (*s++ == 0)
+ setptr(s, temp);
+ if (*s++ == '\0')
break;
}
}
tempfree(ap);
tempfree(y);
- free(origs);
- if (a[2] != 0 && arg3type == STRING) {
- tempfree(x);
- }
+ xfree(origs);
+ xfree(origfs);
x = gettemp();
x->tval = NUM;
x->fval = n;
@@ -1371,7 +1418,7 @@ Cell *ifstat(Node **a, int n) /* if (a[0
if (istrue(x)) {
tempfree(x);
x = execute(a[1]);
- } else if (a[2] != 0) {
+ } else if (a[2] != NULL) {
tempfree(x);
x = execute(a[2]);
}
@@ -1423,7 +1470,7 @@ Cell *forstat(Node **a, int n) /* for (a
x = execute(a[0]);
tempfree(x);
for (;;) {
- if (a[1]!=0) {
+ if (a[1]!=NULL) {
x = execute(a[1]);
if (!istrue(x)) return(x);
else tempfree(x);
@@ -1471,16 +1518,98 @@ Cell *instat(Node **a, int n) /* for (a[
return True;
}
+static char *nawk_convert(const char *s, int (*fun_c)(int),
+ wint_t (*fun_wc)(wint_t))
+{
+ char *buf = NULL;
+ char *pbuf = NULL;
+ const char *ps = NULL;
+ size_t n = 0;
+ wchar_t wc;
+ size_t sz = MB_CUR_MAX;
+
+ if (sz == 1) {
+ buf = tostring(s);
+
+ for (pbuf = buf; *pbuf; pbuf++)
+ *pbuf = fun_c((uschar)*pbuf);
+
+ return buf;
+ } else {
+ /* upper/lower character may be shorter/longer */
+ buf = tostringN(s, strlen(s) * sz + 1);
+
+ (void) mbtowc(NULL, NULL, 0); /* reset internal state */
+ /*
+ * Reset internal state here too.
+ * Assign result to avoid a compiler warning. (Casting to void
+ * doesn't work.)
+ * Increment said variable to avoid a different warning.
+ */
+ int unused = wctomb(NULL, L'\0');
+ unused++;
+
+ ps = s;
+ pbuf = buf;
+ while (n = mbtowc(&wc, ps, sz),
+ n > 0 && n != (size_t)-1 && n != (size_t)-2)
+ {
+ ps += n;
+
+ n = wctomb(pbuf, fun_wc(wc));
+ if (n == (size_t)-1)
+ FATAL("illegal wide character %s", s);
+
+ pbuf += n;
+ }
+
+ *pbuf = '\0';
+
+ if (n)
+ FATAL("illegal byte sequence %s", s);
+
+ return buf;
+ }
+}
+
+#ifdef __DJGPP__
+static wint_t towupper(wint_t wc)
+{
+ if (wc >= 0 && wc < 256)
+ return toupper(wc & 0xFF);
+
+ return wc;
+}
+
+static wint_t towlower(wint_t wc)
+{
+ if (wc >= 0 && wc < 256)
+ return tolower(wc & 0xFF);
+
+ return wc;
+}
+#endif
+
+static char *nawk_toupper(const char *s)
+{
+ return nawk_convert(s, toupper, towupper);
+}
+
+static char *nawk_tolower(const char *s)
+{
+ return nawk_convert(s, tolower, towlower);
+}
+
Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg list */
{
Cell *x, *y;
Awkfloat u;
int t;
Awkfloat tmp;
- char *p, *buf;
+ char *buf;
Node *nextarg;
FILE *fp;
- void flush_all(void);
+ int status = 0;
t = ptoi(a[0]);
x = execute(a[1]);
@@ -1493,19 +1622,25 @@ Cell *bltin(Node **a, int n) /* builtin
u = strlen(getsval(x));
break;
case FLOG:
- u = errcheck(log(getfval(x)), "log"); break;
+ errno = 0;
+ u = errcheck(log(getfval(x)), "log");
+ break;
case FINT:
modf(getfval(x), &u); break;
case FEXP:
- u = errcheck(exp(getfval(x)), "exp"); break;
+ errno = 0;
+ u = errcheck(exp(getfval(x)), "exp");
+ break;
case FSQRT:
- u = errcheck(sqrt(getfval(x)), "sqrt"); break;
+ errno = 0;
+ u = errcheck(sqrt(getfval(x)), "sqrt");
+ break;
case FSIN:
u = sin(getfval(x)); break;
case FCOS:
u = cos(getfval(x)); break;
case FATAN:
- if (nextarg == 0) {
+ if (nextarg == NULL) {
WARNING("atan2 requires two arguments; returning 1.0");
u = 1.0;
} else {
@@ -1517,11 +1652,26 @@ Cell *bltin(Node **a, int n) /* builtin
break;
case FSYSTEM:
fflush(stdout); /* in case something is buffered already */
- u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */
+ status = system(getsval(x));
+ u = status;
+ if (status != -1) {
+ if (WIFEXITED(status)) {
+ u = WEXITSTATUS(status);
+ } else if (WIFSIGNALED(status)) {
+ u = WTERMSIG(status) + 256;
+#ifdef WCOREDUMP
+ if (WCOREDUMP(status))
+ u += 256;
+#endif
+ } else /* something else?!? */
+ u = 0;
+ }
break;
case FRAND:
- /* in principle, rand() returns something in 0..RAND_MAX */
- u = (Awkfloat) (rand() % RAND_MAX) / RAND_MAX;
+ /* random() returns numbers in [0..2^31-1]
+ * in order to get a number in [0, 1), divide it by 2^31
+ */
+ u = (Awkfloat) random() / (0x7fffffffL + 0x1UL);
break;
case FSRAND:
if (isrec(x)) /* no argument provided */
@@ -1529,22 +1679,16 @@ Cell *bltin(Node **a, int n) /* builtin
else
u = getfval(x);
tmp = u;
- srand((unsigned int) u);
+ srandom((unsigned long) u);
u = srand_seed;
srand_seed = tmp;
break;
case FTOUPPER:
case FTOLOWER:
- buf = tostring(getsval(x));
- if (t == FTOUPPER) {
- for (p = buf; *p; p++)
- if (islower((uschar) *p))
- *p = toupper((uschar)*p);
- } else {
- for (p = buf; *p; p++)
- if (isupper((uschar) *p))
- *p = tolower((uschar)*p);
- }
+ if (t == FTOUPPER)
+ buf = nawk_toupper(getsval(x));
+ else
+ buf = nawk_tolower(getsval(x));
tempfree(x);
x = gettemp();
setsval(x, buf);
@@ -1554,7 +1698,7 @@ Cell *bltin(Node **a, int n) /* builtin
if (isrec(x) || strlen(getsval(x)) == 0) {
flush_all(); /* fflush() or fflush("") -> all */
u = 0;
- } else if ((fp = openfile(FFLUSH, getsval(x))) == NULL)
+ } else if ((fp = openfile(FFLUSH, getsval(x), NULL)) == NULL)
u = EOF;
else
u = fflush(fp);
@@ -1566,7 +1710,7 @@ Cell *bltin(Node **a, int n) /* builtin
tempfree(x);
x = gettemp();
setfval(x, u);
- if (nextarg != 0) {
+ if (nextarg != NULL) {
WARNING("warning: function has too many arguments");
for ( ; nextarg; nextarg = nextarg->nnext)
execute(nextarg);
@@ -1580,7 +1724,7 @@ Cell *printstat(Node **a, int n) /* prin
Cell *y;
FILE *fp;
- if (a[1] == 0) /* a[1] is redirection operator, a[2] is file */
+ if (a[1] == NULL) /* a[1] is redirection operator, a[2] is file */
fp = stdout;
else
fp = redirect(ptoi(a[1]), a[2]);
@@ -1589,11 +1733,11 @@ Cell *printstat(Node **a, int n) /* prin
fputs(getpssval(y), fp);
tempfree(y);
if (x->nnext == NULL)
- fputs(*ORS, fp);
+ fputs(getsval(orsloc), fp);
else
- fputs(*OFS, fp);
+ fputs(getsval(ofsloc), fp);
}
- if (a[1] != 0)
+ if (a[1] != NULL)
fflush(fp);
if (ferror(fp))
FATAL("write error on %s", filename(fp));
@@ -1602,8 +1746,6 @@ Cell *printstat(Node **a, int n) /* prin
Cell *nullproc(Node **a, int n)
{
- n = n;
- a = a;
return 0;
}
@@ -1616,7 +1758,7 @@ FILE *redirect(int a, Node *b) /* set up
x = execute(b);
fname = getsval(x);
- fp = openfile(a, fname);
+ fp = openfile(a, fname, NULL);
if (fp == NULL)
FATAL("can't open file %s", fname);
tempfree(x);
@@ -1629,14 +1771,14 @@ struct files {
int mode; /* '|', 'a', 'w' => LE/LT, GT */
} *files;
-int nfiles;
+size_t nfiles;
-void stdinit(void) /* in case stdin, etc., are not constants */
+static void stdinit(void) /* in case stdin, etc., are not constants */
{
nfiles = FOPEN_MAX;
- files = calloc(nfiles, sizeof(*files));
+ files = (struct files *) calloc(nfiles, sizeof(*files));
if (files == NULL)
- FATAL("can't allocate file memory for %u files", nfiles);
+ FATAL("can't allocate file memory for %zu files", nfiles);
files[0].fp = stdin;
files[0].fname = "/dev/stdin";
files[0].mode = LT;
@@ -1648,33 +1790,35 @@ void stdinit(void) /* in case stdin, etc
files[2].mode = GT;
}
-FILE *openfile(int a, const char *us)
+FILE *openfile(int a, const char *us, bool *pnewflag)
{
const char *s = us;
- int i, m;
- FILE *fp = 0;
+ size_t i;
+ int m;
+ FILE *fp = NULL;
if (*s == '\0')
FATAL("null file name in print or getline");
- for (i=0; i < nfiles; i++)
- if (files[i].fname && strcmp(s, files[i].fname) == 0) {
- if (a == files[i].mode || (a==APPEND && files[i].mode==GT))
- return files[i].fp;
- if (a == FFLUSH)
- return files[i].fp;
+ for (i = 0; i < nfiles; i++)
+ if (files[i].fname && strcmp(s, files[i].fname) == 0 &&
+ (a == files[i].mode || (a==APPEND && files[i].mode==GT) ||
+ a == FFLUSH)) {
+ if (pnewflag)
+ *pnewflag = false;
+ return files[i].fp;
}
if (a == FFLUSH) /* didn't find it, so don't create it! */
return NULL;
- for (i=0; i < nfiles; i++)
- if (files[i].fp == 0)
+ for (i = 0; i < nfiles; i++)
+ if (files[i].fp == NULL)
break;
if (i >= nfiles) {
struct files *nf;
- int nnf = nfiles + FOPEN_MAX;
- nf = realloc(files, nnf * sizeof(*nf));
+ size_t nnf = nfiles + FOPEN_MAX;
+ nf = (struct files *) realloc(files, nnf * sizeof(*nf));
if (nf == NULL)
- FATAL("cannot grow files for %s and %d files", s, nnf);
+ FATAL("cannot grow files for %s and %zu files", s, nnf);
memset(&nf[nfiles], 0, FOPEN_MAX * sizeof(*nf));
nfiles = nnf;
files = nf;
@@ -1698,13 +1842,17 @@ FILE *openfile(int a, const char *us)
files[i].fname = tostring(s);
files[i].fp = fp;
files[i].mode = m;
+ if (pnewflag)
+ *pnewflag = true;
+ if (fp != stdin && fp != stdout && fp != stderr)
+ (void) fcntl(fileno(fp), F_SETFD, FD_CLOEXEC);
}
return fp;
}
const char *filename(FILE *fp)
{
- int i;
+ size_t i;
for (i = 0; i < nfiles; i++)
if (fp == files[i].fp)
@@ -1714,69 +1862,91 @@ const char *filename(FILE *fp)
Cell *closefile(Node **a, int n)
{
- Cell *x;
- int i, stat;
-
- n = n;
- x = execute(a[0]);
- getsval(x);
- stat = -1;
- for (i = 0; i < nfiles; i++) {
- if (files[i].fname && strcmp(x->sval, files[i].fname) == 0) {
- if (ferror(files[i].fp))
- WARNING( "i/o error occurred on %s", files[i].fname );
- if (files[i].mode == '|' || files[i].mode == LE)
- stat = pclose(files[i].fp);
+ Cell *x;
+ size_t i;
+ bool stat;
+
+ x = execute(a[0]);
+ getsval(x);
+ stat = true;
+ for (i = 0; i < nfiles; i++) {
+ if (!files[i].fname || strcmp(x->sval, files[i].fname) != 0)
+ continue;
+ if (files[i].mode == GT || files[i].mode == '|')
+ fflush(files[i].fp);
+ if (ferror(files[i].fp)) {
+ if ((files[i].mode == GT && files[i].fp != stderr)
+ || files[i].mode == '|')
+ FATAL("write error on %s", files[i].fname);
else
- stat = fclose(files[i].fp);
- if (stat == EOF)
- WARNING( "i/o error occurred closing %s", files[i].fname );
- if (i > 2) /* don't do /dev/std... */
- xfree(files[i].fname);
- files[i].fname = NULL; /* watch out for ref thru this */
- files[i].fp = NULL;
+ WARNING("i/o error occurred on %s", files[i].fname);
}
- }
- tempfree(x);
- x = gettemp();
- setfval(x, (Awkfloat) stat);
- return(x);
+ if (files[i].fp == stdin || files[i].fp == stdout ||
+ files[i].fp == stderr)
+ stat = freopen("/dev/null", "r+", files[i].fp) == NULL;
+ else if (files[i].mode == '|' || files[i].mode == LE)
+ stat = pclose(files[i].fp) == -1;
+ else
+ stat = fclose(files[i].fp) == EOF;
+ if (stat)
+ WARNING("i/o error occurred closing %s", files[i].fname);
+ if (i > 2) /* don't do /dev/std... */
+ xfree(files[i].fname);
+ files[i].fname = NULL; /* watch out for ref thru this */
+ files[i].fp = NULL;
+ break;
+ }
+ tempfree(x);
+ x = gettemp();
+ setfval(x, (Awkfloat) (stat ? -1 : 0));
+ return(x);
}
void closeall(void)
{
- int i, stat;
+ size_t i;
+ bool stat = false;
- for (i = 0; i < FOPEN_MAX; i++) {
- if (files[i].fp) {
- if (ferror(files[i].fp))
- WARNING( "i/o error occurred on %s", files[i].fname );
- if (files[i].mode == '|' || files[i].mode == LE)
- stat = pclose(files[i].fp);
+ for (i = 0; i < nfiles; i++) {
+ if (! files[i].fp)
+ continue;
+ if (files[i].mode == GT || files[i].mode == '|')
+ fflush(files[i].fp);
+ if (ferror(files[i].fp)) {
+ if ((files[i].mode == GT && files[i].fp != stderr)
+ || files[i].mode == '|')
+ FATAL("write error on %s", files[i].fname);
else
- stat = fclose(files[i].fp);
- if (stat == EOF)
- WARNING( "i/o error occurred while closing %s", files[i].fname );
+ WARNING("i/o error occurred on %s", files[i].fname);
}
+ if (files[i].fp == stdin || files[i].fp == stdout ||
+ files[i].fp == stderr)
+ continue;
+ if (files[i].mode == '|' || files[i].mode == LE)
+ stat = pclose(files[i].fp) == -1;
+ else
+ stat = fclose(files[i].fp) == EOF;
+ if (stat)
+ WARNING("i/o error occurred while closing %s", files[i].fname);
}
}
-void flush_all(void)
+static void flush_all(void)
{
- int i;
+ size_t i;
for (i = 0; i < nfiles; i++)
if (files[i].fp)
fflush(files[i].fp);
}
-void backsub(char **pb_ptr, char **sptr_ptr);
+void backsub(char **pb_ptr, const char **sptr_ptr);
Cell *sub(Node **a, int nnn) /* substitute command */
{
- char *sptr, *pb, *q;
+ const char *sptr, *q;
Cell *x, *y, *result;
- char *t, *buf;
+ char *t, *buf, *pb;
fa *pfa;
int bufsz = recsize;
@@ -1784,7 +1954,7 @@ Cell *sub(Node **a, int nnn) /* substitu
FATAL("out of memory in sub");
x = execute(a[3]); /* target string */
t = getsval(x);
- if (a[0] == 0) /* 0 => a[1] is already-compiled regexpr */
+ if (a[0] == NULL) /* 0 => a[1] is already-compiled regexpr */
pfa = (fa *) a[1]; /* regular expression */
else {
y = execute(a[1]);
@@ -1800,7 +1970,7 @@ Cell *sub(Node **a, int nnn) /* substitu
while (sptr < patbeg)
*pb++ = *sptr++;
sptr = getsval(y);
- while (*sptr != 0) {
+ while (*sptr != '\0') {
adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "sub");
if (*sptr == '\\') {
backsub(&pb, &sptr);
@@ -1818,13 +1988,13 @@ Cell *sub(Node **a, int nnn) /* substitu
sptr = patbeg + patlen;
if ((patlen == 0 && *patbeg) || (patlen && *(sptr-1))) {
adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "sub");
- while ((*pb++ = *sptr++) != 0)
- ;
+ while ((*pb++ = *sptr++) != '\0')
+ continue;
}
if (pb > buf + bufsz)
FATAL("sub result2 %.30s too big; can't happen", buf);
setsval(x, buf); /* BUG: should be able to avoid copy */
- result = True;;
+ result = True;
}
tempfree(x);
tempfree(y);
@@ -1835,7 +2005,8 @@ Cell *sub(Node **a, int nnn) /* substitu
Cell *gsub(Node **a, int nnn) /* global substitute */
{
Cell *x, *y;
- char *rptr, *sptr, *t, *pb, *q;
+ char *rptr, *pb;
+ const char *q, *t, *sptr;
char *buf;
fa *pfa;
int mflag, tempstat, num;
@@ -1847,7 +2018,7 @@ Cell *gsub(Node **a, int nnn) /* global
num = 0;
x = execute(a[3]); /* target string */
t = getsval(x);
- if (a[0] == 0) /* 0 => a[1] is already-compiled regexpr */
+ if (a[0] == NULL) /* 0 => a[1] is already-compiled regexpr */
pfa = (fa *) a[1]; /* regular expression */
else {
y = execute(a[1]);
@@ -1861,11 +2032,11 @@ Cell *gsub(Node **a, int nnn) /* global
pb = buf;
rptr = getsval(y);
do {
- if (patlen == 0 && *patbeg != 0) { /* matched empty string */
+ if (patlen == 0 && *patbeg != '\0') { /* matched empty string */
if (mflag == 0) { /* can replace empty */
num++;
sptr = rptr;
- while (*sptr != 0) {
+ while (*sptr != '\0') {
adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "gsub");
if (*sptr == '\\') {
backsub(&pb, &sptr);
@@ -1878,7 +2049,7 @@ Cell *gsub(Node **a, int nnn) /* global
*pb++ = *sptr++;
}
}
- if (*t == 0) /* at end */
+ if (*t == '\0') /* at end */
goto done;
adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gsub");
*pb++ = *t++;
@@ -1893,7 +2064,7 @@ Cell *gsub(Node **a, int nnn) /* global
while (sptr < patbeg)
*pb++ = *sptr++;
sptr = rptr;
- while (*sptr != 0) {
+ while (*sptr != '\0') {
adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "gsub");
if (*sptr == '\\') {
backsub(&pb, &sptr);
@@ -1906,7 +2077,7 @@ Cell *gsub(Node **a, int nnn) /* global
*pb++ = *sptr++;
}
t = patbeg + patlen;
- if (patlen == 0 || *t == 0 || *(t-1) == 0)
+ if (patlen == 0 || *t == '\0' || *(t-1) == '\0')
goto done;
if (pb > buf + bufsz)
FATAL("gsub result1 %.30s too big; can't happen", buf);
@@ -1915,8 +2086,8 @@ Cell *gsub(Node **a, int nnn) /* global
} while (pmatch(pfa,t));
sptr = t;
adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub");
- while ((*pb++ = *sptr++) != 0)
- ;
+ while ((*pb++ = *sptr++) != '\0')
+ continue;
done: if (pb < buf + bufsz)
*pb = '\0';
else if (*(pb-1) != '\0')
@@ -1933,9 +2104,17 @@ Cell *gsub(Node **a, int nnn) /* global
return(x);
}
-void backsub(char **pb_ptr, char **sptr_ptr) /* handle \\& variations */
+void backsub(char **pb_ptr, const char **sptr_ptr) /* handle \\& variations */
{ /* sptr[0] == '\\' */
- char *pb = *pb_ptr, *sptr = *sptr_ptr;
+ char *pb = *pb_ptr;
+ const char *sptr = *sptr_ptr;
+ static bool first = true;
+ static bool do_posix = false;
+
+ if (first) {
+ first = false;
+ do_posix = (getenv("POSIXLY_CORRECT") != NULL);
+ }
if (sptr[1] == '\\') {
if (sptr[2] == '\\' && sptr[3] == '&') { /* \\\& -> \& */
@@ -1945,6 +2124,9 @@ void backsub(char **pb_ptr, char **sptr_
} else if (sptr[2] == '&') { /* \\& -> \ + matched */
*pb++ = '\\';
sptr += 2;
+ } else if (do_posix) { /* \\x -> \x */
+ sptr++;
+ *pb++ = *sptr++;
} else { /* \\x -> \\x */
*pb++ = *sptr++;
*pb++ = *sptr++;
Index: pkgsrc/lang/nawk/files/lib.c
diff -u pkgsrc/lang/nawk/files/lib.c:1.4 pkgsrc/lang/nawk/files/lib.c:1.5
--- pkgsrc/lang/nawk/files/lib.c:1.4 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/lib.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: lib.c,v 1.4 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -27,45 +25,49 @@ THIS SOFTWARE.
#define DEBUG
#include <stdio.h>
#include <string.h>
+#include <strings.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <limits.h>
+#include <math.h>
#include "awk.h"
-#include "ytab.h"
+char EMPTY[] = { '\0' };
FILE *infile = NULL;
-char *file = "";
+bool innew; /* true = infile has not been read by readrec */
+char *file = EMPTY;
char *record;
int recsize = RECSIZE;
char *fields;
int fieldssize = RECSIZE;
Cell **fldtab; /* pointers to Cells */
-char static_inputFS[16] = " ";
-size_t len_inputFS = sizeof(static_inputFS) - 1;
-char *inputFS = static_inputFS;
+static size_t len_inputFS = 0;
+static char *inputFS = NULL; /* FS at time of input, for field splitting */
#define MAXFLD 2
int nfields = MAXFLD; /* last allocated slot for $i */
-int donefld; /* 1 = implies rec broken into fields */
-int donerec; /* 1 = record is valid (no flds have changed) */
+bool donefld; /* true = implies rec broken into fields */
+bool donerec; /* true = record is valid (no flds have changed) */
int lastfld = 0; /* last used field */
int argno = 1; /* current input argument number */
extern Awkfloat *ARGC;
-static Cell dollar0 = { OCELL, CFLD, NULL, "", 0.0, REC|STR|DONTFREE };
-static Cell dollar1 = { OCELL, CFLD, NULL, "", 0.0, FLD|STR|DONTFREE };
+static Cell dollar0 = { OCELL, CFLD, NULL, EMPTY, 0.0, REC|STR|DONTFREE, NULL, NULL };
+static Cell dollar1 = { OCELL, CFLD, NULL, EMPTY, 0.0, FLD|STR|DONTFREE, NULL, NULL };
void recinit(unsigned int n)
{
if ( (record = (char *) malloc(n)) == NULL
|| (fields = (char *) malloc(n+1)) == NULL
- || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL
- || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL )
+ || (fldtab = (Cell **) calloc(nfields+2, sizeof(*fldtab))) == NULL
+ || (fldtab[0] = (Cell *) malloc(sizeof(**fldtab))) == NULL)
FATAL("out of space for $0 and fields");
+ *record = '\0';
*fldtab[0] = dollar0;
fldtab[0]->sval = record;
fldtab[0]->nval = tostring("0");
@@ -78,11 +80,11 @@ void makefields(int n1, int n2) /* crea
int i;
for (i = n1; i <= n2; i++) {
- fldtab[i] = (Cell *) malloc(sizeof (struct Cell));
+ fldtab[i] = (Cell *) malloc(sizeof(**fldtab));
if (fldtab[i] == NULL)
FATAL("out of space in makefields %d", i);
*fldtab[i] = dollar1;
- sprintf(temp, "%d", i);
+ snprintf(temp, sizeof(temp), "%d", i);
fldtab[i]->nval = tostring(temp);
}
}
@@ -106,11 +108,36 @@ void initgetrec(void)
argno++;
}
infile = stdin; /* no filenames, so use stdin */
+ innew = true;
+}
+
+/*
+ * POSIX specifies that fields are supposed to be evaluated as if they were
+ * split using the value of FS at the time that the record's value ($0) was
+ * read.
+ *
+ * Since field-splitting is done lazily, we save the current value of FS
+ * whenever a new record is read in (implicitly or via getline), or when
+ * a new value is assigned to $0.
+ */
+void savefs(void)
+{
+ size_t len;
+ if ((len = strlen(getsval(fsloc))) < len_inputFS) {
+ strcpy(inputFS, *FS); /* for subsequent field splitting */
+ return;
+ }
+
+ len_inputFS = len + 1;
+ inputFS = (char *) realloc(inputFS, len_inputFS);
+ if (inputFS == NULL)
+ FATAL("field separator %.10s... is too long", *FS);
+ memcpy(inputFS, *FS, len_inputFS);
}
-static int firsttime = 1;
+static bool firsttime = true;
-int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */
+int getrec(char **pbuf, int *pbufsize, bool isrecord) /* get next input record */
{ /* note: cares whether buf == record */
int c;
char *buf = *pbuf;
@@ -118,19 +145,20 @@ int getrec(char **pbuf, int *pbufsize, i
int bufsize = *pbufsize, savebufsize = bufsize;
if (firsttime) {
- firsttime = 0;
+ firsttime = false;
initgetrec();
}
- dprintf( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n",
- *RS, *FS, *ARGC, *FILENAME) );
+ DPRINTF("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n",
+ *RS, *FS, *ARGC, *FILENAME);
if (isrecord) {
- donefld = 0;
- donerec = 1;
+ donefld = false;
+ donerec = true;
+ savefs();
}
saveb0 = buf[0];
buf[0] = 0;
while (argno < *ARGC || infile == stdin) {
- dprintf( ("argno=%d, file=|%s|\n", argno, file) );
+ DPRINTF("argno=%d, file=|%s|\n", argno, file);
if (infile == NULL) { /* have to open a new file */
file = getargv(argno);
if (file == NULL || *file == '\0') { /* deleted or zapped */
@@ -143,22 +171,27 @@ int getrec(char **pbuf, int *pbufsize, i
continue;
}
*FILENAME = file;
- dprintf( ("opening file %s\n", file) );
+ DPRINTF("opening file %s\n", file);
if (*file == '-' && *(file+1) == '\0')
infile = stdin;
else if ((infile = fopen(file, "r")) == NULL)
FATAL("can't open file %s", file);
+ innew = true;
setfval(fnrloc, 0.0);
}
- c = readrec(&buf, &bufsize, infile);
+ c = readrec(&buf, &bufsize, infile, innew);
+ if (innew)
+ innew = false;
if (c != 0 || buf[0] != '\0') { /* normal record */
if (isrecord) {
+ double result;
+
if (freeable(fldtab[0]))
xfree(fldtab[0]->sval);
fldtab[0]->sval = buf; /* buf == record */
fldtab[0]->tval = REC | STR | DONTFREE;
- if (is_number(fldtab[0]->sval)) {
- fldtab[0]->fval = atof(fldtab[0]->sval);
+ if (is_number(fldtab[0]->sval, & result)) {
+ fldtab[0]->fval = result;
fldtab[0]->tval |= NUM;
}
}
@@ -188,54 +221,63 @@ void nextfile(void)
argno++;
}
-int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf */
+int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one record into buf */
{
- int sep, c;
+ int sep, c, isrec;
char *rr, *buf = *pbuf;
int bufsize = *pbufsize;
- size_t len;
+ char *rs = getsval(rsloc);
- if ((len = strlen(*FS)) <= len_inputFS) {
- strcpy(inputFS, *FS); /* for subsequent field splitting */
+ if (*rs && rs[1]) {
+ bool found;
+
+ fa *pfa = makedfa(rs, 1);
+ if (newflag)
+ found = fnematch(pfa, inf, &buf, &bufsize, recsize);
+ else {
+ int tempstat = pfa->initstat;
+ pfa->initstat = 2;
+ found = fnematch(pfa, inf, &buf, &bufsize, recsize);
+ pfa->initstat = tempstat;
+ }
+ if (found)
+ setptr(patbeg, '\0');
+ isrec = (found == 0 && *buf == '\0') ? false : true;
} else {
- if (inputFS != static_inputFS)
- free(inputFS);
- inputFS = malloc(len + 1);
- if (inputFS == NULL)
- FATAL("field separator %.10s... is too long", *FS);
- len_inputFS = len;
- memcpy(inputFS, *FS, len + 1);
- }
- if ((sep = **RS) == 0) {
- sep = '\n';
- while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
- ;
- if (c != EOF)
- ungetc(c, inf);
- }
- for (rr = buf; ; ) {
- for (; (c=getc(inf)) != sep && c != EOF; ) {
- if (rr-buf+1 > bufsize)
- if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 1"))
- FATAL("input record `%.30s...' too long", buf);
+ if ((sep = *rs) == 0) {
+ sep = '\n';
+ while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
+ ;
+ if (c != EOF)
+ ungetc(c, inf);
+ }
+ for (rr = buf; ; ) {
+ for (; (c=getc(inf)) != sep && c != EOF; ) {
+ if (rr-buf+1 > bufsize)
+ if (!adjbuf(&buf, &bufsize, 1+rr-buf,
+ recsize, &rr, "readrec 1"))
+ FATAL("input record `%.30s...' too long", buf);
+ *rr++ = c;
+ }
+ if (*rs == sep || c == EOF)
+ break;
+ if ((c = getc(inf)) == '\n' || c == EOF) /* 2 in a row */
+ break;
+ if (!adjbuf(&buf, &bufsize, 2+rr-buf, recsize, &rr,
+ "readrec 2"))
+ FATAL("input record `%.30s...' too long", buf);
+ *rr++ = '\n';
*rr++ = c;
}
- if (**RS == sep || c == EOF)
- break;
- if ((c = getc(inf)) == '\n' || c == EOF) /* 2 in a row */
- break;
- if (!adjbuf(&buf, &bufsize, 2+rr-buf, recsize, &rr, "readrec 2"))
+ if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
FATAL("input record `%.30s...' too long", buf);
- *rr++ = '\n';
- *rr++ = c;
+ *rr = 0;
+ isrec = (c == EOF && rr == buf) ? false : true;
}
- if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
- FATAL("input record `%.30s...' too long", buf);
- *rr = 0;
- dprintf( ("readrec saw <%s>, returns %d\n", buf, c == EOF && rr == buf ? 0 : 1) );
*pbuf = buf;
*pbufsize = bufsize;
- return c == EOF && rr == buf ? 0 : 1;
+ DPRINTF("readrec saw <%s>, returns %d\n", buf, isrec);
+ return isrec;
}
char *getargv(int n) /* get ARGV[n] */
@@ -244,12 +286,12 @@ char *getargv(int n) /* get ARGV[n] */
char *s, temp[50];
extern Array *ARGVtab;
- sprintf(temp, "%d", n);
+ snprintf(temp, sizeof(temp), "%d", n);
if (lookup(temp, ARGVtab) == NULL)
return NULL;
x = setsymtab(temp, "", 0.0, STR, ARGVtab);
s = getsval(x);
- dprintf( ("getargv(%d) returns |%s|\n", n, s) );
+ DPRINTF("getargv(%d) returns |%s|\n", n, s);
return s;
}
@@ -257,6 +299,7 @@ void setclvar(char *s) /* set var=value
{
char *p;
Cell *q;
+ double result;
for (p=s; *p != '='; p++)
;
@@ -264,11 +307,11 @@ void setclvar(char *s) /* set var=value
p = qstring(p, '\0');
q = setsymtab(s, p, 0.0, STR, symtab);
setsval(q, p);
- if (is_number(q->sval)) {
- q->fval = atof(q->sval);
+ if (is_number(q->sval, & result)) {
+ q->fval = result;
q->tval |= NUM;
}
- dprintf( ("command line set %s to |%s|\n", s, p) );
+ DPRINTF("command line set %s to |%s|\n", s, p);
}
@@ -295,7 +338,9 @@ void fldbld(void) /* create fields from
}
fr = fields;
i = 0; /* number of fields accumulated here */
- if (inputFS[0] && inputFS[1]) { /* it's a regular expression */
+ if (inputFS == NULL) /* make sure we have a copy of FS */
+ savefs();
+ if (strlen(inputFS) > 1) { /* it's a regular expression */
i = refldbld(r, inputFS);
} else if ((sep = *inputFS) == ' ') { /* default whitespace */
for (i = 0; ; ) {
@@ -317,15 +362,19 @@ void fldbld(void) /* create fields from
}
*fr = 0;
} else if ((sep = *inputFS) == 0) { /* new: FS="" => 1 char/field */
- for (i = 0; *r != 0; r++) {
- char buf[2];
+ for (i = 0; *r != '\0'; r += n) {
+ char buf[MB_LEN_MAX + 1];
+
i++;
if (i > nfields)
growfldtab(i);
if (freeable(fldtab[i]))
xfree(fldtab[i]->sval);
- buf[0] = *r;
- buf[1] = 0;
+ n = mblen(r, MB_LEN_MAX);
+ if (n < 0)
+ n = 1;
+ memcpy(buf, r, n);
+ buf[n] = '\0';
fldtab[i]->sval = tostring(buf);
fldtab[i]->tval = FLD | STR;
}
@@ -358,15 +407,18 @@ void fldbld(void) /* create fields from
FATAL("record `%.30s...' has too many fields; can't happen", r);
cleanfld(i+1, lastfld); /* clean out junk from previous record */
lastfld = i;
- donefld = 1;
+ donefld = true;
for (j = 1; j <= lastfld; j++) {
+ double result;
+
p = fldtab[j];
- if(is_number(p->sval)) {
- p->fval = atof(p->sval);
+ if(is_number(p->sval, & result)) {
+ p->fval = result;
p->tval |= NUM;
}
}
setfval(nfloc, (Awkfloat) lastfld);
+ donerec = true; /* restore */
if (dbg) {
for (j = 0; j <= lastfld; j++) {
p = fldtab[j];
@@ -384,7 +436,7 @@ void cleanfld(int n1, int n2) /* clean o
p = fldtab[i];
if (freeable(p))
xfree(p->sval);
- p->sval = "";
+ p->sval = EMPTY,
p->tval = FLD | STR | DONTFREE;
}
}
@@ -398,6 +450,21 @@ void newfld(int n) /* add field n after
setfval(nfloc, (Awkfloat) n);
}
+void setlastfld(int n) /* set lastfld cleaning fldtab cells if necessary */
+{
+ if (n < 0)
+ FATAL("cannot set NF to a negative value");
+ if (n > nfields)
+ growfldtab(n);
+
+ if (lastfld < n)
+ cleanfld(lastfld+1, n);
+ else
+ cleanfld(n+1, lastfld);
+
+ lastfld = n;
+}
+
Cell *fieldadr(int n) /* get nth field */
{
if (n < 0)
@@ -415,7 +482,7 @@ void growfldtab(int n) /* make new field
if (n > nf)
nf = n;
s = (nf+1) * (sizeof (struct Cell *)); /* freebsd: how much do we need? */
- if (s / sizeof(struct Cell *) - 1 == nf) /* didn't overflow */
+ if (s / sizeof(struct Cell *) - 1 == (size_t)nf) /* didn't overflow */
fldtab = (Cell **) realloc(fldtab, s);
else /* overflow sizeof int */
xfree(fldtab); /* make it null */
@@ -445,7 +512,7 @@ int refldbld(const char *rec, const char
if (*rec == '\0')
return 0;
pfa = makedfa(fs, 1);
- dprintf( ("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs) );
+ DPRINTF("into refldbld, rec = <%s>, pat = <%s>\n", rec, fs);
tempstat = pfa->initstat;
for (i = 1; ; i++) {
if (i > nfields)
@@ -454,30 +521,31 @@ int refldbld(const char *rec, const char
xfree(fldtab[i]->sval);
fldtab[i]->tval = FLD | STR | DONTFREE;
fldtab[i]->sval = fr;
- dprintf( ("refldbld: i=%d\n", i) );
+ DPRINTF("refldbld: i=%d\n", i);
if (nematch(pfa, rec)) {
pfa->initstat = 2; /* horrible coupling to b.c */
- dprintf( ("match %s (%d chars)\n", patbeg, patlen) );
+ DPRINTF("match %s (%d chars)\n", patbeg, patlen);
strncpy(fr, rec, patbeg-rec);
fr += patbeg - rec + 1;
*(fr-1) = '\0';
rec = patbeg + patlen;
} else {
- dprintf( ("no match %s\n", rec) );
+ DPRINTF("no match %s\n", rec);
strcpy(fr, rec);
pfa->initstat = tempstat;
break;
}
}
- return i;
+ return i;
}
void recbld(void) /* create $0 from $1..$NF if necessary */
{
int i;
char *r, *p;
+ char *sep = getsval(ofsloc);
- if (donerec == 1)
+ if (donerec)
return;
r = record;
for (i = 1; i <= *NF; i++) {
@@ -487,25 +555,25 @@ void recbld(void) /* create $0 from $1..
while ((*r = *p++) != 0)
r++;
if (i < *NF) {
- if (!adjbuf(&record, &recsize, 2+strlen(*OFS)+r-record, recsize, &r, "recbld 2"))
+ if (!adjbuf(&record, &recsize, 2+strlen(sep)+r-record, recsize, &r, "recbld 2"))
FATAL("created $0 `%.30s...' too long", record);
- for (p = *OFS; (*r = *p++) != 0; )
+ for (p = sep; (*r = *p++) != 0; )
r++;
}
}
if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3"))
FATAL("built giant record `%.30s...'", record);
*r = '\0';
- dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) );
+ DPRINTF("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]);
if (freeable(fldtab[0]))
xfree(fldtab[0]->sval);
fldtab[0]->tval = REC | STR | DONTFREE;
fldtab[0]->sval = record;
- dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) );
- dprintf( ("recbld = |%s|\n", record) );
- donerec = 1;
+ DPRINTF("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]);
+ DPRINTF("recbld = |%s|\n", record);
+ donerec = true;
}
int errorflag = 0;
@@ -530,18 +598,13 @@ void SYNTAX(const char *fmt, ...)
fprintf(stderr, " at source line %d", lineno);
if (curfname != NULL)
fprintf(stderr, " in function %s", curfname);
- if (compile_time == 1 && cursource() != NULL)
+ if (compile_time == COMPILING && cursource() != NULL)
fprintf(stderr, " source file %s", cursource());
fprintf(stderr, "\n");
errorflag = 2;
eprint();
}
-void fpecatch(int n)
-{
- FATAL("floating point exception %d", n);
-}
-
extern int bracecnt, brackcnt, parencnt;
void bracecheck(void)
@@ -604,20 +667,22 @@ void error()
extern Node *curnode;
fprintf(stderr, "\n");
- if (compile_time != 2 && NR && *NR > 0) {
- fprintf(stderr, " input record number %d", (int) (*FNR));
- if (strcmp(*FILENAME, "-") != 0)
- fprintf(stderr, ", file %s", *FILENAME);
+ if (compile_time != ERROR_PRINTING) {
+ if (NR && *NR > 0) {
+ fprintf(stderr, " input record number %d", (int) (*FNR));
+ if (strcmp(*FILENAME, "-") != 0)
+ fprintf(stderr, ", file %s", *FILENAME);
+ fprintf(stderr, "\n");
+ }
+ if (curnode)
+ fprintf(stderr, " source line number %d", curnode->lineno);
+ else if (lineno)
+ fprintf(stderr, " source line number %d", lineno);
+ if (compile_time == COMPILING && cursource() != NULL)
+ fprintf(stderr, " source file %s", cursource());
fprintf(stderr, "\n");
+ eprint();
}
- if (compile_time != 2 && curnode)
- fprintf(stderr, " source line number %d", curnode->lineno);
- else if (compile_time != 2 && lineno)
- fprintf(stderr, " source line number %d", lineno);
- if (compile_time == 1 && cursource() != NULL)
- fprintf(stderr, " source file %s", cursource());
- fprintf(stderr, "\n");
- eprint();
}
void eprint(void) /* try to print context around error */
@@ -627,7 +692,9 @@ void eprint(void) /* try to print contex
static int been_here = 0;
extern char ebuf[], *ep;
- if (compile_time == 2 || compile_time == 0 || been_here++ > 0)
+ if (compile_time != COMPILING || been_here++ > 0 || ebuf == ep)
+ return;
+ if (ebuf == ep)
return;
p = ep - 1;
if (p > ebuf && *p == '\n')
@@ -692,26 +759,82 @@ int isclvar(const char *s) /* is s of fo
for ( ; *s; s++)
if (!(isalnum((uschar) *s) || *s == '_'))
break;
- return *s == '=' && s > os && *(s+1) != '=';
+ return *s == '=' && s > os;
}
/* strtod is supposed to be a proper test of what's a valid number */
/* appears to be broken in gcc on linux: thinks 0x123 is a valid FP number */
/* wrong: violates 4.10.1.4 of ansi C standard */
-#include <math.h>
-int is_number(const char *s)
+/* well, not quite. As of C99, hex floating point is allowed. so this is
+ * a bit of a mess. We work around the mess by checking for a hexadecimal
+ * value and disallowing it. Similarly, we now follow gawk and allow only
+ * +nan, -nan, +inf, and -inf for NaN and infinity values.
+ */
+
+/*
+ * This routine now has a more complicated interface, the main point
+ * being to avoid the double conversion of a string to double, and
+ * also to convey out, if requested, the information that the numeric
+ * value was a leading string or is all of the string. The latter bit
+ * is used in getfval().
+ */
+
+bool is_valid_number(const char *s, bool trailing_stuff_ok,
+ bool *no_trailing, double *result)
{
double r;
char *ep;
+ bool retval = false;
+ bool is_nan = false;
+ bool is_inf = false;
+
+ if (no_trailing)
+ *no_trailing = false;
+
+ while (isspace(*s))
+ s++;
+
+ // no hex floating point, sorry
+ if (s[0] == '0' && tolower(s[1]) == 'x')
+ return false;
+
+ // allow +nan, -nan, +inf, -inf, any other letter, no
+ if (s[0] == '+' || s[0] == '-') {
+ is_nan = (strncasecmp(s+1, "nan", 3) == 0);
+ is_inf = (strncasecmp(s+1, "inf", 3) == 0);
+ if ((is_nan || is_inf)
+ && (isspace(s[4]) || s[4] == '\0'))
+ goto convert;
+ else if (! isdigit(s[1]) && s[1] != '.')
+ return false;
+ }
+ else if (! isdigit(s[0]) && s[0] != '.')
+ return false;
+
+convert:
errno = 0;
r = strtod(s, &ep);
- if (ep == s || r == HUGE_VAL || errno == ERANGE)
- return 0;
- while (*ep == ' ' || *ep == '\t' || *ep == '\n')
+ if (ep == s || errno == ERANGE)
+ return false;
+
+ if (isnan(r) && s[0] == '-' && signbit(r) == 0)
+ r = -r;
+
+ if (result != NULL)
+ *result = r;
+
+ /*
+ * check for trailing stuff
+ */
+ while (isspace(*ep))
ep++;
- if (*ep == '\0')
- return 1;
- else
- return 0;
+
+ if (no_trailing != NULL)
+ *no_trailing = (*ep == '\0');
+
+ // return true if found the end, or trailing stuff is allowed
+ retval = *ep == '\0' || trailing_stuff_ok;
+
+ return retval;
}
Index: pkgsrc/lang/nawk/files/proto.h
diff -u pkgsrc/lang/nawk/files/proto.h:1.4 pkgsrc/lang/nawk/files/proto.h:1.5
--- pkgsrc/lang/nawk/files/proto.h:1.4 Thu Dec 17 21:27:53 2015
+++ pkgsrc/lang/nawk/files/proto.h Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: proto.h,v 1.4 2015/12/17 21:27:53 dholland Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -24,12 +22,6 @@ ARISING OUT OF OR IN CONNECTION WITH THE
THIS SOFTWARE.
****************************************************************/
-#if defined(__CLANG__) || defined(__GNUC__)
-#define DEAD __attribute__((__noreturn__))
-#else
-#define DEAD
-#endif
-
extern int yywrap(void);
extern void setfname(Cell *);
extern int constnode(Node *);
@@ -46,15 +38,15 @@ extern int yylook(void);
extern int yyback(int *, int);
extern int yyinput(void);
-extern fa *makedfa(const char *, int);
-extern fa *mkdfa(const char *, int);
-extern int makeinit(fa *, int);
+extern fa *makedfa(const char *, bool);
+extern fa *mkdfa(const char *, bool);
+extern int makeinit(fa *, bool);
extern void penter(Node *);
extern void freetr(Node *);
-extern int hexstr(uschar **);
-extern int quoted(uschar **);
+extern int hexstr(const uschar **);
+extern int quoted(const uschar **);
extern char *cclenter(const char *);
-extern DEAD void overflo(const char *);
+extern noreturn void overflo(const char *);
extern void cfoll(fa *, Node *);
extern int first(Node *);
extern void follow(Node *);
@@ -62,6 +54,7 @@ extern int member(int, const char *);
extern int match(fa *, const char *);
extern int pmatch(fa *, const char *);
extern int nematch(fa *, const char *);
+extern bool fnematch(fa *, FILE *, char **, int *, int);
extern Node *reparse(const char *);
extern Node *regexp(void);
extern Node *primary(void);
@@ -96,7 +89,7 @@ extern Node *pa2stat(Node *, Node *, Nod
extern Node *linkum(Node *, Node *);
extern void defn(Cell *, Node *, Node *);
extern int isarg(const char *);
-extern char *tokname(int);
+extern const char *tokname(int);
extern Cell *(*proctab[])(Node **, int);
extern int ptoi(void *);
extern Node *itonp(int);
@@ -118,36 +111,44 @@ extern double getfval(Cell *);
extern char *getsval(Cell *);
extern char *getpssval(Cell *); /* for print */
extern char *tostring(const char *);
+extern char *tostringN(const char *, size_t);
extern char *qstring(const char *, int);
+extern Cell *catstr(Cell *, Cell *);
extern void recinit(unsigned int);
extern void initgetrec(void);
extern void makefields(int, int);
extern void growfldtab(int n);
-extern int getrec(char **, int *, int);
+extern void savefs(void);
+extern int getrec(char **, int *, bool);
extern void nextfile(void);
-extern int readrec(char **buf, int *bufsize, FILE *inf);
+extern int readrec(char **buf, int *bufsize, FILE *inf, bool isnew);
extern char *getargv(int);
extern void setclvar(char *);
extern void fldbld(void);
extern void cleanfld(int, int);
extern void newfld(int);
+extern void setlastfld(int);
extern int refldbld(const char *, const char *);
extern void recbld(void);
extern Cell *fieldadr(int);
extern void yyerror(const char *);
-extern void fpecatch(int);
extern void bracecheck(void);
extern void bcheck2(int, int, int);
-extern void SYNTAX(const char *, ...);
-extern DEAD void FATAL(const char *, ...);
-extern void WARNING(const char *, ...);
+extern void SYNTAX(const char *, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
+extern noreturn void FATAL(const char *, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
+extern void WARNING(const char *, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
extern void error(void);
extern void eprint(void);
extern void bclass(int);
extern double errcheck(double, const char *);
extern int isclvar(const char *);
-extern int is_number(const char *);
+extern bool is_valid_number(const char *s, bool trailing_stuff_ok,
+ bool *no_trailing, double *result);
+#define is_number(s, val) is_valid_number(s, false, NULL, val)
extern int adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
extern void run(Node *);
@@ -192,7 +193,7 @@ extern Cell *bltin(Node **, int);
extern Cell *printstat(Node **, int);
extern Cell *nullproc(Node **, int);
extern FILE *redirect(int, Node *);
-extern FILE *openfile(int, const char *);
+extern FILE *openfile(int, const char *, bool *);
extern const char *filename(FILE *);
extern Cell *closefile(Node **, int);
extern void closeall(void);
@@ -201,3 +202,5 @@ extern Cell *gsub(Node **, int);
extern FILE *popen(const char *, const char *);
extern int pclose(FILE *);
+
+extern const char *flags2str(int flags);
Index: pkgsrc/lang/nawk/files/tran.c
diff -u pkgsrc/lang/nawk/files/tran.c:1.4 pkgsrc/lang/nawk/files/tran.c:1.5
--- pkgsrc/lang/nawk/files/tran.c:1.4 Wed Mar 12 14:20:43 2014
+++ pkgsrc/lang/nawk/files/tran.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: tran.c,v 1.4 2014/03/12 14:20:43 ryoon Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -31,7 +29,6 @@ THIS SOFTWARE.
#include <string.h>
#include <stdlib.h>
#include "awk.h"
-#include "ytab.h"
#define FULLTAB 2 /* rehash when table gets this x full */
#define GROWTAB 4 /* grow table by this factor */
@@ -57,10 +54,14 @@ Cell *fsloc; /* FS */
Cell *nrloc; /* NR */
Cell *nfloc; /* NF */
Cell *fnrloc; /* FNR */
+Cell *ofsloc; /* OFS */
+Cell *orsloc; /* ORS */
+Cell *rsloc; /* RS */
Array *ARGVtab; /* symbol table containing ARGV[...] */
Array *ENVtab; /* symbol table containing ENVIRON[...] */
Cell *rstartloc; /* RSTART */
Cell *rlengthloc; /* RLENGTH */
+Cell *subseploc; /* SUBSEP */
Cell *symtabloc; /* SYMTAB */
Cell *nullloc; /* a guaranteed empty cell */
@@ -69,6 +70,18 @@ Cell *literal0;
extern Cell **fldtab;
+static void
+setfree(Cell *vp)
+{
+ if (&vp->sval == FS || &vp->sval == RS ||
+ &vp->sval == OFS || &vp->sval == ORS ||
+ &vp->sval == OFMT || &vp->sval == CONVFMT ||
+ &vp->sval == FILENAME || &vp->sval == SUBSEP)
+ vp->tval |= DONTFREE;
+ else
+ vp->tval &= ~DONTFREE;
+}
+
void syminit(void) /* initialize symbol table with builtin vars */
{
literal0 = setsymtab("0", "0", 0.0, NUM|STR|CON|DONTFREE, symtab);
@@ -78,9 +91,12 @@ void syminit(void) /* initialize symbol
fsloc = setsymtab("FS", " ", 0.0, STR|DONTFREE, symtab);
FS = &fsloc->sval;
- RS = &setsymtab("RS", "\n", 0.0, STR|DONTFREE, symtab)->sval;
- OFS = &setsymtab("OFS", " ", 0.0, STR|DONTFREE, symtab)->sval;
- ORS = &setsymtab("ORS", "\n", 0.0, STR|DONTFREE, symtab)->sval;
+ rsloc = setsymtab("RS", "\n", 0.0, STR|DONTFREE, symtab);
+ RS = &rsloc->sval;
+ ofsloc = setsymtab("OFS", " ", 0.0, STR|DONTFREE, symtab);
+ OFS = &ofsloc->sval;
+ orsloc = setsymtab("ORS", "\n", 0.0, STR|DONTFREE, symtab);
+ ORS = &orsloc->sval;
OFMT = &setsymtab("OFMT", "%.6g", 0.0, STR|DONTFREE, symtab)->sval;
CONVFMT = &setsymtab("CONVFMT", "%.6g", 0.0, STR|DONTFREE, symtab)->sval;
FILENAME = &setsymtab("FILENAME", "", 0.0, STR|DONTFREE, symtab)->sval;
@@ -90,12 +106,14 @@ void syminit(void) /* initialize symbol
NR = &nrloc->fval;
fnrloc = setsymtab("FNR", "", 0.0, NUM, symtab);
FNR = &fnrloc->fval;
- SUBSEP = &setsymtab("SUBSEP", "\034", 0.0, STR|DONTFREE, symtab)->sval;
+ subseploc = setsymtab("SUBSEP", "\034", 0.0, STR|DONTFREE, symtab);
+ SUBSEP = &subseploc->sval;
rstartloc = setsymtab("RSTART", "", 0.0, NUM, symtab);
RSTART = &rstartloc->fval;
rlengthloc = setsymtab("RLENGTH", "", 0.0, NUM, symtab);
RLENGTH = &rlengthloc->fval;
symtabloc = setsymtab("SYMTAB", "", 0.0, ARR, symtab);
+ free(symtabloc->sval);
symtabloc->sval = (char *) symtab;
}
@@ -108,11 +126,14 @@ void arginit(int ac, char **av) /* set u
ARGC = &setsymtab("ARGC", "", (Awkfloat) ac, NUM, symtab)->fval;
cp = setsymtab("ARGV", "", 0.0, ARR, symtab);
ARGVtab = makesymtab(NSYMTAB); /* could be (int) ARGC as well */
+ free(cp->sval);
cp->sval = (char *) ARGVtab;
for (i = 0; i < ac; i++) {
+ double result;
+
sprintf(temp, "%d", i);
- if (is_number(*av))
- setsymtab(temp, *av, atof(*av), STR|NUM, ARGVtab);
+ if (is_number(*av, & result))
+ setsymtab(temp, *av, result, STR|NUM, ARGVtab);
else
setsymtab(temp, *av, 0.0, STR, ARGVtab);
av++;
@@ -126,15 +147,18 @@ void envinit(char **envp) /* set up ENVI
cp = setsymtab("ENVIRON", "", 0.0, ARR, symtab);
ENVtab = makesymtab(NSYMTAB);
+ free(cp->sval);
cp->sval = (char *) ENVtab;
for ( ; *envp; envp++) {
+ double result;
+
if ((p = strchr(*envp, '=')) == NULL)
continue;
if( p == *envp ) /* no left hand side name in env string */
continue;
*p++ = 0; /* split into two strings at = */
- if (is_number(p))
- setsymtab(*envp, p, atof(p), STR|NUM, ENVtab);
+ if (is_number(p, & result))
+ setsymtab(*envp, p, result, STR|NUM, ENVtab);
else
setsymtab(*envp, p, 0.0, STR, ENVtab);
p[-1] = '='; /* restore in case env is passed down to a shell */
@@ -146,8 +170,8 @@ Array *makesymtab(int n) /* make a new s
Array *ap;
Cell **tp;
- ap = (Array *) malloc(sizeof(Array));
- tp = (Cell **) calloc(n, sizeof(Cell *));
+ ap = (Array *) malloc(sizeof(*ap));
+ tp = (Cell **) calloc(n, sizeof(*tp));
if (ap == NULL || tp == NULL)
FATAL("out of space in makesymtab");
ap->nelem = 0;
@@ -173,10 +197,10 @@ void freesymtab(Cell *ap) /* free a symb
if (freeable(cp))
xfree(cp->sval);
temp = cp->cnext; /* avoids freeing then using */
- free(cp);
+ free(cp);
tp->nelem--;
}
- tp->tab[i] = 0;
+ tp->tab[i] = NULL;
}
if (tp->nelem != 0)
WARNING("can't happen: inconsistent element count freeing %s", ap->nval);
@@ -189,7 +213,7 @@ void freeelem(Cell *ap, const char *s) /
Array *tp;
Cell *p, *prev = NULL;
int h;
-
+
tp = (Array *) ap->sval;
h = hash(s, tp->size);
for (p = tp->tab[h]; p != NULL; prev = p, p = p->cnext)
@@ -213,11 +237,11 @@ Cell *setsymtab(const char *n, const cha
Cell *p;
if (n != NULL && (p = lookup(n, tp)) != NULL) {
- dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n",
- (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval) );
+ DPRINTF("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n",
+ (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval);
return(p);
}
- p = (Cell *) malloc(sizeof(Cell));
+ p = (Cell *) malloc(sizeof(*p));
if (p == NULL)
FATAL("out of space for symbol table at %s", n);
p->nval = tostring(n);
@@ -232,8 +256,8 @@ Cell *setsymtab(const char *n, const cha
h = hash(n, tp->size);
p->cnext = tp->tab[h];
tp->tab[h] = p;
- dprintf( ("setsymtab set %p: n=%s s=\"%s\" f=%g t=%o\n",
- (void*)p, p->nval, p->sval, p->fval, p->tval) );
+ DPRINTF("setsymtab set %p: n=%s s=\"%s\" f=%g t=%o\n",
+ (void*)p, p->nval, p->sval, p->fval, p->tval);
return(p);
}
@@ -252,7 +276,7 @@ void rehash(Array *tp) /* rehash items i
Cell *cp, *op, **np;
nsz = GROWTAB * tp->size;
- np = (Cell **) calloc(nsz, sizeof(Cell *));
+ np = (Cell **) calloc(nsz, sizeof(*np));
if (np == NULL) /* can't do it, but can keep running. */
return; /* someone else will run out later. */
for (i = 0; i < tp->size; i++) {
@@ -284,25 +308,35 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /
{
int fldno;
- if ((vp->tval & (NUM | STR)) == 0)
+ f += 0.0; /* normalise negative zero to positive zero */
+ if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "assign to");
if (isfld(vp)) {
- donerec = 0; /* mark $0 invalid */
+ donerec = false; /* mark $0 invalid */
fldno = atoi(vp->nval);
if (fldno > *NF)
newfld(fldno);
- dprintf( ("setting field %d to %g\n", fldno, f) );
+ DPRINTF("setting field %d to %g\n", fldno, f);
+ } else if (&vp->fval == NF) {
+ donerec = false; /* mark $0 invalid */
+ setlastfld(f);
+ DPRINTF("setting NF to %g\n", f);
} else if (isrec(vp)) {
- donefld = 0; /* mark $1... invalid */
- donerec = 1;
+ donefld = false; /* mark $1... invalid */
+ donerec = true;
+ savefs();
+ } else if (vp == ofsloc) {
+ if (!donerec)
+ recbld();
}
if (freeable(vp))
xfree(vp->sval); /* free any previous string */
- vp->tval &= ~STR; /* mark string invalid */
+ vp->tval &= ~(STR|CONVC|CONVO); /* mark string invalid */
+ vp->fmt = NULL;
vp->tval |= NUM; /* mark number ok */
if (f == -0) /* who would have thought this possible? */
f = 0;
- dprintf( ("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval) );
+ DPRINTF("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval);
return vp->fval = f;
}
@@ -313,81 +347,175 @@ void funnyvar(Cell *vp, const char *rw)
if (vp->tval & FCN)
FATAL("can't %s %s; it's a function.", rw, vp->nval);
WARNING("funny variable %p: n=%s s=\"%s\" f=%g t=%o",
- vp, vp->nval, vp->sval, vp->fval, vp->tval);
+ (void *)vp, vp->nval, vp->sval, vp->fval, vp->tval);
}
char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
{
char *t;
int fldno;
+ Awkfloat f;
- dprintf( ("starting setsval %p: %s = \"%s\", t=%o, r,f=%d,%d\n",
- (void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld) );
+ DPRINTF("starting setsval %p: %s = \"%s\", t=%o, r,f=%d,%d\n",
+ (void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld);
if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "assign to");
if (isfld(vp)) {
- donerec = 0; /* mark $0 invalid */
+ donerec = false; /* mark $0 invalid */
fldno = atoi(vp->nval);
if (fldno > *NF)
newfld(fldno);
- dprintf( ("setting field %d to %s (%p)\n", fldno, s, s) );
+ DPRINTF("setting field %d to %s (%p)\n", fldno, s, (const void*)s);
} else if (isrec(vp)) {
- donefld = 0; /* mark $1... invalid */
- donerec = 1;
+ donefld = false; /* mark $1... invalid */
+ donerec = true;
+ savefs();
+ } else if (vp == ofsloc) {
+ if (!donerec)
+ recbld();
}
- t = tostring(s); /* in case it's self-assign */
+ t = s ? tostring(s) : tostring(""); /* in case it's self-assign */
if (freeable(vp))
xfree(vp->sval);
- vp->tval &= ~NUM;
+ vp->tval &= ~(NUM|CONVC|CONVO);
vp->tval |= STR;
- vp->tval &= ~DONTFREE;
- dprintf( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
- (void*)vp, NN(vp->nval), t,t, vp->tval, donerec, donefld) );
- return(vp->sval = t);
+ vp->fmt = NULL;
+ setfree(vp);
+ DPRINTF("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
+ (void*)vp, NN(vp->nval), t, (void*)t, vp->tval, donerec, donefld);
+ vp->sval = t;
+ if (&vp->fval == NF) {
+ donerec = false; /* mark $0 invalid */
+ f = getfval(vp);
+ setlastfld(f);
+ DPRINTF("setting NF to %g\n", f);
+ }
+
+ return(vp->sval);
}
Awkfloat getfval(Cell *vp) /* get float val of a Cell */
{
if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "read value of");
- if (isfld(vp) && donefld == 0)
+ if (isfld(vp) && !donefld)
fldbld();
- else if (isrec(vp) && donerec == 0)
+ else if (isrec(vp) && !donerec)
recbld();
if (!isnum(vp)) { /* not a number */
- vp->fval = atof(vp->sval); /* best guess */
- if (is_number(vp->sval) && !(vp->tval&CON))
- vp->tval |= NUM; /* make NUM only sparingly */
+ double fval;
+ bool no_trailing;
+
+ if (is_valid_number(vp->sval, true, & no_trailing, & fval)) {
+ vp->fval = fval;
+ if (no_trailing && !(vp->tval&CON))
+ vp->tval |= NUM; /* make NUM only sparingly */
+ } else
+ vp->fval = 0.0;
}
- dprintf( ("getfval %p: %s = %g, t=%o\n",
- (void*)vp, NN(vp->nval), vp->fval, vp->tval) );
+ DPRINTF("getfval %p: %s = %g, t=%o\n",
+ (void*)vp, NN(vp->nval), vp->fval, vp->tval);
return(vp->fval);
}
+static const char *get_inf_nan(double d)
+{
+ if (isinf(d)) {
+ return (d < 0 ? "-inf" : "+inf");
+ } else if (isnan(d)) {
+ return (signbit(d) != 0 ? "-nan" : "+nan");
+ } else
+ return NULL;
+}
+
static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */
{
- char s[100]; /* BUG: unchecked */
+ char s[256];
double dtemp;
+ const char *p;
if ((vp->tval & (NUM | STR)) == 0)
funnyvar(vp, "read value of");
- if (isfld(vp) && donefld == 0)
+ if (isfld(vp) && ! donefld)
fldbld();
- else if (isrec(vp) && donerec == 0)
+ else if (isrec(vp) && ! donerec)
recbld();
+
+ /*
+ * ADR: This is complicated and more fragile than is desirable.
+ * Retrieving a string value for a number associates the string
+ * value with the scalar. Previously, the string value was
+ * sticky, meaning if converted via OFMT that became the value
+ * (even though POSIX wants it to be via CONVFMT). Or if CONVFMT
+ * changed after a string value was retrieved, the original value
+ * was maintained and used. Also not per POSIX.
+ *
+ * We work around this design by adding two additional flags,
+ * CONVC and CONVO, indicating how the string value was
+ * obtained (via CONVFMT or OFMT) and _also_ maintaining a copy
+ * of the pointer to the xFMT format string used for the
+ * conversion. This pointer is only read, **never** dereferenced.
+ * The next time we do a conversion, if it's coming from the same
+ * xFMT as last time, and the pointer value is different, we
+ * know that the xFMT format string changed, and we need to
+ * redo the conversion. If it's the same, we don't have to.
+ *
+ * There are also several cases where we don't do a conversion,
+ * such as for a field (see the checks below).
+ */
+
+ /* Don't duplicate the code for actually updating the value */
+#define update_str_val(vp) \
+ { \
+ if (freeable(vp)) \
+ xfree(vp->sval); \
+ if ((p = get_inf_nan(vp->fval)) != NULL) \
+ strcpy(s, p); \
+ else if (modf(vp->fval, &dtemp) == 0) /* it's integral */ \
+ snprintf(s, sizeof (s), "%.30g", vp->fval); \
+ else \
+ snprintf(s, sizeof (s), *fmt, vp->fval); \
+ vp->sval = tostring(s); \
+ vp->tval &= ~DONTFREE; \
+ vp->tval |= STR; \
+ }
+
if (isstr(vp) == 0) {
- if (freeable(vp))
- xfree(vp->sval);
- if (modf(vp->fval, &dtemp) == 0) /* it's integral */
- sprintf(s, "%.30g", vp->fval);
- else
- sprintf(s, *fmt, vp->fval);
- vp->sval = tostring(s);
- vp->tval &= ~DONTFREE;
- vp->tval |= STR;
+ update_str_val(vp);
+ if (fmt == OFMT) {
+ vp->tval &= ~CONVC;
+ vp->tval |= CONVO;
+ } else {
+ /* CONVFMT */
+ vp->tval &= ~CONVO;
+ vp->tval |= CONVC;
+ }
+ vp->fmt = *fmt;
+ } else if ((vp->tval & DONTFREE) != 0 || ! isnum(vp) || isfld(vp)) {
+ goto done;
+ } else if (isstr(vp)) {
+ if (fmt == OFMT) {
+ if ((vp->tval & CONVC) != 0
+ || ((vp->tval & CONVO) != 0 && vp->fmt != *fmt)) {
+ update_str_val(vp);
+ vp->tval &= ~CONVC;
+ vp->tval |= CONVO;
+ vp->fmt = *fmt;
+ }
+ } else {
+ /* CONVFMT */
+ if ((vp->tval & CONVO) != 0
+ || ((vp->tval & CONVC) != 0 && vp->fmt != *fmt)) {
+ update_str_val(vp);
+ vp->tval &= ~CONVO;
+ vp->tval |= CONVC;
+ vp->fmt = *fmt;
+ }
+ }
}
- dprintf( ("getsval %p: %s = \"%s (%p)\", t=%o\n",
- (void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
+done:
+ DPRINTF("getsval %p: %s = \"%s (%p)\", t=%o\n",
+ (void*)vp, NN(vp->nval), vp->sval, (void*)vp->sval, vp->tval);
return(vp->sval);
}
@@ -404,22 +532,53 @@ char *getpssval(Cell *vp) /* get str
char *tostring(const char *s) /* make a copy of string s */
{
- size_t len;
+ char *p = strdup(s);
+ if (p == NULL)
+ FATAL("out of space in tostring on %s", s);
+ return(p);
+}
+
+char *tostringN(const char *s, size_t n) /* make a copy of string s */
+{
char *p;
- len = strlen(s) + 1;
- p = (char *) malloc(len);
+ p = (char *) malloc(n);
if (p == NULL)
FATAL("out of space in tostring on %s", s);
- memcpy(p, s, len);
+ strcpy(p, s);
return(p);
}
+Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */
+{
+ Cell *c;
+ char *p;
+ char *sa = getsval(a);
+ char *sb = getsval(b);
+ size_t l = strlen(sa) + strlen(sb) + 1;
+ p = (char *) malloc(l);
+ if (p == NULL)
+ FATAL("out of space concatenating %s and %s", sa, sb);
+ snprintf(p, l, "%s%s", sa, sb);
+
+ l++; // add room for ' '
+ char *newbuf = (char *) malloc(l);
+ if (newbuf == NULL)
+ FATAL("out of space concatenating %s and %s", sa, sb);
+ // See string() in lex.c; a string "xx" is stored in the symbol
+ // table as "xx ".
+ snprintf(newbuf, l, "%s ", p);
+ c = setsymtab(newbuf, p, 0.0, CON|STR|DONTFREE, symtab);
+ free(p);
+ free(newbuf);
+ return c;
+}
+
char *qstring(const char *is, int delim) /* collect string up to next delim */
{
const char *os = is;
int c, n;
- uschar *s = (uschar *) is;
+ const uschar *s = (const uschar *) is;
uschar *buf, *bp;
if ((buf = (uschar *) malloc(strlen(is)+3)) == NULL)
@@ -434,7 +593,7 @@ char *qstring(const char *is, int delim)
if (c == 0) { /* \ at end */
*bp++ = '\\';
break; /* for loop */
- }
+ }
switch (c) {
case '\\': *bp++ = '\\'; break;
case 'n': *bp++ = '\n'; break;
@@ -442,6 +601,8 @@ char *qstring(const char *is, int delim)
case 'b': *bp++ = '\b'; break;
case 'f': *bp++ = '\f'; break;
case 'r': *bp++ = '\r'; break;
+ case 'v': *bp++ = '\v'; break;
+ case 'a': *bp++ = '\a'; break;
default:
if (!isdigit(c)) {
*bp++ = c;
@@ -461,3 +622,37 @@ char *qstring(const char *is, int delim)
*bp++ = 0;
return (char *) buf;
}
+
+const char *flags2str(int flags)
+{
+ static const struct ftab {
+ const char *name;
+ int value;
+ } flagtab[] = {
+ { "NUM", NUM },
+ { "STR", STR },
+ { "DONTFREE", DONTFREE },
+ { "CON", CON },
+ { "ARR", ARR },
+ { "FCN", FCN },
+ { "FLD", FLD },
+ { "REC", REC },
+ { "CONVC", CONVC },
+ { "CONVO", CONVO },
+ { NULL, 0 }
+ };
+ static char buf[100];
+ int i;
+ char *cp = buf;
+
+ for (i = 0; flagtab[i].name != NULL; i++) {
+ if ((flags & flagtab[i].value) != 0) {
+ if (cp > buf)
+ *cp++ = '|';
+ strcpy(cp, flagtab[i].name);
+ cp += strlen(cp);
+ }
+ }
+
+ return buf;
+}
Index: pkgsrc/lang/nawk/files/nawk.1
diff -u pkgsrc/lang/nawk/files/nawk.1:1.1 pkgsrc/lang/nawk/files/nawk.1:1.2
--- pkgsrc/lang/nawk/files/nawk.1:1.1 Fri Jul 14 14:23:06 2006
+++ pkgsrc/lang/nawk/files/nawk.1 Fri Feb 24 20:57:50 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: nawk.1,v 1.1 2006/07/14 14:23:06 jlam Exp $
+.\" $NetBSD: nawk.1,v 1.2 2023/02/24 20:57:50 vins Exp $
.\"
.\" This file is copied from awk.1 but with the following modifications
.\" for pkgsrc:
@@ -16,7 +16,10 @@
.fi
.ft 1
..
-nawk
+.de TF
+.IP "" "\w'\fB\\$1\ \ \fP'u"
+.PD 0
+..
.TH NAWK 1
.CT 1 files prog_other
.SH NAME
@@ -45,7 +48,7 @@ nawk \- pattern-directed scanning and pr
scans each input
.I file
for lines that match any of a set of patterns specified literally in
-.IR prog
+.I prog
or in one or more files
specified as
.B \-f
@@ -58,11 +61,11 @@ matches the pattern.
Each line is matched against the
pattern portion of every pattern-action statement;
the associated action is performed for each matched pattern.
-The file name
+The file name
.B \-
means the standard input.
Any
-.IR file
+.I file
of the form
.I var=value
is treated as an assignment, not a filename,
@@ -79,12 +82,12 @@ any number of
options may be present.
The
.B \-F
-.IR fs
+.I fs
option defines the input field separator to be the regular expression
-.IR fs.
+.IR fs .
.PP
An input line is normally made up of fields separated by white space,
-or by regular expression
+or by the regular expression
.BR FS .
The fields are denoted
.BR $1 ,
@@ -96,11 +99,11 @@ If
.BR FS
is null, the input line is split into one field per character.
.PP
-A pattern-action statement has the form
+A pattern-action statement has the form:
.IP
.IB pattern " { " action " }
.PP
-A missing
+A missing
.BI { " action " }
means print the line;
a missing pattern always matches.
@@ -110,7 +113,7 @@ An action is a sequence of statements.
A statement can be one of the following:
.PP
.EX
-.ta \w'\f(CWdelete array[expression]'u
+.ta \w'\f(CWdelete array[expression]\fR'u
.RS
.nf
.ft CW
@@ -154,7 +157,7 @@ The operators
are also available in expressions.
Variables may be scalars, array elements
(denoted
-.IB x [ i ] )
+.IB x [ i ] \fR)
or fields.
Variables are initialized to the null string.
Array subscripts may be any string,
@@ -170,11 +173,11 @@ The
.B print
statement prints its arguments on the standard output
(or on a file if
-.BI > file
+.BI > " file
or
-.BI >> file
+.BI >> " file
is present or on a pipe if
-.BI | cmd
+.BI | " cmd
is present), separated by the current output field separator,
and terminated by the output record separator.
.I file
@@ -185,9 +188,10 @@ identical string values in different sta
the same open file.
The
.B printf
-statement formats its expression list according to the format
+statement formats its expression list according to the
+.I format
(see
-.IR printf (3)) .
+.IR printf (3)).
The built-in function
.BI close( expr )
closes the file or pipe
@@ -198,13 +202,13 @@ flushes any buffered output for the file
.IR expr .
.PP
The mathematical functions
+.BR atan2 ,
+.BR cos ,
.BR exp ,
.BR log ,
-.BR sqrt ,
.BR sin ,
-.BR cos ,
and
-.BR atan2
+.B sqrt
are built in.
Other built-in functions:
.TF length
@@ -212,12 +216,13 @@ Other built-in functions:
.B length
the length of its argument
taken as a string,
-or of
+number of elements in an array for an array argument,
+or length of
.B $0
if no argument.
.TP
.B rand
-random number on (0,1)
+random number on [0,1).
.TP
.B srand
sets seed for
@@ -225,16 +230,19 @@ sets seed for
and returns the previous seed.
.TP
.B int
-truncates to an integer value
+truncates to an integer value.
.TP
-.BI substr( s , " m" , " n\fB)
+\fBsubstr(\fIs\fB, \fIm\fR [\fB, \fIn\^\fR]\fB)\fR
the
.IR n -character
substring of
.I s
that begins at position
-.IR m
+.I m
counted from 1.
+If no
+.IR n ,
+use the rest of the string.
.TP
.BI index( s , " t" )
the position in
@@ -255,14 +263,14 @@ and
.B RLENGTH
are set to the position and length of the matched string.
.TP
-.BI split( s , " a" , " fs\fB)
+\fBsplit(\fIs\fB, \fIa \fR[\fB, \fIfs\^\fR]\fB)\fR
splits the string
.I s
into array elements
-.IB a [1] ,
-.IB a [2] ,
+.IB a [1] \fR,
+.IB a [2] \fR,
\&...,
-.IB a [ n ] ,
+.IB a [ n ] \fR,
and returns
.IR n .
The separation is done with the regular expression
@@ -275,7 +283,7 @@ is not given.
An empty string as field separator splits the string
into one array element per character.
.TP
-.BI sub( r , " t" , " s\fB)
+\fBsub(\fIr\fB, \fIt \fR[, \fIs\^\fR]\fB)
substitutes
.I t
for the first occurrence of the regular expression
@@ -288,7 +296,7 @@ is not given,
.B $0
is used.
.TP
-.B gsub
+\fBgsub(\fIr\fB, \fIt \fR[, \fIs\^\fR]\fB)
same as
.B sub
except that all occurrences of the regular expression
@@ -298,18 +306,28 @@ and
.B gsub
return the number of replacements.
.TP
-.BI sprintf( fmt , " expr" , " ...\fB )
+.BI sprintf( fmt , " expr" , " ...\fB)
the string resulting from formatting
.I expr ...
according to the
.IR printf (3)
format
-.I fmt
+.IR fmt .
.TP
.BI system( cmd )
executes
.I cmd
-and returns its exit status
+and returns its exit status. This will be \-1 upon error,
+.IR cmd 's
+exit status upon a normal exit,
+256 +
+.I sig
+upon death-by-signal, where
+.I sig
+is the number of the murdering signal,
+or 512 +
+.I sig
+if there was a core dump.
.TP
.BI tolower( str )
returns a copy of
@@ -330,7 +348,7 @@ sets
.B $0
to the next input record from the current input file;
.B getline
-.BI < file
+.BI < " file
sets
.B $0
to the next record from
@@ -361,14 +379,14 @@ Patterns are arbitrary Boolean combinati
of regular expressions and
relational expressions.
Regular expressions are as in
-.IR egrep ;
+.IR egrep ;
see
.IR grep (1).
Isolated regular expressions
in a pattern apply to the entire line.
Regular expressions may also occur in
relational expressions, using the operators
-.BR ~
+.B ~
and
.BR !~ .
.BI / re /
@@ -392,8 +410,12 @@ A relational expression is one of the fo
.br
.BI ( expr , expr,... ") in " array-name
.PP
-where a relop is any of the six relational operators in C,
-and a matchop is either
+where a
+.I relop
+is any of the six relational operators in C,
+and a
+.I matchop
+is either
.B ~
(matches)
or
@@ -414,57 +436,73 @@ and after the last.
and
.B END
do not combine with other patterns.
+They may appear multiple times in a program and execute
+in the order they are read by
+.IR nawk .
.PP
Variable names with special meanings:
.TF FILENAME
.TP
+.B ARGC
+argument count, assignable.
+.TP
+.B ARGV
+argument array, assignable;
+non-null members are taken as filenames.
+.TP
.B CONVFMT
conversion format used when converting numbers
(default
-.BR "%.6g" )
+.BR "%.6g" ).
+.TP
+.B ENVIRON
+array of environment variables; subscripts are names.
+.TP
+.B FILENAME
+the name of the current input file.
+.TP
+.B FNR
+ordinal number of the current record in the current file.
.TP
.B FS
regular expression used to separate fields; also settable
by option
-.BI \-F fs.
+.BI \-F fs\fR.
.TP
.BR NF
-number of fields in the current record
+number of fields in the current record.
.TP
.B NR
-ordinal number of the current record
-.TP
-.B FNR
-ordinal number of the current record in the current file
-.TP
-.B FILENAME
-the name of the current input file
+ordinal number of the current record.
.TP
-.B RS
-input record separator (default newline)
+.B OFMT
+output format for numbers (default
+.BR "%.6g" ).
.TP
.B OFS
-output field separator (default blank)
+output field separator (default space).
.TP
.B ORS
-output record separator (default newline)
+output record separator (default newline).
.TP
-.B OFMT
-output format for numbers (default
-.BR "%.6g" )
-.TP
-.B SUBSEP
-separates multiple subscripts (default 034)
+.B RLENGTH
+the length of a string matched by
+.BR match .
.TP
-.B ARGC
-argument count, assignable
+.B RS
+input record separator (default newline).
+If empty, blank lines separate records.
+If more than one character long,
+.B RS
+is treated as a regular expression, and records are
+separated by text matching the expression.
.TP
-.B ARGV
-argument array, assignable;
-non-null members are taken as filenames
+.B RSTART
+the start position of a string matched by
+.BR match .
.TP
-.B ENVIRON
-array of environment variables; subscripts are names.
+.B SUBSEP
+separates multiple subscripts (default 034).
.PD
.PP
Functions may be defined (at the position of a pattern-action statement) thus:
@@ -477,6 +515,16 @@ functions may be called recursively.
Parameters are local to the function; all other variables are global.
Thus local variables may be created by providing excess parameters in
the function definition.
+.SH ENVIRONMENT VARIABLES
+If
+.B POSIXLY_CORRECT
+is set in the environment, then
+.I nawk
+follows the POSIX rules for
+.B sub
+and
+.B gsub
+with respect to consecutive backslashes and ampersands.
.SH EXAMPLES
.TP
.EX
@@ -495,7 +543,7 @@ BEGIN { FS = ",[ \et]*|[ \et]+" }
.EE
.ns
.IP
-Same, with input fields separated by comma and/or blanks and tabs.
+Same, with input fields separated by comma and/or spaces and tabs.
.PP
.EX
.nf
@@ -521,18 +569,73 @@ BEGIN { # Simulate echo(1)
.fi
.EE
.SH SEE ALSO
-.IR lex (1),
+.IR grep (1),
+.IR lex (1),
.IR sed (1)
.br
A. V. Aho, B. W. Kernighan, P. J. Weinberger,
-.I
-The AWK Programming Language,
-Addison-Wesley, 1988. ISBN 0-201-07981-X
+.IR "The AWK Programming Language" ,
+Addison-Wesley, 1988. ISBN 0-201-07981-X.
.SH BUGS
There are no explicit conversions between numbers and strings.
To force an expression to be treated as a number add 0 to it;
to force it to be treated as a string concatenate
\&\f(CW""\fP to it.
-.br
+.PP
The scope rules for variables in functions are a botch;
the syntax is worse.
+.PP
+Only eight-bit characters sets are handled correctly.
+.SH UNUSUAL FLOATING-POINT VALUES
+.I Nawk
+was designed before IEEE 754 arithmetic defined Not-A-Number (NaN)
+and Infinity values, which are supported by all modern floating-point
+hardware.
+.PP
+Because
+.I nawk
+uses
+.IR strtod (3)
+and
+.IR atof (3)
+to convert string values to double-precision floating-point values,
+modern C libraries also convert strings starting with
+.B inf
+and
+.B nan
+into infinity and NaN values respectively. This led to strange results,
+with something like this:
+.PP
+.EX
+.nf
+echo nancy | nawk '{ print $1 + 0 }'
+.fi
+.EE
+.PP
+printing
+.B nan
+instead of zero.
+.PP
+.I Nawk
+now follows GNU AWK, and prefilters string values before attempting
+to convert them to numbers, as follows:
+.TP
+.I "Hexadecimal values"
+Hexadecimal values (allowed since C99) convert to zero, as they did
+prior to C99.
+.TP
+.I "NaN values"
+The two strings
+.B +nan
+and
+.B \-nan
+(case independent) convert to NaN. No others do.
+(NaNs can have signs.)
+.TP
+.I "Infinity values"
+The two strings
+.B +inf
+and
+.B \-inf
+(case independent) convert to positive and negative infinity, respectively.
+No others do.
Index: pkgsrc/lang/nawk/files/parse.c
diff -u pkgsrc/lang/nawk/files/parse.c:1.1 pkgsrc/lang/nawk/files/parse.c:1.2
--- pkgsrc/lang/nawk/files/parse.c:1.1 Fri Jul 14 14:23:06 2006
+++ pkgsrc/lang/nawk/files/parse.c Fri Feb 24 20:57:50 2023
@@ -1,5 +1,3 @@
-/* $NetBSD: parse.c,v 1.1 2006/07/14 14:23:06 jlam Exp $ */
-
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -29,13 +27,13 @@ THIS SOFTWARE.
#include <string.h>
#include <stdlib.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.tab.h"
Node *nodealloc(int n)
{
Node *x;
- x = (Node *) malloc(sizeof(Node) + (n-1)*sizeof(Node *));
+ x = (Node *) malloc(sizeof(*x) + (n-1) * sizeof(x));
if (x == NULL)
FATAL("out of space in nodealloc");
x->nnext = NULL;
@@ -252,7 +250,7 @@ void defn(Cell *v, Node *vl, Node *st) /
for (p = vl; p; p = p->nnext)
n++;
v->fval = n;
- dprintf( ("defining func %s (%d args)\n", v->nval, n) );
+ DPRINTF("defining func %s (%d args)\n", v->nval, n);
}
int isarg(const char *s) /* is s in argument list for current function? */
@@ -261,7 +259,7 @@ int isarg(const char *s) /* is s in arg
Node *p = arglist;
int n;
- for (n = 0; p != 0; p = p->nnext, n++)
+ for (n = 0; p != NULL; p = p->nnext, n++)
if (strcmp(((Cell *)(p->narg[0]))->nval, s) == 0)
return n;
return -1;
Added files:
Index: pkgsrc/lang/nawk/files/LICENSE
diff -u /dev/null pkgsrc/lang/nawk/files/LICENSE:1.1
--- /dev/null Fri Feb 24 20:57:50 2023
+++ pkgsrc/lang/nawk/files/LICENSE Fri Feb 24 20:57:50 2023
@@ -0,0 +1,23 @@
+/****************************************************************
+Copyright (C) Lucent Technologies 1997
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name Lucent Technologies or any of
+its entities not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+****************************************************************/
Index: pkgsrc/lang/nawk/files/awkgram.tab.c
diff -u /dev/null pkgsrc/lang/nawk/files/awkgram.tab.c:1.1
--- /dev/null Fri Feb 24 20:57:50 2023
+++ pkgsrc/lang/nawk/files/awkgram.tab.c Fri Feb 24 20:57:50 2023
@@ -0,0 +1,3455 @@
+/* A Bison parser, made by GNU Bison 3.8.2. */
+
+/* Bison implementation for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
+ especially those whose name start with YY_ or yy_. They are
+ private implementation details that can be changed or removed. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output, and Bison version. */
+#define YYBISON 30802
+
+/* Bison version string. */
+#define YYBISON_VERSION "3.8.2"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+
+
+
+/* First part of user prologue. */
+#line 25 "awkgram.y"
+
+#include <stdio.h>
+#include <string.h>
+#include "awk.h"
+
+void checkdup(Node *list, Cell *item);
+int yywrap(void) { return(1); }
+
+Node *beginloc = 0;
+Node *endloc = 0;
+bool infunc = false; /* = true if in arglist or body of func */
+int inloop = 0; /* >= 1 if in while, for, do; can't be bool, since loops can next */
+char *curfname = 0; /* current function name */
+Node *arglist = 0; /* list of args for current function */
+
+#line 87 "awkgram.tab.c"
+
+# ifndef YY_CAST
+# ifdef __cplusplus
+# define YY_CAST(Type, Val) static_cast<Type> (Val)
+# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
+# else
+# define YY_CAST(Type, Val) ((Type) (Val))
+# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
+# endif
+# endif
+# ifndef YY_NULLPTR
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
+# else
+# define YY_NULLPTR ((void*)0)
+# endif
+# endif
+
+#include "awkgram.tab.h"
+/* Symbol kind. */
+enum yysymbol_kind_t
+{
+ YYSYMBOL_YYEMPTY = -2,
+ YYSYMBOL_YYEOF = 0, /* "end of file" */
+ YYSYMBOL_YYerror = 1, /* error */
+ YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
+ YYSYMBOL_FIRSTTOKEN = 3, /* FIRSTTOKEN */
+ YYSYMBOL_PROGRAM = 4, /* PROGRAM */
+ YYSYMBOL_PASTAT = 5, /* PASTAT */
+ YYSYMBOL_PASTAT2 = 6, /* PASTAT2 */
+ YYSYMBOL_XBEGIN = 7, /* XBEGIN */
+ YYSYMBOL_XEND = 8, /* XEND */
+ YYSYMBOL_NL = 9, /* NL */
+ YYSYMBOL_10_ = 10, /* ',' */
+ YYSYMBOL_11_ = 11, /* '{' */
+ YYSYMBOL_12_ = 12, /* '(' */
+ YYSYMBOL_13_ = 13, /* '|' */
+ YYSYMBOL_14_ = 14, /* ';' */
+ YYSYMBOL_15_ = 15, /* '/' */
+ YYSYMBOL_16_ = 16, /* ')' */
+ YYSYMBOL_17_ = 17, /* '}' */
+ YYSYMBOL_18_ = 18, /* '[' */
+ YYSYMBOL_19_ = 19, /* ']' */
+ YYSYMBOL_ARRAY = 20, /* ARRAY */
+ YYSYMBOL_MATCH = 21, /* MATCH */
+ YYSYMBOL_NOTMATCH = 22, /* NOTMATCH */
+ YYSYMBOL_MATCHOP = 23, /* MATCHOP */
+ YYSYMBOL_FINAL = 24, /* FINAL */
+ YYSYMBOL_DOT = 25, /* DOT */
+ YYSYMBOL_ALL = 26, /* ALL */
+ YYSYMBOL_CCL = 27, /* CCL */
+ YYSYMBOL_NCCL = 28, /* NCCL */
+ YYSYMBOL_CHAR = 29, /* CHAR */
+ YYSYMBOL_OR = 30, /* OR */
+ YYSYMBOL_STAR = 31, /* STAR */
+ YYSYMBOL_QUEST = 32, /* QUEST */
+ YYSYMBOL_PLUS = 33, /* PLUS */
+ YYSYMBOL_EMPTYRE = 34, /* EMPTYRE */
+ YYSYMBOL_ZERO = 35, /* ZERO */
+ YYSYMBOL_AND = 36, /* AND */
+ YYSYMBOL_BOR = 37, /* BOR */
+ YYSYMBOL_APPEND = 38, /* APPEND */
+ YYSYMBOL_EQ = 39, /* EQ */
+ YYSYMBOL_GE = 40, /* GE */
+ YYSYMBOL_GT = 41, /* GT */
+ YYSYMBOL_LE = 42, /* LE */
+ YYSYMBOL_LT = 43, /* LT */
+ YYSYMBOL_NE = 44, /* NE */
+ YYSYMBOL_IN = 45, /* IN */
+ YYSYMBOL_ARG = 46, /* ARG */
+ YYSYMBOL_BLTIN = 47, /* BLTIN */
+ YYSYMBOL_BREAK = 48, /* BREAK */
+ YYSYMBOL_CLOSE = 49, /* CLOSE */
+ YYSYMBOL_CONTINUE = 50, /* CONTINUE */
+ YYSYMBOL_DELETE = 51, /* DELETE */
+ YYSYMBOL_DO = 52, /* DO */
+ YYSYMBOL_EXIT = 53, /* EXIT */
+ YYSYMBOL_FOR = 54, /* FOR */
+ YYSYMBOL_FUNC = 55, /* FUNC */
+ YYSYMBOL_SUB = 56, /* SUB */
+ YYSYMBOL_GSUB = 57, /* GSUB */
+ YYSYMBOL_IF = 58, /* IF */
+ YYSYMBOL_INDEX = 59, /* INDEX */
+ YYSYMBOL_LSUBSTR = 60, /* LSUBSTR */
+ YYSYMBOL_MATCHFCN = 61, /* MATCHFCN */
+ YYSYMBOL_NEXT = 62, /* NEXT */
+ YYSYMBOL_NEXTFILE = 63, /* NEXTFILE */
+ YYSYMBOL_ADD = 64, /* ADD */
+ YYSYMBOL_MINUS = 65, /* MINUS */
+ YYSYMBOL_MULT = 66, /* MULT */
+ YYSYMBOL_DIVIDE = 67, /* DIVIDE */
+ YYSYMBOL_MOD = 68, /* MOD */
+ YYSYMBOL_ASSIGN = 69, /* ASSIGN */
+ YYSYMBOL_ASGNOP = 70, /* ASGNOP */
+ YYSYMBOL_ADDEQ = 71, /* ADDEQ */
+ YYSYMBOL_SUBEQ = 72, /* SUBEQ */
+ YYSYMBOL_MULTEQ = 73, /* MULTEQ */
+ YYSYMBOL_DIVEQ = 74, /* DIVEQ */
+ YYSYMBOL_MODEQ = 75, /* MODEQ */
+ YYSYMBOL_POWEQ = 76, /* POWEQ */
+ YYSYMBOL_PRINT = 77, /* PRINT */
+ YYSYMBOL_PRINTF = 78, /* PRINTF */
+ YYSYMBOL_SPRINTF = 79, /* SPRINTF */
+ YYSYMBOL_ELSE = 80, /* ELSE */
+ YYSYMBOL_INTEST = 81, /* INTEST */
+ YYSYMBOL_CONDEXPR = 82, /* CONDEXPR */
+ YYSYMBOL_POSTINCR = 83, /* POSTINCR */
+ YYSYMBOL_PREINCR = 84, /* PREINCR */
+ YYSYMBOL_POSTDECR = 85, /* POSTDECR */
+ YYSYMBOL_PREDECR = 86, /* PREDECR */
+ YYSYMBOL_VAR = 87, /* VAR */
+ YYSYMBOL_IVAR = 88, /* IVAR */
+ YYSYMBOL_VARNF = 89, /* VARNF */
+ YYSYMBOL_CALL = 90, /* CALL */
+ YYSYMBOL_NUMBER = 91, /* NUMBER */
+ YYSYMBOL_STRING = 92, /* STRING */
+ YYSYMBOL_REGEXPR = 93, /* REGEXPR */
+ YYSYMBOL_94_ = 94, /* '?' */
+ YYSYMBOL_95_ = 95, /* ':' */
+ YYSYMBOL_GETLINE = 96, /* GETLINE */
+ YYSYMBOL_RETURN = 97, /* RETURN */
+ YYSYMBOL_SPLIT = 98, /* SPLIT */
+ YYSYMBOL_SUBSTR = 99, /* SUBSTR */
+ YYSYMBOL_WHILE = 100, /* WHILE */
+ YYSYMBOL_CAT = 101, /* CAT */
+ YYSYMBOL_102_ = 102, /* '+' */
+ YYSYMBOL_103_ = 103, /* '-' */
+ YYSYMBOL_104_ = 104, /* '*' */
+ YYSYMBOL_105_ = 105, /* '%' */
+ YYSYMBOL_NOT = 106, /* NOT */
+ YYSYMBOL_UMINUS = 107, /* UMINUS */
+ YYSYMBOL_UPLUS = 108, /* UPLUS */
+ YYSYMBOL_POWER = 109, /* POWER */
+ YYSYMBOL_DECR = 110, /* DECR */
+ YYSYMBOL_INCR = 111, /* INCR */
+ YYSYMBOL_INDIRECT = 112, /* INDIRECT */
+ YYSYMBOL_LASTTOKEN = 113, /* LASTTOKEN */
+ YYSYMBOL_YYACCEPT = 114, /* $accept */
+ YYSYMBOL_program = 115, /* program */
+ YYSYMBOL_and = 116, /* and */
+ YYSYMBOL_bor = 117, /* bor */
+ YYSYMBOL_comma = 118, /* comma */
+ YYSYMBOL_do = 119, /* do */
+ YYSYMBOL_else = 120, /* else */
+ YYSYMBOL_for = 121, /* for */
+ YYSYMBOL_122_1 = 122, /* $@1 */
+ YYSYMBOL_123_2 = 123, /* $@2 */
+ YYSYMBOL_124_3 = 124, /* $@3 */
+ YYSYMBOL_funcname = 125, /* funcname */
+ YYSYMBOL_if = 126, /* if */
+ YYSYMBOL_lbrace = 127, /* lbrace */
+ YYSYMBOL_nl = 128, /* nl */
+ YYSYMBOL_opt_nl = 129, /* opt_nl */
+ YYSYMBOL_opt_pst = 130, /* opt_pst */
+ YYSYMBOL_opt_simple_stmt = 131, /* opt_simple_stmt */
+ YYSYMBOL_pas = 132, /* pas */
+ YYSYMBOL_pa_pat = 133, /* pa_pat */
+ YYSYMBOL_pa_stat = 134, /* pa_stat */
+ YYSYMBOL_135_4 = 135, /* $@4 */
+ YYSYMBOL_pa_stats = 136, /* pa_stats */
+ YYSYMBOL_patlist = 137, /* patlist */
+ YYSYMBOL_ppattern = 138, /* ppattern */
+ YYSYMBOL_pattern = 139, /* pattern */
+ YYSYMBOL_plist = 140, /* plist */
+ YYSYMBOL_pplist = 141, /* pplist */
+ YYSYMBOL_prarg = 142, /* prarg */
+ YYSYMBOL_print = 143, /* print */
+ YYSYMBOL_pst = 144, /* pst */
+ YYSYMBOL_rbrace = 145, /* rbrace */
+ YYSYMBOL_re = 146, /* re */
+ YYSYMBOL_reg_expr = 147, /* reg_expr */
+ YYSYMBOL_148_5 = 148, /* $@5 */
+ YYSYMBOL_rparen = 149, /* rparen */
+ YYSYMBOL_simple_stmt = 150, /* simple_stmt */
+ YYSYMBOL_st = 151, /* st */
+ YYSYMBOL_stmt = 152, /* stmt */
+ YYSYMBOL_153_6 = 153, /* $@6 */
+ YYSYMBOL_154_7 = 154, /* $@7 */
+ YYSYMBOL_155_8 = 155, /* $@8 */
+ YYSYMBOL_stmtlist = 156, /* stmtlist */
+ YYSYMBOL_subop = 157, /* subop */
+ YYSYMBOL_string = 158, /* string */
+ YYSYMBOL_term = 159, /* term */
+ YYSYMBOL_var = 160, /* var */
+ YYSYMBOL_varlist = 161, /* varlist */
+ YYSYMBOL_varname = 162, /* varname */
+ YYSYMBOL_while = 163 /* while */
+};
+typedef enum yysymbol_kind_t yysymbol_kind_t;
+
+
+
+
+#ifdef short
+# undef short
+#endif
+
+/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
+ <limits.h> and (if available) <stdint.h> are included
+ so that the code can choose integer types of a good width. */
+
+#ifndef __PTRDIFF_MAX__
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_STDINT_H
+# endif
+#endif
+
+/* Narrow types that promote to a signed type and that can represent a
+ signed or unsigned integer of at least N bits. In tables they can
+ save space and decrease cache pressure. Promoting to a signed type
+ helps avoid bugs in integer arithmetic. */
+
+#ifdef __INT_LEAST8_MAX__
+typedef __INT_LEAST8_TYPE__ yytype_int8;
+#elif defined YY_STDINT_H
+typedef int_least8_t yytype_int8;
+#else
+typedef signed char yytype_int8;
+#endif
+
+#ifdef __INT_LEAST16_MAX__
+typedef __INT_LEAST16_TYPE__ yytype_int16;
+#elif defined YY_STDINT_H
+typedef int_least16_t yytype_int16;
+#else
+typedef short yytype_int16;
+#endif
+
+/* Work around bug in HP-UX 11.23, which defines these macros
+ incorrectly for preprocessor constants. This workaround can likely
+ be removed in 2023, as HPE has promised support for HP-UX 11.23
+ (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
+ <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
+#ifdef __hpux
+# undef UINT_LEAST8_MAX
+# undef UINT_LEAST16_MAX
+# define UINT_LEAST8_MAX 255
+# define UINT_LEAST16_MAX 65535
+#endif
+
+#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST8_TYPE__ yytype_uint8;
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
+ && UINT_LEAST8_MAX <= INT_MAX)
+typedef uint_least8_t yytype_uint8;
+#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
+typedef unsigned char yytype_uint8;
+#else
+typedef short yytype_uint8;
+#endif
+
+#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
+typedef __UINT_LEAST16_TYPE__ yytype_uint16;
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
+ && UINT_LEAST16_MAX <= INT_MAX)
+typedef uint_least16_t yytype_uint16;
+#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
+typedef unsigned short yytype_uint16;
+#else
+typedef int yytype_uint16;
+#endif
+
+#ifndef YYPTRDIFF_T
+# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
+# define YYPTRDIFF_T __PTRDIFF_TYPE__
+# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
+# elif defined PTRDIFF_MAX
+# ifndef ptrdiff_t
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# endif
+# define YYPTRDIFF_T ptrdiff_t
+# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
+# else
+# define YYPTRDIFF_T long
+# define YYPTRDIFF_MAXIMUM LONG_MAX
+# endif
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM \
+ YY_CAST (YYPTRDIFF_T, \
+ (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
+ ? YYPTRDIFF_MAXIMUM \
+ : YY_CAST (YYSIZE_T, -1)))
+
+#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
+
+
+/* Stored state numbers (used for stacks). */
+typedef yytype_int16 yy_state_t;
+
+/* State numbers in computations. */
+typedef int yy_state_fast_t;
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(Msgid) Msgid
+# endif
+#endif
+
+
+#ifndef YY_ATTRIBUTE_PURE
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+# define YY_ATTRIBUTE_PURE
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+# define YY_ATTRIBUTE_UNUSED
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YY_USE(E) ((void) (E))
+#else
+# define YY_USE(E) /* empty */
+#endif
+
+/* Suppress an incorrect diagnostic about yylval being uninitialized. */
+#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
+# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
+# else
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# endif
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+#else
+# define YY_INITIAL_VALUE(Value) Value
+#endif
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
+# define YY_IGNORE_USELESS_CAST_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
+# define YY_IGNORE_USELESS_CAST_END \
+ _Pragma ("GCC diagnostic pop")
+#endif
+#ifndef YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_BEGIN
+# define YY_IGNORE_USELESS_CAST_END
+#endif
+
+
+#define YY_ASSERT(E) ((void) (0 && (E)))
+
+#if !defined yyoverflow
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's 'empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* !defined yyoverflow */
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yy_state_t yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYPTRDIFF_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / YYSIZEOF (*yyptr); \
+ } \
+ while (0)
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from SRC to DST. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(Dst, Src, Count) \
+ __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
+# else
+# define YYCOPY(Dst, Src, Count) \
+ do \
+ { \
+ YYPTRDIFF_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (Dst)[yyi] = (Src)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 8
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 4608
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 114
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 50
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 187
+/* YYNSTATES -- Number of states. */
+#define YYNSTATES 370
+
+/* YYMAXUTOK -- Last valid token kind. */
+#define YYMAXUTOK 352
+
+
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
+#define YYTRANSLATE(YYX) \
+ (0 <= (YYX) && (YYX) <= YYMAXUTOK \
+ ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
+ : YYSYMBOL_YYUNDEF)
+
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex. */
+static const yytype_int8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 105, 2, 2,
+ 12, 16, 104, 102, 10, 103, 2, 15, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 95, 14,
+ 2, 2, 2, 94, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 18, 2, 19, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 11, 13, 17, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89, 90, 91, 92, 93, 96,
+ 97, 98, 99, 100, 101, 106, 107, 108, 109, 110,
+ 111, 112, 113
+};
+
+#if YYDEBUG
+/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
+static const yytype_int16 yyrline[] =
+{
+ 0, 99, 99, 101, 105, 105, 109, 109, 113, 113,
+ 117, 117, 121, 121, 125, 125, 127, 127, 129, 129,
+ 134, 135, 139, 143, 143, 147, 147, 151, 152, 156,
+ 157, 162, 163, 167, 168, 172, 176, 177, 178, 179,
+ 180, 181, 183, 185, 185, 190, 191, 195, 196, 200,
+ 201, 203, 205, 207, 208, 213, 214, 215, 216, 217,
+ 221, 222, 224, 226, 228, 229, 230, 231, 232, 233,
+ 234, 235, 240, 241, 242, 245, 248, 249, 250, 254,
+ 255, 259, 260, 264, 265, 266, 270, 270, 274, 274,
+ 274, 274, 278, 278, 282, 284, 288, 288, 292, 292,
+ 296, 299, 302, 305, 306, 307, 308, 309, 313, 314,
+ 318, 320, 322, 322, 322, 324, 325, 326, 327, 328,
+ 329, 330, 333, 336, 337, 338, 339, 339, 340, 344,
+ 345, 349, 349, 353, 354, 358, 359, 360, 361, 362,
+ 363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
+ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
+ 384, 387, 388, 390, 395, 396, 398, 400, 402, 403,
+ 404, 406, 411, 413, 418, 420, 422, 426, 427, 428,
+ 429, 433, 434, 435, 441, 442, 443, 448
+};
+#endif
+
+/** Accessing symbol of state STATE. */
+#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
+
+#if YYDEBUG || 0
+/* The user-facing name of the symbol whose (internal) number is
+ YYSYMBOL. No bounds checking. */
+static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
+
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "\"end of file\"", "error", "\"invalid token\"", "FIRSTTOKEN",
+ "PROGRAM", "PASTAT", "PASTAT2", "XBEGIN", "XEND", "NL", "','", "'{'",
+ "'('", "'|'", "';'", "'/'", "')'", "'}'", "'['", "']'", "ARRAY", "MATCH",
+ "NOTMATCH", "MATCHOP", "FINAL", "DOT", "ALL", "CCL", "NCCL", "CHAR",
+ "OR", "STAR", "QUEST", "PLUS", "EMPTYRE", "ZERO", "AND", "BOR", "APPEND",
+ "EQ", "GE", "GT", "LE", "LT", "NE", "IN", "ARG", "BLTIN", "BREAK",
+ "CLOSE", "CONTINUE", "DELETE", "DO", "EXIT", "FOR", "FUNC", "SUB",
+ "GSUB", "IF", "INDEX", "LSUBSTR", "MATCHFCN", "NEXT", "NEXTFILE", "ADD",
+ "MINUS", "MULT", "DIVIDE", "MOD", "ASSIGN", "ASGNOP", "ADDEQ", "SUBEQ",
+ "MULTEQ", "DIVEQ", "MODEQ", "POWEQ", "PRINT", "PRINTF", "SPRINTF",
+ "ELSE", "INTEST", "CONDEXPR", "POSTINCR", "PREINCR", "POSTDECR",
+ "PREDECR", "VAR", "IVAR", "VARNF", "CALL", "NUMBER", "STRING", "REGEXPR",
+ "'?'", "':'", "GETLINE", "RETURN", "SPLIT", "SUBSTR", "WHILE", "CAT",
+ "'+'", "'-'", "'*'", "'%'", "NOT", "UMINUS", "UPLUS", "POWER", "DECR",
+ "INCR", "INDIRECT", "LASTTOKEN", "$accept", "program", "and", "bor",
+ "comma", "do", "else", "for", "$@1", "$@2", "$@3", "funcname", "if",
+ "lbrace", "nl", "opt_nl", "opt_pst", "opt_simple_stmt", "pas", "pa_pat",
+ "pa_stat", "$@4", "pa_stats", "patlist", "ppattern", "pattern", "plist",
+ "pplist", "prarg", "print", "pst", "rbrace", "re", "reg_expr", "$@5",
+ "rparen", "simple_stmt", "st", "stmt", "$@6", "$@7", "$@8", "stmtlist",
+ "subop", "string", "term", "var", "varlist", "varname", "while", YY_NULLPTR
+};
+
+static const char *
+yysymbol_name (yysymbol_kind_t yysymbol)
+{
+ return yytname[yysymbol];
+}
+#endif
+
+#define YYPACT_NINF (-316)
+
+#define yypact_value_is_default(Yyn) \
+ ((Yyn) == YYPACT_NINF)
+
+#define YYTABLE_NINF (-32)
+
+#define yytable_value_is_error(Yyn) \
+ ((Yyn) == YYTABLE_NINF)
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+static const yytype_int16 yypact[] =
+{
+ 635, -316, -316, -316, 10, 1580, -316, 151, -316, 3,
+ 3, -316, 4178, -316, -316, 29, 4496, 18, -316, -316,
+ 40, 44, 56, -316, -316, -316, 71, -316, -316, 81,
+ 95, 104, 4496, 4496, 4226, 261, 261, 4496, 763, 76,
+ -316, 157, 3511, -316, -316, 106, -62, -3, -34, 117,
+ -316, -316, 763, 763, 2184, 39, 53, 4014, 4178, 4496,
+ -3, 32, -316, -316, 113, 4178, 4178, 4178, 4072, 4496,
+ 115, 4178, 4178, 65, 65, -316, 65, -316, -316, -316,
+ -316, -316, 166, 158, 158, -14, -316, 1733, 164, 178,
+ 158, 158, -316, -316, 1733, 186, 190, -316, 1386, 763,
+ 3511, 4284, 158, -316, 832, -316, 166, 763, 1580, 108,
+ 4178, -316, -316, 4178, 4178, 4178, 4178, 4178, 4178, -14,
+ 4178, 1791, 1849, -3, 4178, -316, 4332, 4496, 4496, 4496,
+ 4496, 4496, 4178, -316, -316, 4178, 901, 970, -316, -316,
+ 1907, 155, 1907, 192, -316, 62, 3511, 2680, 116, 2588,
+ 2588, 80, -316, 87, -3, 4496, 2588, 2588, -316, 196,
+ -316, 166, 196, -316, -316, 191, 1675, -316, 1454, 4178,
+ -316, -316, 1675, -316, 4178, -316, 1386, 130, 1039, 4178,
+ 3894, 201, 57, -316, -3, -30, -316, -316, -316, 1386,
+ 4178, 1108, -316, 261, 3765, -316, 3765, 3765, 3765, 3765,
+ 3765, 3765, -316, 2772, -316, 3684, -316, 3603, 2588, 201,
+ 4496, 65, 43, 43, 65, 65, 65, 3511, 27, -316,
+ -316, -316, 3511, -14, 3511, -316, -316, 1907, -316, 107,
+ 1907, 1907, -316, -316, -3, 2, 1907, -316, -316, 4178,
+ -316, 203, -316, -11, 2864, -316, 2864, -316, -316, 1179,
+ -316, 206, 128, 4400, -14, 4400, 1965, 2023, -3, 2081,
+ 4496, 4496, 4496, 4400, -316, 3, -316, -316, 4178, 1907,
+ 1907, -3, -316, -316, 3511, -316, 6, 210, 2956, 204,
+ 3048, 213, 143, 2287, 47, 188, -14, 210, 210, 132,
+ -316, -316, -316, 193, 4178, 4448, -316, -316, 3813, 4120,
+ 3966, 3894, -3, -3, -3, 3894, 763, 3511, 2390, 2493,
+ -316, -316, 3, -316, -316, -316, -316, -316, 1907, -316,
+ 1907, -316, 166, 4178, 217, 223, -14, 147, 4400, 1248,
+ -316, 33, -316, 33, 763, 3140, 220, 3232, 1522, 3327,
+ 210, 4178, -316, 193, 3894, -316, 226, 232, 1317, -316,
+ -316, -316, 217, 166, 1386, 3419, -316, -316, -316, 210,
+ 1522, -316, 158, 1386, 217, -316, -316, 210, 1386, -316
+};
+
+/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE does not specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 0, 3, 88, 89, 0, 33, 2, 30, 1, 0,
+ 0, 23, 0, 96, 185, 147, 0, 0, 131, 132,
+ 0, 0, 0, 184, 179, 186, 0, 164, 133, 158,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
+ 45, 29, 35, 77, 94, 0, 169, 78, 176, 177,
+ 90, 91, 0, 0, 0, 0, 0, 0, 0, 0,
+ 150, 176, 20, 21, 0, 0, 0, 0, 0, 0,
+ 157, 0, 0, 143, 142, 95, 144, 151, 152, 180,
+ 107, 24, 27, 0, 0, 0, 10, 0, 0, 0,
+ 0, 0, 86, 87, 0, 0, 112, 117, 0, 0,
+ 106, 83, 0, 129, 0, 126, 27, 0, 34, 0,
+ 0, 4, 6, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 76, 0, 134, 0, 0, 0, 0,
+ 0, 0, 0, 153, 154, 0, 0, 0, 8, 161,
+ 0, 0, 0, 0, 145, 0, 47, 0, 181, 0,
+ 0, 0, 148, 0, 156, 0, 0, 0, 25, 28,
+ 128, 27, 108, 110, 111, 105, 0, 116, 0, 0,
+ 121, 122, 0, 124, 0, 11, 0, 119, 0, 0,
+ 81, 84, 103, 58, 59, 176, 125, 40, 130, 0,
+ 0, 0, 46, 75, 71, 70, 64, 65, 66, 67,
+ 68, 69, 72, 0, 5, 63, 7, 62, 0, 94,
+ 0, 139, 136, 137, 138, 140, 141, 60, 0, 41,
+ 42, 9, 79, 0, 80, 97, 146, 0, 182, 0,
+ 0, 0, 168, 149, 155, 0, 0, 26, 109, 0,
+ 115, 0, 32, 177, 0, 123, 0, 113, 12, 0,
+ 92, 120, 0, 0, 0, 0, 0, 0, 57, 0,
+ 0, 0, 0, 0, 127, 38, 37, 74, 0, 0,
+ 0, 135, 178, 73, 48, 98, 0, 43, 0, 94,
+ 0, 94, 0, 0, 0, 27, 0, 22, 187, 0,
+ 13, 118, 93, 85, 0, 54, 53, 55, 0, 52,
+ 51, 82, 100, 101, 102, 49, 0, 61, 0, 0,
+ 183, 99, 0, 159, 160, 163, 162, 167, 0, 175,
+ 0, 104, 27, 0, 0, 0, 0, 0, 0, 0,
+ 171, 0, 170, 0, 0, 0, 94, 0, 0, 0,
+ 18, 0, 56, 0, 50, 39, 0, 0, 0, 165,
+ 166, 174, 0, 27, 0, 0, 173, 172, 44, 16,
+ 0, 19, 0, 0, 0, 114, 17, 14, 0, 15
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -316, -316, -1, 46, 5, -316, -316, -316, -316, -316,
+ -316, -316, -316, -4, -73, -67, 209, -315, -316, 61,
+ 145, -316, -316, -43, -192, 482, -175, -316, -316, -316,
+ -316, -316, -32, -102, -316, -215, -165, -40, 381, -316,
+ -316, -316, -25, -316, -316, 236, -16, -316, 103, -316
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ 0, 4, 121, 122, 227, 96, 249, 97, 368, 363,
+ 354, 64, 98, 99, 162, 160, 5, 241, 6, 39,
+ 40, 312, 41, 145, 180, 100, 55, 181, 182, 101,
+ 7, 251, 43, 44, 56, 277, 102, 163, 103, 176,
+ 289, 189, 104, 45, 46, 47, 48, 229, 49, 105
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule whose
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+static const yytype_int16 yytable[] =
+{
+ 61, 38, 75, 242, 252, 52, 53, 135, 195, 159,
+ 8, 221, 126, 70, 11, 221, 61, 61, 61, 77,
+ 78, 61, 209, 352, 151, 153, 61, 136, 137, 287,
+ 125, 288, 14, 159, 286, 107, 132, 138, 61, 190,
+ 263, 57, 221, 61, 164, 364, 272, 167, 14, 138,
+ 170, 171, 65, 61, 173, 141, 66, 138, 126, 140,
+ 142, 295, 186, 298, 299, 300, 321, 301, 67, 183,
+ 260, 305, 138, 23, 178, 25, 133, 134, 226, 14,
+ 133, 134, 191, 68, 61, 185, 106, 11, 159, 23,
+ 138, 25, 218, 310, 238, 261, 232, 138, 262, 127,
+ 128, 129, 130, 233, 38, 62, 131, 71, 63, 340,
+ 61, 61, 61, 61, 61, 61, 72, 138, 124, 327,
+ 23, 24, 25, 275, 69, 148, 240, 14, 279, 281,
+ 61, 61, 245, 61, 61, 135, 344, 359, 138, 61,
+ 61, 61, 133, 134, 293, 37, 143, 129, 130, 367,
+ 61, 296, 131, 138, 230, 231, 61, 138, 155, 317,
+ 50, 235, 236, 343, 61, 51, 2, 158, 23, 24,
+ 25, 3, 161, 242, 131, 158, 168, 267, 61, 256,
+ 61, 61, 61, 61, 61, 61, 259, 61, 165, 61,
+ 169, 61, 61, 37, 61, 242, 284, 158, 174, 175,
+ 223, 61, 322, 228, 193, 237, 61, 225, 61, 239,
+ 248, 138, 159, 269, 270, 292, 336, 285, 323, 311,
+ 314, 183, 202, 183, 183, 183, 257, 183, 61, 316,
+ 61, 183, 325, 275, 276, 341, 350, 185, 326, 185,
+ 185, 185, 356, 185, 61, 61, 61, 185, 357, 159,
+ 108, 265, 60, 192, 0, 338, 0, 142, 61, 0,
+ 0, 306, 61, 0, 61, 0, 0, 61, 73, 74,
+ 76, 243, 0, 79, 0, 0, 0, 0, 123, 61,
+ 159, 329, 61, 61, 61, 61, 360, 318, 320, 61,
+ 123, 61, 61, 61, 256, 76, 183, 256, 256, 256,
+ 256, 0, 0, 0, 256, 154, 0, 14, 334, 348,
+ 0, 0, 185, 331, 333, 346, 0, 347, 0, 61,
+ 0, 61, 365, 61, 0, 0, 273, 0, 61, 0,
+ 0, 0, 142, 0, 0, 0, 123, 184, 282, 61,
+ 0, 257, 0, 256, 257, 257, 257, 257, 23, 24,
+ 25, 257, 0, 0, 0, 0, 0, 297, 0, 0,
+ 0, 0, 211, 212, 213, 214, 215, 216, 0, 0,
+ 0, 0, 0, 37, 0, 0, 0, 0, 0, 0,
+ 0, 0, 123, 123, 0, 123, 123, 0, 0, 324,
+ 257, 234, 123, 123, 0, 0, 0, 0, 0, 0,
+ 0, 0, 123, 0, 0, 0, 0, 0, 123, 0,
+ 0, 0, 0, 0, 0, 0, 258, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 342,
+ 123, 0, 123, 123, 123, 123, 123, 123, 0, 123,
+ 0, 123, 0, 123, 123, 0, 271, 0, 0, 0,
+ 0, 0, 0, 123, 0, 0, 0, 0, 123, 0,
+ 123, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 177,
+ 123, 0, 123, 0, 0, 188, 0, 42, 0, 184,
+ 0, 184, 184, 184, 54, 184, 302, 303, 304, 184,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 123, 0, 0, 0, 123, 0, 123, 188, 188, 123,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 258, 0, 0, 258, 258, 258, 258, 0, 146,
+ 147, 258, 0, 123, 123, 123, 0, 149, 150, 146,
+ 146, 0, 0, 156, 157, 0, 0, 247, 0, 188,
+ 0, 0, 0, 0, 184, 0, 0, 0, 0, 166,
+ 264, 123, 188, 123, 0, 123, 172, 0, 0, 0,
+ 258, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 42, 123, 194, 0, 0, 196, 197, 198, 199, 200,
+ 201, 0, 203, 205, 207, 0, 208, 0, 0, 0,
+ 0, 0, 0, 0, 217, 0, 0, 146, 0, 0,
+ 0, 0, 222, 0, 224, 0, 0, 0, 0, 0,
+ 291, 0, 0, 0, 0, -29, 1, 0, 0, 0,
+ 0, 0, -29, -29, 2, 0, -29, -29, 0, 3,
+ -29, 244, 0, 0, 0, 0, 246, 0, 0, 0,
+ 0, 54, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 42, 0, 0, 0, 0, 0, 0, 0,
+ 0, -29, -29, 0, -29, 0, 0, 0, 0, 0,
+ -29, -29, -29, 0, -29, 0, -29, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 274,
+ 188, 0, 278, 280, -29, 0, 0, 0, 283, 0,
+ 0, 146, -29, -29, -29, -29, -29, -29, 0, 188,
+ 0, -29, 0, -29, -29, 361, 0, -29, -29, 0,
+ 0, -29, 0, 0, 366, -29, -29, -29, 0, 369,
+ 307, 308, 309, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 80, 0, 0, 0, 0, 0,
+ 0, 0, 81, 0, 11, 12, 54, 82, 13, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 335, 0, 337, 0, 0, 339, 0, 0, 0, 14,
+ 15, 83, 16, 84, 85, 86, 87, 88, 0, 18,
+ 19, 89, 20, 355, 21, 90, 91, 0, 0, 0,
+ 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
+ 92, 93, 22, 11, 12, 0, 82, 13, 0, 187,
+ 23, 24, 25, 26, 27, 28, 0, 0, 0, 29,
+ 94, 30, 31, 95, 0, 32, 33, 0, 0, 34,
+ 0, 0, 0, 35, 36, 37, 0, 0, 14, 15,
+ 83, 16, 84, 85, 86, 87, 88, 0, 18, 19,
+ 89, 20, 0, 21, 90, 91, 0, 0, 0, 0,
+ 0, 0, 80, 0, 0, 0, 0, 0, 0, 92,
+ 93, 22, 11, 12, 0, 82, 13, 0, 219, 23,
+ 24, 25, 26, 27, 28, 0, 0, 0, 29, 94,
+ 30, 31, 95, 0, 32, 33, 0, 0, 34, 0,
+ 0, 0, 35, 36, 37, 0, 0, 14, 15, 83,
+ 16, 84, 85, 86, 87, 88, 0, 18, 19, 89,
+ 20, 0, 21, 90, 91, 0, 0, 0, 0, 0,
+ 0, 80, 0, 0, 0, 0, 0, 0, 92, 93,
+ 22, 11, 12, 0, 82, 13, 0, 220, 23, 24,
+ 25, 26, 27, 28, 0, 0, 0, 29, 94, 30,
+ 31, 95, 0, 32, 33, 0, 0, 34, 0, 0,
+ 0, 35, 36, 37, 0, 0, 14, 15, 83, 16,
+ 84, 85, 86, 87, 88, 0, 18, 19, 89, 20,
+ 0, 21, 90, 91, 0, 0, 0, 0, 0, 0,
+ 80, 0, 0, 0, 0, 0, 0, 92, 93, 22,
+ 11, 12, 0, 82, 13, 0, 250, 23, 24, 25,
+ 26, 27, 28, 0, 0, 0, 29, 94, 30, 31,
+ 95, 0, 32, 33, 0, 0, 34, 0, 0, 0,
+ 35, 36, 37, 0, 0, 14, 15, 83, 16, 84,
+ 85, 86, 87, 88, 0, 18, 19, 89, 20, 0,
+ 21, 90, 91, 0, 0, 0, 0, 0, 0, 80,
+ 0, 0, 0, 0, 0, 0, 92, 93, 22, 11,
+ 12, 0, 82, 13, 0, 266, 23, 24, 25, 26,
+ 27, 28, 0, 0, 0, 29, 94, 30, 31, 95,
+ 0, 32, 33, 0, 0, 34, 0, 0, 0, 35,
+ 36, 37, 0, 0, 14, 15, 83, 16, 84, 85,
+ 86, 87, 88, 0, 18, 19, 89, 20, 0, 21,
+ 90, 91, 0, 0, 0, 0, 0, 0, 0, 0,
+ 80, 0, 0, 0, 0, 92, 93, 22, 290, 0,
+ 11, 12, 0, 82, 13, 23, 24, 25, 26, 27,
+ 28, 0, 0, 0, 29, 94, 30, 31, 95, 0,
+ 32, 33, 0, 0, 34, 0, 0, 0, 35, 36,
+ 37, 0, 0, 0, 0, 14, 15, 83, 16, 84,
+ 85, 86, 87, 88, 0, 18, 19, 89, 20, 0,
+ 21, 90, 91, 0, 0, 0, 0, 0, 0, 80,
+ 0, 0, 0, 0, 0, 0, 92, 93, 22, 11,
+ 12, 0, 82, 13, 0, 345, 23, 24, 25, 26,
+ 27, 28, 0, 0, 0, 29, 94, 30, 31, 95,
+ 0, 32, 33, 0, 0, 34, 0, 0, 0, 35,
+ 36, 37, 0, 0, 14, 15, 83, 16, 84, 85,
+ 86, 87, 88, 0, 18, 19, 89, 20, 0, 21,
+ 90, 91, 0, 0, 0, 0, 0, 0, 80, 0,
+ 0, 0, 0, 0, 0, 92, 93, 22, 11, 12,
+ 0, 82, 13, 0, 358, 23, 24, 25, 26, 27,
+ 28, 0, 0, 0, 29, 94, 30, 31, 95, 0,
+ 32, 33, 0, 0, 34, 0, 0, 0, 35, 36,
+ 37, 0, 0, 14, 15, 83, 16, 84, 85, 86,
+ 87, 88, 0, 18, 19, 89, 20, 0, 21, 90,
+ 91, 0, 0, 0, 0, 0, 0, 80, 0, 0,
+ 0, 0, 0, 0, 92, 93, 22, 11, 12, 0,
+ 82, 13, 0, 0, 23, 24, 25, 26, 27, 28,
+ 0, 0, 0, 29, 94, 30, 31, 95, 0, 32,
+ 33, 0, 0, 34, 0, 0, 0, 35, 36, 37,
+ 0, 0, 14, 15, 83, 16, 84, 85, 86, 87,
+ 88, 0, 18, 19, 89, 20, 0, 21, 90, 91,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 0,
+ 0, 0, 0, 92, 93, 22, 12, 0, -31, 13,
+ 0, 0, 0, 23, 24, 25, 26, 27, 28, 0,
+ 0, 0, 29, 94, 30, 31, 95, 0, 32, 33,
+ 0, 0, 34, 0, 0, 0, 35, 36, 37, 0,
+ 14, 15, 0, 16, 0, 85, 0, 0, 0, 0,
+ 18, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
+ 0, 92, 93, 22, 12, 0, 0, 13, -31, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 0, 0,
+ 29, 0, 30, 31, 0, 0, 32, 33, 0, 0,
+ 34, 0, 0, 0, 35, 36, 37, 0, 14, 15,
+ 0, 16, 0, 85, 0, 0, 0, 0, 18, 19,
+ 0, 20, 0, 21, 0, 0, 0, 9, 10, 0,
+ 0, 11, 12, 0, 0, 13, 0, 0, 0, 92,
+ 93, 22, 0, 0, 0, 0, 0, 0, 0, 23,
+ 24, 25, 26, 27, 28, 0, 0, 0, 29, 0,
+ 30, 31, 0, 0, 32, 33, 14, 15, 34, 16,
+ 0, 0, 35, 36, 37, 17, 18, 19, 0, 20,
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, 0, 0, 0, 29, 0, 30, 31,
+ 0, 0, 32, 33, 158, 0, 34, 58, 109, 161,
+ 35, 36, 37, 0, 0, 0, 0, 0, 110, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 111, 112, 0, 113, 114, 115, 116, 117, 118,
+ 119, 14, 15, 0, 16, 0, 0, 0, 0, 0,
+ 0, 18, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 158, 0, 0, 12, 0, 161, 13, 0,
+ 0, 0, 0, 0, 22, 0, 0, 0, 0, 0,
+ 0, 0, 23, 24, 25, 26, 27, 28, 0, 120,
+ 0, 29, 0, 30, 31, 0, 0, 32, 33, 14,
+ 15, 59, 16, 0, 0, 35, 36, 37, 0, 18,
+ 19, 0, 20, 0, 21, 0, 0, 0, 0, 0,
+ 204, 0, 0, 12, 0, 0, 13, 0, 0, 0,
+ 0, 0, 22, 0, 0, 0, 0, 0, 0, 0,
+ 23, 24, 25, 26, 27, 28, 0, 0, 0, 29,
+ 0, 30, 31, 0, 0, 32, 33, 14, 15, 34,
+ 16, 0, 0, 35, 36, 37, 0, 18, 19, 0,
+ 20, 0, 21, 0, 0, 0, 0, 0, 206, 0,
+ 0, 12, 0, 0, 13, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 23, 24,
+ 25, 26, 27, 28, 0, 0, 0, 29, 0, 30,
+ 31, 0, 0, 32, 33, 14, 15, 34, 16, 0,
+ 0, 35, 36, 37, 0, 18, 19, 0, 20, 0,
+ 21, 0, 0, 0, 0, 0, 221, 0, 0, 12,
+ 0, 0, 13, 0, 0, 0, 0, 0, 22, 0,
+ 0, 0, 0, 0, 0, 0, 23, 24, 25, 26,
+ 27, 28, 0, 0, 0, 29, 0, 30, 31, 0,
+ 0, 32, 33, 14, 15, 34, 16, 0, 0, 35,
+ 36, 37, 0, 18, 19, 0, 20, 0, 21, 0,
+ 0, 0, 0, 0, 204, 0, 0, 294, 0, 0,
+ 13, 0, 0, 0, 0, 0, 22, 0, 0, 0,
+ 0, 0, 0, 0, 23, 24, 25, 26, 27, 28,
+ 0, 0, 0, 29, 0, 30, 31, 0, 0, 32,
+ 33, 14, 15, 34, 16, 0, 0, 35, 36, 37,
+ 0, 18, 19, 0, 20, 0, 21, 0, 0, 0,
+ 0, 0, 206, 0, 0, 294, 0, 0, 13, 0,
+ 0, 0, 0, 0, 22, 0, 0, 0, 0, 0,
+ 0, 0, 23, 24, 25, 26, 27, 28, 0, 0,
+ 0, 29, 0, 30, 31, 0, 0, 32, 33, 14,
+ 15, 34, 16, 0, 0, 35, 36, 37, 0, 18,
+ 19, 0, 20, 0, 21, 0, 0, 0, 0, 0,
+ 221, 0, 0, 294, 0, 0, 13, 0, 0, 0,
+ 0, 0, 22, 0, 0, 0, 0, 0, 0, 0,
+ 23, 24, 25, 26, 27, 28, 0, 0, 0, 29,
+ 0, 30, 31, 0, 0, 32, 33, 14, 15, 34,
+ 16, 0, 0, 35, 36, 37, 0, 18, 19, 0,
+ 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 23, 24,
+ 25, 26, 27, 28, 0, 0, 0, 29, 0, 30,
+ 31, 0, 0, 32, 33, 0, 0, 34, 0, 0,
+ 0, 35, 36, 37, 138, 0, 58, 109, 0, 0,
+ 139, 0, 0, 0, 0, 0, 0, 110, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 111, 112, 0, 113, 114, 115, 116, 117, 118, 119,
+ 14, 15, 0, 16, 0, 0, 0, 0, 0, 0,
+ 18, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 120, 0,
+ 29, 0, 30, 31, 0, 0, 32, 33, 0, 0,
+ 59, 0, 0, 0, 35, 36, 37, 138, 0, 58,
+ 109, 0, 0, 319, 0, 0, 0, 0, 0, 0,
+ 110, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 111, 112, 0, 113, 114, 115, 116,
+ 117, 118, 119, 14, 15, 0, 16, 0, 0, 0,
+ 0, 0, 0, 18, 19, 0, 20, 0, 21, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 22, 0, 0, 0,
+ 0, 0, 0, 0, 23, 24, 25, 26, 27, 28,
+ 0, 120, 0, 29, 0, 30, 31, 0, 0, 32,
+ 33, 0, 0, 59, 0, 0, 0, 35, 36, 37,
+ 138, 0, 58, 109, 0, 0, 330, 0, 0, 0,
+ 0, 0, 0, 110, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 111, 112, 0, 113,
+ 114, 115, 116, 117, 118, 119, 14, 15, 0, 16,
+ 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, 0, 120, 0, 29, 0, 30, 31,
+ 0, 0, 32, 33, 0, 0, 59, 0, 0, 0,
+ 35, 36, 37, 138, 0, 58, 109, 0, 0, 332,
+ 0, 0, 0, 0, 0, 0, 110, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 111,
+ 112, 0, 113, 114, 115, 116, 117, 118, 119, 14,
+ 15, 0, 16, 0, 0, 0, 0, 0, 0, 18,
+ 19, 0, 20, 0, 21, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 22, 0, 0, 0, 0, 0, 0, 0,
+ 23, 24, 25, 26, 27, 28, 0, 120, 0, 29,
+ 0, 30, 31, 0, 0, 32, 33, 0, 138, 59,
+ 58, 109, 0, 35, 36, 37, 0, 0, 0, 0,
+ 0, 110, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 111, 112, 0, 113, 114, 115,
+ 116, 117, 118, 119, 14, 15, 0, 16, 0, 0,
+ 0, 0, 0, 0, 18, 19, 0, 20, 0, 21,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 22, 0, 0,
+ 0, 0, 0, 0, 0, 23, 24, 25, 26, 27,
+ 28, 0, 120, 0, 29, 0, 30, 31, 0, 0,
+ 32, 33, 58, 109, 59, 0, 139, 0, 35, 36,
+ 37, 0, 0, 110, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 111, 112, 0, 113,
+ 114, 115, 116, 117, 118, 119, 14, 15, 0, 16,
+ 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, 0, 120, 0, 29, 0, 30, 31,
+ 0, 0, 32, 33, 58, 109, 59, 0, 0, 0,
+ 35, 36, 37, 0, 0, 110, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 111, 112,
+ 0, 113, 114, 115, 116, 117, 118, 119, 14, 15,
+ 0, 16, 0, 0, 0, 0, 0, 0, 18, 19,
+ 0, 20, 0, 21, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 23,
+ 24, 25, 26, 27, 28, 0, 120, 268, 29, 0,
+ 30, 31, 0, 0, 32, 33, 58, 109, 59, 0,
+ 275, 0, 35, 36, 37, 0, 0, 110, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 111, 112, 0, 113, 114, 115, 116, 117, 118, 119,
+ 14, 15, 0, 16, 0, 0, 0, 0, 0, 0,
+ 18, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 120, 0,
+ 29, 0, 30, 31, 0, 0, 32, 33, 58, 109,
+ 59, 0, 313, 0, 35, 36, 37, 0, 0, 110,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 111, 112, 0, 113, 114, 115, 116, 117,
+ 118, 119, 14, 15, 0, 16, 0, 0, 0, 0,
+ 0, 0, 18, 19, 0, 20, 0, 21, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 22, 0, 0, 0, 0,
+ 0, 0, 0, 23, 24, 25, 26, 27, 28, 0,
+ 120, 0, 29, 0, 30, 31, 0, 0, 32, 33,
+ 58, 109, 59, 0, 315, 0, 35, 36, 37, 0,
+ 0, 110, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 111, 112, 0, 113, 114, 115,
+ 116, 117, 118, 119, 14, 15, 0, 16, 0, 0,
+ 0, 0, 0, 0, 18, 19, 0, 20, 0, 21,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 22, 0, 0,
+ 0, 0, 0, 0, 0, 23, 24, 25, 26, 27,
+ 28, 0, 120, 0, 29, 0, 30, 31, 0, 0,
+ 32, 33, 58, 109, 59, 0, 349, 0, 35, 36,
+ 37, 0, 0, 110, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 111, 112, 0, 113,
+ 114, 115, 116, 117, 118, 119, 14, 15, 0, 16,
+ 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
+ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, 0, 120, 0, 29, 0, 30, 31,
+ 0, 0, 32, 33, 58, 109, 59, 0, 351, 0,
+ 35, 36, 37, 0, 0, 110, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 111, 112,
+ 0, 113, 114, 115, 116, 117, 118, 119, 14, 15,
+ 0, 16, 0, 0, 0, 0, 0, 0, 18, 19,
+ 0, 20, 0, 21, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 23,
+ 24, 25, 26, 27, 28, 0, 120, 0, 29, 0,
+ 30, 31, 0, 0, 32, 33, 0, 0, 59, 58,
+ 109, 353, 35, 36, 37, 0, 0, 0, 0, 0,
+ 110, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 111, 112, 0, 113, 114, 115, 116,
+ 117, 118, 119, 14, 15, 0, 16, 0, 0, 0,
+ 0, 0, 0, 18, 19, 0, 20, 0, 21, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 22, 0, 0, 0,
+ 0, 0, 0, 0, 23, 24, 25, 26, 27, 28,
+ 0, 120, 0, 29, 0, 30, 31, 0, 0, 32,
+ 33, 58, 109, 59, 0, 362, 0, 35, 36, 37,
+ 0, 0, 110, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 111, 112, 0, 113, 114,
+ 115, 116, 117, 118, 119, 14, 15, 0, 16, 0,
+ 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
+ 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 22, 0,
+ 0, 0, 0, 0, 0, 0, 23, 24, 25, 26,
+ 27, 28, 0, 120, 0, 29, 0, 30, 31, 0,
+ 0, 32, 33, 58, 109, 59, 0, 0, 0, 35,
+ 36, 37, 0, 0, 110, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 111, 112, 0,
+ 113, 114, 115, 116, 117, 118, 119, 14, 15, 0,
+ 16, 0, 0, 0, 0, 0, 0, 18, 19, 0,
+ 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 22, 0, 0, 0, 0, 0, 0, 0, 23, 24,
+ 25, 26, 27, 28, 0, 120, 0, 29, 0, 30,
+ 31, 0, 0, 32, 33, 58, 109, 59, 0, 0,
+ 0, 35, 36, 37, 0, 0, 110, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 111,
+ 0, 0, 113, 114, 115, 116, 117, 118, 119, 14,
+ 15, 0, 16, 0, 0, 0, 0, 0, 0, 18,
+ 19, 0, 20, 0, 21, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 22, 0, 0, 0, 0, 0, 0, 0,
+ 23, 24, 25, 26, 27, 28, 58, 109, 0, 29,
+ 0, 30, 31, 0, 0, 32, 33, 110, 0, 59,
+ 0, 0, 0, 35, 36, 37, 0, 0, 0, 0,
+ 0, 0, 0, 113, 114, 115, 116, 117, 118, 119,
+ 14, 15, 0, 16, 0, 0, 0, 0, 0, 0,
+ 18, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 23, 24, 25, 26, 27, 28, 58, -32, 0,
+ 29, 0, 30, 31, 0, 0, 32, 33, -32, 0,
+ 59, 0, 0, 0, 35, 36, 37, 0, 0, 0,
+ 0, 0, 0, 0, -32, -32, -32, -32, -32, -32,
+ -32, 14, 15, 0, 16, 0, 0, 0, 0, 0,
+ 0, 18, 19, 0, 20, 58, 21, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 253, 0, 0, 0,
+ 0, 0, 0, 0, 22, 0, 0, 0, 0, 111,
+ 112, 0, 23, 24, 25, 26, 27, 28, 254, 14,
+ 15, 0, 16, 30, 31, 0, 0, 32, 33, 18,
+ 19, 59, 20, 0, 21, 35, 36, 37, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 22, 0, 0, 0, 0, 0, 0, 0,
+ 23, 24, 25, 26, 27, 28, 58, 255, 328, 29,
+ 0, 30, 31, 0, 0, 32, 33, 253, 0, 59,
+ 0, 0, 0, 35, 36, 37, 0, 0, 0, 0,
+ 111, 112, 0, 0, 0, 0, 0, 0, 0, 254,
+ 14, 15, 0, 16, 0, 0, 0, 0, 0, 0,
+ 18, 19, 0, 20, 0, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 58, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 255, 253,
+ 29, 0, 30, 31, 0, 0, 32, 33, 0, 0,
+ 59, 0, 111, 0, 35, 36, 37, 0, 0, 0,
+ 0, 254, 14, 15, 0, 16, 0, 0, 0, 0,
+ 0, 0, 18, 19, 0, 20, 12, 21, 0, 13,
+ 144, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 22, 0, 0, 0, 0,
+ 0, 0, 0, 23, 24, 25, 26, 27, 28, 0,
+ 14, 15, 29, 16, 30, 31, 0, 0, 32, 33,
+ 18, 19, 59, 20, 0, 21, 35, 36, 37, 0,
+ 0, 0, 0, 0, 12, 0, 0, 13, 152, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 0, 0,
+ 29, 0, 30, 31, 0, 0, 32, 33, 14, 15,
+ 34, 16, 0, 0, 35, 36, 37, 0, 18, 19,
+ 0, 20, 58, 21, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 253, 0, 0, 0, 0, 0, 0,
+ 0, 22, 0, 0, 0, 0, 0, 0, 0, 23,
+ 24, 25, 26, 27, 28, 254, 14, 15, 29, 16,
+ 30, 31, 0, 0, 32, 33, 18, 19, 34, 20,
+ 0, 21, 35, 36, 37, 0, 0, 0, 0, 0,
+ 12, 0, 0, 13, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, 0, 0, 0, 29, 0, 30, 31,
+ 0, 0, 32, 33, 14, 15, 59, 16, 0, 0,
+ 35, 36, 37, 0, 18, 19, 0, 20, 58, 21,
+ 0, 13, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 22, 0, 0,
+ 0, 0, 0, 0, 0, 23, 24, 25, 26, 27,
+ 28, 0, 14, 15, 29, 16, 30, 31, 0, 0,
+ 32, 33, 18, 19, 34, 20, 0, 21, 35, 36,
+ 37, 0, 0, 0, 0, 0, 179, 0, 0, 13,
+ 0, 0, 0, 0, 0, 22, 0, 0, 0, 0,
+ 0, 0, 0, 23, 24, 25, 26, 27, 28, 0,
+ 0, 0, 29, 0, 30, 31, 0, 0, 32, 33,
+ 14, 15, 34, 16, 0, 0, 35, 36, 37, 0,
+ 18, 19, 0, 20, 58, 21, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 0, 0, 0, 0, 0, 0,
+ 0, 23, 24, 25, 26, 27, 28, 0, 14, 15,
+ 29, 16, 30, 31, 0, 0, 32, 33, 18, 19,
+ 34, 20, 0, 21, 35, 36, 37, 0, 0, 0,
+ 0, 0, 210, 0, 0, 0, 0, 0, 0, 0,
+ 0, 22, 294, 0, 0, 13, 0, 0, 0, 23,
+ 24, 25, 26, 27, 28, 0, 0, 0, 29, 0,
+ 30, 31, 0, 0, 32, 33, 0, 0, 59, 0,
+ 0, 0, 35, 36, 37, 0, 14, 15, 0, 16,
+ 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
+ 58, 21, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, -32, 0, 0, 0, 0, 0, 0, 0, 22,
+ 0, 0, 0, 0, 0, 0, 0, 23, 24, 25,
+ 26, 27, 28, -32, 14, 15, 29, 16, 30, 31,
+ 0, 0, 32, 33, 18, 19, 34, 20, 58, 21,
+ 35, 36, 37, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 22, 0, 0,
+ 0, 0, 0, 0, 0, 23, 24, 25, 26, 27,
+ 28, 0, 14, 15, 0, 16, 30, 31, 0, 0,
+ 32, 33, 18, 19, 59, 20, 0, 21, 35, 36,
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 22, 0, 0, 0, 0,
+ 0, 0, 0, 23, 24, 25, 26, 27, 28, 0,
+ 0, 0, 29, 0, 30, 31, 0, 0, 32, 33,
+ 0, 0, 59, 0, 0, 0, 35, 36, 37
+};
+
+static const yytype_int16 yycheck[] =
+{
+ 16, 5, 34, 168, 179, 9, 10, 18, 110, 82,
+ 0, 9, 15, 29, 11, 9, 32, 33, 34, 35,
+ 36, 37, 124, 338, 67, 68, 42, 52, 53, 244,
+ 92, 246, 46, 106, 45, 39, 70, 10, 54, 106,
+ 70, 12, 9, 59, 84, 360, 19, 87, 46, 10,
+ 90, 91, 12, 69, 94, 16, 12, 10, 15, 54,
+ 55, 253, 102, 255, 256, 257, 19, 259, 12, 101,
+ 13, 263, 10, 87, 99, 89, 110, 111, 16, 46,
+ 110, 111, 107, 12, 100, 101, 10, 11, 161, 87,
+ 10, 89, 135, 87, 161, 38, 16, 10, 41, 102,
+ 103, 104, 105, 16, 108, 87, 109, 12, 90, 324,
+ 126, 127, 128, 129, 130, 131, 12, 10, 12, 294,
+ 87, 88, 89, 16, 43, 12, 166, 46, 230, 231,
+ 146, 147, 172, 149, 150, 18, 328, 352, 10, 155,
+ 156, 157, 110, 111, 16, 112, 93, 104, 105, 364,
+ 166, 253, 109, 10, 149, 150, 172, 10, 43, 16,
+ 9, 156, 157, 16, 180, 14, 9, 9, 87, 88,
+ 89, 14, 14, 338, 109, 9, 12, 193, 194, 180,
+ 196, 197, 198, 199, 200, 201, 181, 203, 85, 205,
+ 12, 207, 208, 112, 210, 360, 239, 9, 12, 9,
+ 45, 217, 14, 87, 96, 9, 222, 15, 224, 18,
+ 80, 10, 285, 208, 209, 9, 318, 14, 285, 9,
+ 16, 253, 119, 255, 256, 257, 180, 259, 244, 16,
+ 246, 263, 100, 16, 229, 12, 16, 253, 45, 255,
+ 256, 257, 16, 259, 260, 261, 262, 263, 16, 322,
+ 41, 190, 16, 108, -1, 322, -1, 252, 274, -1,
+ -1, 265, 278, -1, 280, -1, -1, 283, 32, 33,
+ 34, 168, -1, 37, -1, -1, -1, -1, 42, 295,
+ 353, 306, 298, 299, 300, 301, 353, 282, 283, 305,
+ 54, 307, 308, 309, 295, 59, 328, 298, 299, 300,
+ 301, -1, -1, -1, 305, 69, -1, 46, 312, 334,
+ -1, -1, 328, 308, 309, 331, -1, 333, -1, 335,
+ -1, 337, 362, 339, -1, -1, 223, -1, 344, -1,
+ -1, -1, 327, -1, -1, -1, 100, 101, 235, 355,
+ -1, 295, -1, 344, 298, 299, 300, 301, 87, 88,
+ 89, 305, -1, -1, -1, -1, -1, 254, -1, -1,
+ -1, -1, 126, 127, 128, 129, 130, 131, -1, -1,
+ -1, -1, -1, 112, -1, -1, -1, -1, -1, -1,
+ -1, -1, 146, 147, -1, 149, 150, -1, -1, 286,
+ 344, 155, 156, 157, -1, -1, -1, -1, -1, -1,
+ -1, -1, 166, -1, -1, -1, -1, -1, 172, -1,
+ -1, -1, -1, -1, -1, -1, 180, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 326,
+ 194, -1, 196, 197, 198, 199, 200, 201, -1, 203,
+ -1, 205, -1, 207, 208, -1, 210, -1, -1, -1,
+ -1, -1, -1, 217, -1, -1, -1, -1, 222, -1,
+ 224, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 98,
+ 244, -1, 246, -1, -1, 104, -1, 5, -1, 253,
+ -1, 255, 256, 257, 12, 259, 260, 261, 262, 263,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 274, -1, -1, -1, 278, -1, 280, 136, 137, 283,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 295, -1, -1, 298, 299, 300, 301, -1, 57,
+ 58, 305, -1, 307, 308, 309, -1, 65, 66, 67,
+ 68, -1, -1, 71, 72, -1, -1, 176, -1, 178,
+ -1, -1, -1, -1, 328, -1, -1, -1, -1, 87,
+ 189, 335, 191, 337, -1, 339, 94, -1, -1, -1,
+ 344, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 108, 355, 110, -1, -1, 113, 114, 115, 116, 117,
+ 118, -1, 120, 121, 122, -1, 124, -1, -1, -1,
+ -1, -1, -1, -1, 132, -1, -1, 135, -1, -1,
+ -1, -1, 140, -1, 142, -1, -1, -1, -1, -1,
+ 249, -1, -1, -1, -1, 0, 1, -1, -1, -1,
+ -1, -1, 7, 8, 9, -1, 11, 12, -1, 14,
+ 15, 169, -1, -1, -1, -1, 174, -1, -1, -1,
+ -1, 179, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 190, -1, -1, -1, -1, -1, -1, -1,
+ -1, 46, 47, -1, 49, -1, -1, -1, -1, -1,
+ 55, 56, 57, -1, 59, -1, 61, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 227,
+ 329, -1, 230, 231, 79, -1, -1, -1, 236, -1,
+ -1, 239, 87, 88, 89, 90, 91, 92, -1, 348,
+ -1, 96, -1, 98, 99, 354, -1, 102, 103, -1,
+ -1, 106, -1, -1, 363, 110, 111, 112, -1, 368,
+ 268, 269, 270, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 1, -1, -1, -1, -1, -1,
+ -1, -1, 9, -1, 11, 12, 294, 14, 15, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 318, -1, 320, -1, -1, 323, -1, -1, -1, 46,
+ 47, 48, 49, 50, 51, 52, 53, 54, -1, 56,
+ 57, 58, 59, 341, 61, 62, 63, -1, -1, -1,
+ -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
+ 77, 78, 79, 11, 12, -1, 14, 15, -1, 17,
+ 87, 88, 89, 90, 91, 92, -1, -1, -1, 96,
+ 97, 98, 99, 100, -1, 102, 103, -1, -1, 106,
+ -1, -1, -1, 110, 111, 112, -1, -1, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, -1, 56, 57,
+ 58, 59, -1, 61, 62, 63, -1, -1, -1, -1,
+ -1, -1, 1, -1, -1, -1, -1, -1, -1, 77,
+ 78, 79, 11, 12, -1, 14, 15, -1, 17, 87,
+ 88, 89, 90, 91, 92, -1, -1, -1, 96, 97,
+ 98, 99, 100, -1, 102, 103, -1, -1, 106, -1,
+ -1, -1, 110, 111, 112, -1, -1, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, -1, 56, 57, 58,
+ 59, -1, 61, 62, 63, -1, -1, -1, -1, -1,
+ -1, 1, -1, -1, -1, -1, -1, -1, 77, 78,
+ 79, 11, 12, -1, 14, 15, -1, 17, 87, 88,
+ 89, 90, 91, 92, -1, -1, -1, 96, 97, 98,
+ 99, 100, -1, 102, 103, -1, -1, 106, -1, -1,
+ -1, 110, 111, 112, -1, -1, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54, -1, 56, 57, 58, 59,
+ -1, 61, 62, 63, -1, -1, -1, -1, -1, -1,
+ 1, -1, -1, -1, -1, -1, -1, 77, 78, 79,
+ 11, 12, -1, 14, 15, -1, 17, 87, 88, 89,
+ 90, 91, 92, -1, -1, -1, 96, 97, 98, 99,
+ 100, -1, 102, 103, -1, -1, 106, -1, -1, -1,
+ 110, 111, 112, -1, -1, 46, 47, 48, 49, 50,
+ 51, 52, 53, 54, -1, 56, 57, 58, 59, -1,
+ 61, 62, 63, -1, -1, -1, -1, -1, -1, 1,
+ -1, -1, -1, -1, -1, -1, 77, 78, 79, 11,
+ 12, -1, 14, 15, -1, 17, 87, 88, 89, 90,
+ 91, 92, -1, -1, -1, 96, 97, 98, 99, 100,
+ -1, 102, 103, -1, -1, 106, -1, -1, -1, 110,
+ 111, 112, -1, -1, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, -1, 56, 57, 58, 59, -1, 61,
+ 62, 63, -1, -1, -1, -1, -1, -1, -1, -1,
+ 1, -1, -1, -1, -1, 77, 78, 79, 9, -1,
+ 11, 12, -1, 14, 15, 87, 88, 89, 90, 91,
+ 92, -1, -1, -1, 96, 97, 98, 99, 100, -1,
+ 102, 103, -1, -1, 106, -1, -1, -1, 110, 111,
+ 112, -1, -1, -1, -1, 46, 47, 48, 49, 50,
+ 51, 52, 53, 54, -1, 56, 57, 58, 59, -1,
+ 61, 62, 63, -1, -1, -1, -1, -1, -1, 1,
+ -1, -1, -1, -1, -1, -1, 77, 78, 79, 11,
+ 12, -1, 14, 15, -1, 17, 87, 88, 89, 90,
+ 91, 92, -1, -1, -1, 96, 97, 98, 99, 100,
+ -1, 102, 103, -1, -1, 106, -1, -1, -1, 110,
+ 111, 112, -1, -1, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, -1, 56, 57, 58, 59, -1, 61,
+ 62, 63, -1, -1, -1, -1, -1, -1, 1, -1,
+ -1, -1, -1, -1, -1, 77, 78, 79, 11, 12,
+ -1, 14, 15, -1, 17, 87, 88, 89, 90, 91,
+ 92, -1, -1, -1, 96, 97, 98, 99, 100, -1,
+ 102, 103, -1, -1, 106, -1, -1, -1, 110, 111,
+ 112, -1, -1, 46, 47, 48, 49, 50, 51, 52,
+ 53, 54, -1, 56, 57, 58, 59, -1, 61, 62,
+ 63, -1, -1, -1, -1, -1, -1, 1, -1, -1,
+ -1, -1, -1, -1, 77, 78, 79, 11, 12, -1,
+ 14, 15, -1, -1, 87, 88, 89, 90, 91, 92,
+ -1, -1, -1, 96, 97, 98, 99, 100, -1, 102,
+ 103, -1, -1, 106, -1, -1, -1, 110, 111, 112,
+ -1, -1, 46, 47, 48, 49, 50, 51, 52, 53,
+ 54, -1, 56, 57, 58, 59, -1, 61, 62, 63,
+ -1, -1, -1, -1, -1, 1, -1, -1, -1, -1,
+ -1, -1, -1, 77, 78, 79, 12, -1, 14, 15,
+ -1, -1, -1, 87, 88, 89, 90, 91, 92, -1,
+ -1, -1, 96, 97, 98, 99, 100, -1, 102, 103,
+ -1, -1, 106, -1, -1, -1, 110, 111, 112, -1,
+ 46, 47, -1, 49, -1, 51, -1, -1, -1, -1,
+ 56, 57, -1, 59, -1, 61, -1, -1, -1, -1,
+ -1, -1, -1, 1, -1, -1, -1, -1, -1, -1,
+ -1, 77, 78, 79, 12, -1, -1, 15, 16, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, -1, -1,
+ 96, -1, 98, 99, -1, -1, 102, 103, -1, -1,
+ 106, -1, -1, -1, 110, 111, 112, -1, 46, 47,
+ -1, 49, -1, 51, -1, -1, -1, -1, 56, 57,
+ -1, 59, -1, 61, -1, -1, -1, 7, 8, -1,
+ -1, 11, 12, -1, -1, 15, -1, -1, -1, 77,
+ 78, 79, -1, -1, -1, -1, -1, -1, -1, 87,
+ 88, 89, 90, 91, 92, -1, -1, -1, 96, -1,
+ 98, 99, -1, -1, 102, 103, 46, 47, 106, 49,
+ -1, -1, 110, 111, 112, 55, 56, 57, -1, 59,
+ -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, -1, -1, -1, 96, -1, 98, 99,
+ -1, -1, 102, 103, 9, -1, 106, 12, 13, 14,
+ 110, 111, 112, -1, -1, -1, -1, -1, 23, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 36, 37, -1, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, -1, 49, -1, -1, -1, -1, -1,
+ -1, 56, 57, -1, 59, -1, 61, -1, -1, -1,
+ -1, -1, 9, -1, -1, 12, -1, 14, 15, -1,
+ -1, -1, -1, -1, 79, -1, -1, -1, -1, -1,
+ -1, -1, 87, 88, 89, 90, 91, 92, -1, 94,
+ -1, 96, -1, 98, 99, -1, -1, 102, 103, 46,
+ 47, 106, 49, -1, -1, 110, 111, 112, -1, 56,
+ 57, -1, 59, -1, 61, -1, -1, -1, -1, -1,
+ 9, -1, -1, 12, -1, -1, 15, -1, -1, -1,
+ -1, -1, 79, -1, -1, -1, -1, -1, -1, -1,
+ 87, 88, 89, 90, 91, 92, -1, -1, -1, 96,
+ -1, 98, 99, -1, -1, 102, 103, 46, 47, 106,
+ 49, -1, -1, 110, 111, 112, -1, 56, 57, -1,
+ 59, -1, 61, -1, -1, -1, -1, -1, 9, -1,
+ -1, 12, -1, -1, 15, -1, -1, -1, -1, -1,
+ 79, -1, -1, -1, -1, -1, -1, -1, 87, 88,
+ 89, 90, 91, 92, -1, -1, -1, 96, -1, 98,
+ 99, -1, -1, 102, 103, 46, 47, 106, 49, -1,
+ -1, 110, 111, 112, -1, 56, 57, -1, 59, -1,
+ 61, -1, -1, -1, -1, -1, 9, -1, -1, 12,
+ -1, -1, 15, -1, -1, -1, -1, -1, 79, -1,
+ -1, -1, -1, -1, -1, -1, 87, 88, 89, 90,
+ 91, 92, -1, -1, -1, 96, -1, 98, 99, -1,
+ -1, 102, 103, 46, 47, 106, 49, -1, -1, 110,
+ 111, 112, -1, 56, 57, -1, 59, -1, 61, -1,
+ -1, -1, -1, -1, 9, -1, -1, 12, -1, -1,
+ 15, -1, -1, -1, -1, -1, 79, -1, -1, -1,
+ -1, -1, -1, -1, 87, 88, 89, 90, 91, 92,
+ -1, -1, -1, 96, -1, 98, 99, -1, -1, 102,
+ 103, 46, 47, 106, 49, -1, -1, 110, 111, 112,
+ -1, 56, 57, -1, 59, -1, 61, -1, -1, -1,
+ -1, -1, 9, -1, -1, 12, -1, -1, 15, -1,
+ -1, -1, -1, -1, 79, -1, -1, -1, -1, -1,
+ -1, -1, 87, 88, 89, 90, 91, 92, -1, -1,
+ -1, 96, -1, 98, 99, -1, -1, 102, 103, 46,
+ 47, 106, 49, -1, -1, 110, 111, 112, -1, 56,
+ 57, -1, 59, -1, 61, -1, -1, -1, -1, -1,
+ 9, -1, -1, 12, -1, -1, 15, -1, -1, -1,
+ -1, -1, 79, -1, -1, -1, -1, -1, -1, -1,
+ 87, 88, 89, 90, 91, 92, -1, -1, -1, 96,
+ -1, 98, 99, -1, -1, 102, 103, 46, 47, 106,
+ 49, -1, -1, 110, 111, 112, -1, 56, 57, -1,
+ 59, -1, 61, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 79, -1, -1, -1, -1, -1, -1, -1, 87, 88,
+ 89, 90, 91, 92, -1, -1, -1, 96, -1, 98,
+ 99, -1, -1, 102, 103, -1, -1, 106, -1, -1,
+ -1, 110, 111, 112, 10, -1, 12, 13, -1, -1,
+ 16, -1, -1, -1, -1, -1, -1, 23, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 36, 37, -1, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, -1, 49, -1, -1, -1, -1, -1, -1,
+ 56, 57, -1, 59, -1, 61, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, -1, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, 94, -1,
+ 96, -1, 98, 99, -1, -1, 102, 103, -1, -1,
+ 106, -1, -1, -1, 110, 111, 112, 10, -1, 12,
+ 13, -1, -1, 16, -1, -1, -1, -1, -1, -1,
+ 23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 36, 37, -1, 39, 40, 41, 42,
+ 43, 44, 45, 46, 47, -1, 49, -1, -1, -1,
+ -1, -1, -1, 56, 57, -1, 59, -1, 61, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 79, -1, -1, -1,
+ -1, -1, -1, -1, 87, 88, 89, 90, 91, 92,
+ -1, 94, -1, 96, -1, 98, 99, -1, -1, 102,
+ 103, -1, -1, 106, -1, -1, -1, 110, 111, 112,
+ 10, -1, 12, 13, -1, -1, 16, -1, -1, -1,
+ -1, -1, -1, 23, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 36, 37, -1, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, -1, 49,
+ -1, -1, -1, -1, -1, -1, 56, 57, -1, 59,
+ -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, -1, 94, -1, 96, -1, 98, 99,
+ -1, -1, 102, 103, -1, -1, 106, -1, -1, -1,
+ 110, 111, 112, 10, -1, 12, 13, -1, -1, 16,
+ -1, -1, -1, -1, -1, -1, 23, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
+ 37, -1, 39, 40, 41, 42, 43, 44, 45, 46,
+ 47, -1, 49, -1, -1, -1, -1, -1, -1, 56,
+ 57, -1, 59, -1, 61, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 79, -1, -1, -1, -1, -1, -1, -1,
+ 87, 88, 89, 90, 91, 92, -1, 94, -1, 96,
+ -1, 98, 99, -1, -1, 102, 103, -1, 10, 106,
+ 12, 13, -1, 110, 111, 112, -1, -1, -1, -1,
+ -1, 23, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 36, 37, -1, 39, 40, 41,
+ 42, 43, 44, 45, 46, 47, -1, 49, -1, -1,
+ -1, -1, -1, -1, 56, 57, -1, 59, -1, 61,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 79, -1, -1,
+ -1, -1, -1, -1, -1, 87, 88, 89, 90, 91,
+ 92, -1, 94, -1, 96, -1, 98, 99, -1, -1,
+ 102, 103, 12, 13, 106, -1, 16, -1, 110, 111,
+ 112, -1, -1, 23, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 36, 37, -1, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, -1, 49,
+ -1, -1, -1, -1, -1, -1, 56, 57, -1, 59,
+ -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, -1, 94, -1, 96, -1, 98, 99,
+ -1, -1, 102, 103, 12, 13, 106, -1, -1, -1,
+ 110, 111, 112, -1, -1, 23, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 36, 37,
+ -1, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ -1, 49, -1, -1, -1, -1, -1, -1, 56, 57,
+ -1, 59, -1, 61, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 79, -1, -1, -1, -1, -1, -1, -1, 87,
+ 88, 89, 90, 91, 92, -1, 94, 95, 96, -1,
+ 98, 99, -1, -1, 102, 103, 12, 13, 106, -1,
+ 16, -1, 110, 111, 112, -1, -1, 23, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 36, 37, -1, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, -1, 49, -1, -1, -1, -1, -1, -1,
+ 56, 57, -1, 59, -1, 61, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, -1, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, 94, -1,
+ 96, -1, 98, 99, -1, -1, 102, 103, 12, 13,
+ 106, -1, 16, -1, 110, 111, 112, -1, -1, 23,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 36, 37, -1, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, -1, 49, -1, -1, -1, -1,
+ -1, -1, 56, 57, -1, 59, -1, 61, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 79, -1, -1, -1, -1,
+ -1, -1, -1, 87, 88, 89, 90, 91, 92, -1,
+ 94, -1, 96, -1, 98, 99, -1, -1, 102, 103,
+ 12, 13, 106, -1, 16, -1, 110, 111, 112, -1,
+ -1, 23, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 36, 37, -1, 39, 40, 41,
+ 42, 43, 44, 45, 46, 47, -1, 49, -1, -1,
+ -1, -1, -1, -1, 56, 57, -1, 59, -1, 61,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 79, -1, -1,
+ -1, -1, -1, -1, -1, 87, 88, 89, 90, 91,
+ 92, -1, 94, -1, 96, -1, 98, 99, -1, -1,
+ 102, 103, 12, 13, 106, -1, 16, -1, 110, 111,
+ 112, -1, -1, 23, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 36, 37, -1, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, -1, 49,
+ -1, -1, -1, -1, -1, -1, 56, 57, -1, 59,
+ -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, -1, 94, -1, 96, -1, 98, 99,
+ -1, -1, 102, 103, 12, 13, 106, -1, 16, -1,
+ 110, 111, 112, -1, -1, 23, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 36, 37,
+ -1, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ -1, 49, -1, -1, -1, -1, -1, -1, 56, 57,
+ -1, 59, -1, 61, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 79, -1, -1, -1, -1, -1, -1, -1, 87,
+ 88, 89, 90, 91, 92, -1, 94, -1, 96, -1,
+ 98, 99, -1, -1, 102, 103, -1, -1, 106, 12,
+ 13, 14, 110, 111, 112, -1, -1, -1, -1, -1,
+ 23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 36, 37, -1, 39, 40, 41, 42,
+ 43, 44, 45, 46, 47, -1, 49, -1, -1, -1,
+ -1, -1, -1, 56, 57, -1, 59, -1, 61, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 79, -1, -1, -1,
+ -1, -1, -1, -1, 87, 88, 89, 90, 91, 92,
+ -1, 94, -1, 96, -1, 98, 99, -1, -1, 102,
+ 103, 12, 13, 106, -1, 16, -1, 110, 111, 112,
+ -1, -1, 23, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 36, 37, -1, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, -1, 49, -1,
+ -1, -1, -1, -1, -1, 56, 57, -1, 59, -1,
+ 61, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 79, -1,
+ -1, -1, -1, -1, -1, -1, 87, 88, 89, 90,
+ 91, 92, -1, 94, -1, 96, -1, 98, 99, -1,
+ -1, 102, 103, 12, 13, 106, -1, -1, -1, 110,
+ 111, 112, -1, -1, 23, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 36, 37, -1,
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, -1,
+ 49, -1, -1, -1, -1, -1, -1, 56, 57, -1,
+ 59, -1, 61, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 79, -1, -1, -1, -1, -1, -1, -1, 87, 88,
+ 89, 90, 91, 92, -1, 94, -1, 96, -1, 98,
+ 99, -1, -1, 102, 103, 12, 13, 106, -1, -1,
+ -1, 110, 111, 112, -1, -1, 23, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
+ -1, -1, 39, 40, 41, 42, 43, 44, 45, 46,
+ 47, -1, 49, -1, -1, -1, -1, -1, -1, 56,
+ 57, -1, 59, -1, 61, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 79, -1, -1, -1, -1, -1, -1, -1,
+ 87, 88, 89, 90, 91, 92, 12, 13, -1, 96,
+ -1, 98, 99, -1, -1, 102, 103, 23, -1, 106,
+ -1, -1, -1, 110, 111, 112, -1, -1, -1, -1,
+ -1, -1, -1, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, -1, 49, -1, -1, -1, -1, -1, -1,
+ 56, 57, -1, 59, -1, 61, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, -1, -1,
+ -1, 87, 88, 89, 90, 91, 92, 12, 13, -1,
+ 96, -1, 98, 99, -1, -1, 102, 103, 23, -1,
+ 106, -1, -1, -1, 110, 111, 112, -1, -1, -1,
+ -1, -1, -1, -1, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, -1, 49, -1, -1, -1, -1, -1,
+ -1, 56, 57, -1, 59, 12, 61, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 23, -1, -1, -1,
+ -1, -1, -1, -1, 79, -1, -1, -1, -1, 36,
+ 37, -1, 87, 88, 89, 90, 91, 92, 45, 46,
+ 47, -1, 49, 98, 99, -1, -1, 102, 103, 56,
+ 57, 106, 59, -1, 61, 110, 111, 112, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 79, -1, -1, -1, -1, -1, -1, -1,
+ 87, 88, 89, 90, 91, 92, 12, 94, 95, 96,
+ -1, 98, 99, -1, -1, 102, 103, 23, -1, 106,
+ -1, -1, -1, 110, 111, 112, -1, -1, -1, -1,
+ 36, 37, -1, -1, -1, -1, -1, -1, -1, 45,
+ 46, 47, -1, 49, -1, -1, -1, -1, -1, -1,
+ 56, 57, -1, 59, -1, 61, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, 12, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, 94, 23,
+ 96, -1, 98, 99, -1, -1, 102, 103, -1, -1,
+ 106, -1, 36, -1, 110, 111, 112, -1, -1, -1,
+ -1, 45, 46, 47, -1, 49, -1, -1, -1, -1,
+ -1, -1, 56, 57, -1, 59, 12, 61, -1, 15,
+ 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 79, -1, -1, -1, -1,
+ -1, -1, -1, 87, 88, 89, 90, 91, 92, -1,
+ 46, 47, 96, 49, 98, 99, -1, -1, 102, 103,
+ 56, 57, 106, 59, -1, 61, 110, 111, 112, -1,
+ -1, -1, -1, -1, 12, -1, -1, 15, 16, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, -1, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, -1, -1,
+ 96, -1, 98, 99, -1, -1, 102, 103, 46, 47,
+ 106, 49, -1, -1, 110, 111, 112, -1, 56, 57,
+ -1, 59, 12, 61, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 23, -1, -1, -1, -1, -1, -1,
+ -1, 79, -1, -1, -1, -1, -1, -1, -1, 87,
+ 88, 89, 90, 91, 92, 45, 46, 47, 96, 49,
+ 98, 99, -1, -1, 102, 103, 56, 57, 106, 59,
+ -1, 61, 110, 111, 112, -1, -1, -1, -1, -1,
+ 12, -1, -1, 15, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, -1, -1, -1, 96, -1, 98, 99,
+ -1, -1, 102, 103, 46, 47, 106, 49, -1, -1,
+ 110, 111, 112, -1, 56, 57, -1, 59, 12, 61,
+ -1, 15, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 79, -1, -1,
+ -1, -1, -1, -1, -1, 87, 88, 89, 90, 91,
+ 92, -1, 46, 47, 96, 49, 98, 99, -1, -1,
+ 102, 103, 56, 57, 106, 59, -1, 61, 110, 111,
+ 112, -1, -1, -1, -1, -1, 12, -1, -1, 15,
+ -1, -1, -1, -1, -1, 79, -1, -1, -1, -1,
+ -1, -1, -1, 87, 88, 89, 90, 91, 92, -1,
+ -1, -1, 96, -1, 98, 99, -1, -1, 102, 103,
+ 46, 47, 106, 49, -1, -1, 110, 111, 112, -1,
+ 56, 57, -1, 59, 12, 61, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 79, -1, -1, -1, -1, -1, -1,
+ -1, 87, 88, 89, 90, 91, 92, -1, 46, 47,
+ 96, 49, 98, 99, -1, -1, 102, 103, 56, 57,
+ 106, 59, -1, 61, 110, 111, 112, -1, -1, -1,
+ -1, -1, 70, -1, -1, -1, -1, -1, -1, -1,
+ -1, 79, 12, -1, -1, 15, -1, -1, -1, 87,
+ 88, 89, 90, 91, 92, -1, -1, -1, 96, -1,
+ 98, 99, -1, -1, 102, 103, -1, -1, 106, -1,
+ -1, -1, 110, 111, 112, -1, 46, 47, -1, 49,
+ -1, -1, -1, -1, -1, -1, 56, 57, -1, 59,
+ 12, 61, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 23, -1, -1, -1, -1, -1, -1, -1, 79,
+ -1, -1, -1, -1, -1, -1, -1, 87, 88, 89,
+ 90, 91, 92, 45, 46, 47, 96, 49, 98, 99,
+ -1, -1, 102, 103, 56, 57, 106, 59, 12, 61,
+ 110, 111, 112, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 79, -1, -1,
+ -1, -1, -1, -1, -1, 87, 88, 89, 90, 91,
+ 92, -1, 46, 47, -1, 49, 98, 99, -1, -1,
+ 102, 103, 56, 57, 106, 59, -1, 61, 110, 111,
+ 112, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 79, -1, -1, -1, -1,
+ -1, -1, -1, 87, 88, 89, 90, 91, 92, -1,
+ -1, -1, 96, -1, 98, 99, -1, -1, 102, 103,
+ -1, -1, 106, -1, -1, -1, 110, 111, 112
+};
+
+/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
+ state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 1, 9, 14, 115, 130, 132, 144, 0, 7,
+ 8, 11, 12, 15, 46, 47, 49, 55, 56, 57,
+ 59, 61, 79, 87, 88, 89, 90, 91, 92, 96,
+ 98, 99, 102, 103, 106, 110, 111, 112, 127, 133,
+ 134, 136, 139, 146, 147, 157, 158, 159, 160, 162,
+ 9, 14, 127, 127, 139, 140, 148, 12, 12, 106,
+ 159, 160, 87, 90, 125, 12, 12, 12, 12, 43,
+ 160, 12, 12, 159, 159, 146, 159, 160, 160, 159,
+ 1, 9, 14, 48, 50, 51, 52, 53, 54, 58,
+ 62, 63, 77, 78, 97, 100, 119, 121, 126, 127,
+ 139, 143, 150, 152, 156, 163, 10, 127, 130, 13,
+ 23, 36, 37, 39, 40, 41, 42, 43, 44, 45,
+ 94, 116, 117, 159, 12, 92, 15, 102, 103, 104,
+ 105, 109, 70, 110, 111, 18, 156, 156, 10, 16,
+ 118, 16, 118, 93, 16, 137, 139, 139, 12, 139,
+ 139, 137, 16, 137, 159, 43, 139, 139, 9, 128,
+ 129, 14, 128, 151, 151, 162, 139, 151, 12, 12,
+ 151, 151, 139, 151, 12, 9, 153, 152, 156, 12,
+ 138, 141, 142, 146, 159, 160, 151, 17, 152, 155,
+ 129, 156, 134, 96, 139, 147, 139, 139, 139, 139,
+ 139, 139, 162, 139, 9, 139, 9, 139, 139, 147,
+ 70, 159, 159, 159, 159, 159, 159, 139, 137, 17,
+ 17, 9, 139, 45, 139, 15, 16, 118, 87, 161,
+ 118, 118, 16, 16, 159, 118, 118, 9, 129, 18,
+ 151, 131, 150, 162, 139, 151, 139, 152, 80, 120,
+ 17, 145, 140, 23, 45, 94, 116, 117, 159, 118,
+ 13, 38, 41, 70, 152, 133, 17, 160, 95, 118,
+ 118, 159, 19, 162, 139, 16, 118, 149, 139, 147,
+ 139, 147, 162, 139, 137, 14, 45, 149, 149, 154,
+ 9, 152, 9, 16, 12, 138, 147, 162, 138, 138,
+ 138, 138, 159, 159, 159, 138, 127, 139, 139, 139,
+ 87, 9, 135, 16, 16, 16, 16, 16, 118, 16,
+ 118, 19, 14, 129, 162, 100, 45, 140, 95, 156,
+ 16, 118, 16, 118, 127, 139, 147, 139, 129, 139,
+ 149, 12, 162, 16, 138, 17, 160, 160, 156, 16,
+ 16, 16, 131, 14, 124, 139, 16, 16, 17, 149,
+ 129, 152, 16, 123, 131, 151, 152, 149, 122, 152
+};
+
+/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 114, 115, 115, 116, 116, 117, 117, 118, 118,
+ 119, 119, 120, 120, 122, 121, 123, 121, 124, 121,
+ 125, 125, 126, 127, 127, 128, 128, 129, 129, 130,
+ 130, 131, 131, 132, 132, 133, 134, 134, 134, 134,
+ 134, 134, 134, 135, 134, 136, 136, 137, 137, 138,
+ 138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
+ 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+ 139, 139, 139, 139, 139, 139, 139, 139, 139, 140,
+ 140, 141, 141, 142, 142, 142, 143, 143, 144, 144,
+ 144, 144, 145, 145, 146, 146, 148, 147, 149, 149,
+ 150, 150, 150, 150, 150, 150, 150, 150, 151, 151,
+ 152, 152, 153, 154, 152, 152, 152, 152, 152, 152,
+ 152, 152, 152, 152, 152, 152, 155, 152, 152, 156,
+ 156, 157, 157, 158, 158, 159, 159, 159, 159, 159,
+ 159, 159, 159, 159, 159, 159, 159, 159, 159, 159,
+ 159, 159, 159, 159, 159, 159, 159, 159, 159, 159,
+ 159, 159, 159, 159, 159, 159, 159, 159, 159, 159,
+ 159, 159, 159, 159, 159, 159, 159, 160, 160, 160,
+ 160, 161, 161, 161, 162, 162, 162, 163
+};
+
+/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
+static const yytype_int8 yyr2[] =
+{
+ 0, 2, 1, 1, 1, 2, 1, 2, 1, 2,
+ 1, 2, 1, 2, 0, 12, 0, 10, 0, 8,
+ 1, 1, 4, 1, 2, 1, 2, 0, 1, 0,
+ 1, 0, 1, 1, 3, 1, 1, 4, 4, 7,
+ 3, 4, 4, 0, 9, 1, 3, 1, 3, 3,
+ 5, 3, 3, 3, 3, 3, 5, 2, 1, 1,
+ 3, 5, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 5, 4, 3, 2, 1, 1, 3,
+ 3, 1, 3, 0, 1, 3, 1, 1, 1, 1,
+ 2, 2, 1, 2, 1, 2, 0, 4, 1, 2,
+ 4, 4, 4, 2, 5, 2, 1, 1, 1, 2,
+ 2, 2, 0, 0, 9, 3, 2, 1, 4, 2,
+ 3, 2, 2, 3, 2, 2, 0, 3, 2, 1,
+ 2, 1, 1, 1, 2, 4, 3, 3, 3, 3,
+ 3, 3, 2, 2, 2, 3, 4, 1, 3, 4,
+ 2, 2, 2, 2, 2, 4, 3, 2, 1, 6,
+ 6, 3, 6, 6, 1, 8, 8, 6, 4, 1,
+ 6, 6, 8, 8, 8, 6, 1, 1, 4, 1,
+ 2, 0, 1, 3, 1, 1, 1, 4
+};
+
+
+enum { YYENOMEM = -2 };
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+#define YYNOMEM goto yyexhaustedlab
+
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
+
+/* Backward compatibility with an undocumented macro.
+ Use YYerror or YYUNDEF. */
+#define YYERRCODE YYUNDEF
+
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
+
+
+
+
+# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Kind, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
+
+
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
+
+static void
+yy_symbol_value_print (FILE *yyo,
+ yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
+{
+ FILE *yyoutput = yyo;
+ YY_USE (yyoutput);
+ if (!yyvaluep)
+ return;
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ YY_USE (yykind);
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+}
+
+
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
+
+static void
+yy_symbol_print (FILE *yyo,
+ yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
+{
+ YYFPRINTF (yyo, "%s %s (",
+ yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
+
+ yy_symbol_value_print (yyo, yykind, yyvaluep);
+ YYFPRINTF (yyo, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+static void
+yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+static void
+yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
+ int yyrule)
+{
+ int yylno = yyrline[yyrule];
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr,
+ YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
+ &yyvsp[(yyi + 1) - (yynrhs)]);
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyssp, yyvsp, Rule); \
+} while (0)
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args) ((void) 0)
+# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+static void
+yydestruct (const char *yymsg,
+ yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
+{
+ YY_USE (yyvaluep);
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
+
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ YY_USE (yykind);
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+}
+
+
+/* Lookahead token kind. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+int
+yyparse (void)
+{
+ yy_state_fast_t yystate = 0;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus = 0;
+
+ /* Refer to the stacks through separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* Their size. */
+ YYPTRDIFF_T yystacksize = YYINITDEPTH;
+
+ /* The state stack: array, bottom, top. */
+ yy_state_t yyssa[YYINITDEPTH];
+ yy_state_t *yyss = yyssa;
+ yy_state_t *yyssp = yyss;
+
+ /* The semantic value stack: array, bottom, top. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ YYSTYPE *yyvsp = yyvs;
+
+ int yyn;
+ /* The return value of yyparse. */
+ int yyresult;
+ /* Lookahead symbol kind. */
+ yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ goto yysetstate;
+
+
+/*------------------------------------------------------------.
+| yynewstate -- push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+
+/*--------------------------------------------------------------------.
+| yysetstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
+ YY_IGNORE_USELESS_CAST_BEGIN
+ *yyssp = YY_CAST (yy_state_t, yystate);
+ YY_IGNORE_USELESS_CAST_END
+ YY_STACK_PRINT (yyss, yyssp);
+
+ if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ YYNOMEM;
+#else
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYPTRDIFF_T yysize = yyssp - yyss + 1;
+
+# if defined yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ yy_state_t *yyss1 = yyss;
+ YYSTYPE *yyvs1 = yyvs;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * YYSIZEOF (*yyssp),
+ &yyvs1, yysize * YYSIZEOF (*yyvsp),
+ &yystacksize);
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+# else /* defined YYSTACK_RELOCATE */
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ YYNOMEM;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yy_state_t *yyss1 = yyss;
+ union yyalloc *yyptr =
+ YY_CAST (union yyalloc *,
+ YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
+ if (! yyptr)
+ YYNOMEM;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YY_IGNORE_USELESS_CAST_BEGIN
+ YYDPRINTF ((stderr, "Stack size increased to %ld\n",
+ YY_CAST (long, yystacksize)));
+ YY_IGNORE_USELESS_CAST_END
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
+
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token\n"));
+ yychar = yylex ();
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = YYEOF;
+ yytoken = YYSYMBOL_YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else if (yychar == YYerror)
+ {
+ /* The scanner already issued an error message, process directly
+ to error recovery. But do not keep the error token as
+ lookahead, it is too special and may lead us to an endless
+ loop in error recovery. */
+ yychar = YYUNDEF;
+ yytoken = YYSYMBOL_YYerror;
+ goto yyerrlab1;
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+ yystate = yyn;
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ '$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 2: /* program: pas */
+#line 99 "awkgram.y"
+ { if (errorflag==0)
+ winner = (Node *)stat3(PROGRAM, beginloc, (yyvsp[0].p), endloc); }
+#line 2343 "awkgram.tab.c"
+ break;
+
+ case 3: /* program: error */
+#line 101 "awkgram.y"
+ { yyclearin; bracecheck(); SYNTAX("bailing out"); }
+#line 2349 "awkgram.tab.c"
+ break;
+
+ case 14: /* $@1: %empty */
+#line 125 "awkgram.y"
+ {inloop++;}
+#line 2355 "awkgram.tab.c"
+ break;
+
+ case 15: /* for: FOR '(' opt_simple_stmt ';' opt_nl pattern ';' opt_nl opt_simple_stmt rparen $@1 stmt */
+#line 126 "awkgram.y"
+ { --inloop; (yyval.p) = stat4(FOR, (yyvsp[-9].p), notnull((yyvsp[-6].p)), (yyvsp[-3].p), (yyvsp[0].p)); }
+#line 2361 "awkgram.tab.c"
+ break;
+
+ case 16: /* $@2: %empty */
+#line 127 "awkgram.y"
+ {inloop++;}
+#line 2367 "awkgram.tab.c"
+ break;
+
+ case 17: /* for: FOR '(' opt_simple_stmt ';' ';' opt_nl opt_simple_stmt rparen $@2 stmt */
+#line 128 "awkgram.y"
+ { --inloop; (yyval.p) = stat4(FOR, (yyvsp[-7].p), NIL, (yyvsp[-3].p), (yyvsp[0].p)); }
+#line 2373 "awkgram.tab.c"
+ break;
+
+ case 18: /* $@3: %empty */
+#line 129 "awkgram.y"
+ {inloop++;}
+#line 2379 "awkgram.tab.c"
+ break;
+
+ case 19: /* for: FOR '(' varname IN varname rparen $@3 stmt */
+#line 130 "awkgram.y"
+ { --inloop; (yyval.p) = stat3(IN, (yyvsp[-5].p), makearr((yyvsp[-3].p)), (yyvsp[0].p)); }
+#line 2385 "awkgram.tab.c"
+ break;
+
+ case 20: /* funcname: VAR */
+#line 134 "awkgram.y"
+ { setfname((yyvsp[0].cp)); }
+#line 2391 "awkgram.tab.c"
+ break;
+
+ case 21: /* funcname: CALL */
+#line 135 "awkgram.y"
+ { setfname((yyvsp[0].cp)); }
+#line 2397 "awkgram.tab.c"
+ break;
+
+ case 22: /* if: IF '(' pattern rparen */
+#line 139 "awkgram.y"
+ { (yyval.p) = notnull((yyvsp[-1].p)); }
+#line 2403 "awkgram.tab.c"
+ break;
+
+ case 27: /* opt_nl: %empty */
+#line 151 "awkgram.y"
+ { (yyval.i) = 0; }
+#line 2409 "awkgram.tab.c"
+ break;
+
+ case 29: /* opt_pst: %empty */
+#line 156 "awkgram.y"
+ { (yyval.i) = 0; }
+#line 2415 "awkgram.tab.c"
+ break;
+
+ case 31: /* opt_simple_stmt: %empty */
+#line 162 "awkgram.y"
+ { (yyval.p) = 0; }
+#line 2421 "awkgram.tab.c"
+ break;
+
+ case 33: /* pas: opt_pst */
+#line 167 "awkgram.y"
+ { (yyval.p) = 0; }
+#line 2427 "awkgram.tab.c"
+ break;
+
+ case 34: /* pas: opt_pst pa_stats opt_pst */
+#line 168 "awkgram.y"
+ { (yyval.p) = (yyvsp[-1].p); }
+#line 2433 "awkgram.tab.c"
+ break;
+
+ case 35: /* pa_pat: pattern */
+#line 172 "awkgram.y"
+ { (yyval.p) = notnull((yyvsp[0].p)); }
+#line 2439 "awkgram.tab.c"
+ break;
+
+ case 36: /* pa_stat: pa_pat */
+#line 176 "awkgram.y"
+ { (yyval.p) = stat2(PASTAT, (yyvsp[0].p), stat2(PRINT, rectonode(), NIL)); }
+#line 2445 "awkgram.tab.c"
+ break;
+
+ case 37: /* pa_stat: pa_pat lbrace stmtlist '}' */
+#line 177 "awkgram.y"
+ { (yyval.p) = stat2(PASTAT, (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 2451 "awkgram.tab.c"
+ break;
+
+ case 38: /* pa_stat: pa_pat ',' opt_nl pa_pat */
+#line 178 "awkgram.y"
+ { (yyval.p) = pa2stat((yyvsp[-3].p), (yyvsp[0].p), stat2(PRINT, rectonode(), NIL)); }
+#line 2457 "awkgram.tab.c"
+ break;
+
+ case 39: /* pa_stat: pa_pat ',' opt_nl pa_pat lbrace stmtlist '}' */
+#line 179 "awkgram.y"
+ { (yyval.p) = pa2stat((yyvsp[-6].p), (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 2463 "awkgram.tab.c"
+ break;
+
+ case 40: /* pa_stat: lbrace stmtlist '}' */
+#line 180 "awkgram.y"
+ { (yyval.p) = stat2(PASTAT, NIL, (yyvsp[-1].p)); }
+#line 2469 "awkgram.tab.c"
+ break;
+
+ case 41: /* pa_stat: XBEGIN lbrace stmtlist '}' */
+#line 182 "awkgram.y"
+ { beginloc = linkum(beginloc, (yyvsp[-1].p)); (yyval.p) = 0; }
+#line 2475 "awkgram.tab.c"
+ break;
+
+ case 42: /* pa_stat: XEND lbrace stmtlist '}' */
+#line 184 "awkgram.y"
+ { endloc = linkum(endloc, (yyvsp[-1].p)); (yyval.p) = 0; }
+#line 2481 "awkgram.tab.c"
+ break;
+
+ case 43: /* $@4: %empty */
+#line 185 "awkgram.y"
+ {infunc = true;}
+#line 2487 "awkgram.tab.c"
+ break;
+
+ case 44: /* pa_stat: FUNC funcname '(' varlist rparen $@4 lbrace stmtlist '}' */
+#line 186 "awkgram.y"
+ { infunc = false; curfname=0; defn((Cell *)(yyvsp[-7].p), (yyvsp[-5].p), (yyvsp[-1].p)); (yyval.p) = 0; }
+#line 2493 "awkgram.tab.c"
+ break;
+
+ case 46: /* pa_stats: pa_stats opt_pst pa_stat */
+#line 191 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2499 "awkgram.tab.c"
+ break;
+
+ case 48: /* patlist: patlist comma pattern */
+#line 196 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2505 "awkgram.tab.c"
+ break;
+
+ case 49: /* ppattern: var ASGNOP ppattern */
+#line 200 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2511 "awkgram.tab.c"
+ break;
+
+ case 50: /* ppattern: ppattern '?' ppattern ':' ppattern */
+#line 202 "awkgram.y"
+ { (yyval.p) = op3(CONDEXPR, notnull((yyvsp[-4].p)), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2517 "awkgram.tab.c"
+ break;
+
+ case 51: /* ppattern: ppattern bor ppattern */
+#line 204 "awkgram.y"
+ { (yyval.p) = op2(BOR, notnull((yyvsp[-2].p)), notnull((yyvsp[0].p))); }
+#line 2523 "awkgram.tab.c"
+ break;
+
+ case 52: /* ppattern: ppattern and ppattern */
+#line 206 "awkgram.y"
+ { (yyval.p) = op2(AND, notnull((yyvsp[-2].p)), notnull((yyvsp[0].p))); }
+#line 2529 "awkgram.tab.c"
+ break;
+
+ case 53: /* ppattern: ppattern MATCHOP reg_expr */
+#line 207 "awkgram.y"
+ { (yyval.p) = op3((yyvsp[-1].i), NIL, (yyvsp[-2].p), (Node*)makedfa((yyvsp[0].s), 0)); }
+#line 2535 "awkgram.tab.c"
+ break;
+
+ case 54: /* ppattern: ppattern MATCHOP ppattern */
+#line 209 "awkgram.y"
+ { if (constnode((yyvsp[0].p)))
+ (yyval.p) = op3((yyvsp[-1].i), NIL, (yyvsp[-2].p), (Node*)makedfa(strnode((yyvsp[0].p)), 0));
+ else
+ (yyval.p) = op3((yyvsp[-1].i), (Node *)1, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2544 "awkgram.tab.c"
+ break;
+
+ case 55: /* ppattern: ppattern IN varname */
+#line 213 "awkgram.y"
+ { (yyval.p) = op2(INTEST, (yyvsp[-2].p), makearr((yyvsp[0].p))); }
+#line 2550 "awkgram.tab.c"
+ break;
+
+ case 56: /* ppattern: '(' plist ')' IN varname */
+#line 214 "awkgram.y"
+ { (yyval.p) = op2(INTEST, (yyvsp[-3].p), makearr((yyvsp[0].p))); }
+#line 2556 "awkgram.tab.c"
+ break;
+
+ case 57: /* ppattern: ppattern term */
+#line 215 "awkgram.y"
+ { (yyval.p) = op2(CAT, (yyvsp[-1].p), (yyvsp[0].p)); }
+#line 2562 "awkgram.tab.c"
+ break;
+
+ case 60: /* pattern: var ASGNOP pattern */
+#line 221 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2568 "awkgram.tab.c"
+ break;
+
+ case 61: /* pattern: pattern '?' pattern ':' pattern */
+#line 223 "awkgram.y"
+ { (yyval.p) = op3(CONDEXPR, notnull((yyvsp[-4].p)), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2574 "awkgram.tab.c"
+ break;
+
+ case 62: /* pattern: pattern bor pattern */
+#line 225 "awkgram.y"
+ { (yyval.p) = op2(BOR, notnull((yyvsp[-2].p)), notnull((yyvsp[0].p))); }
+#line 2580 "awkgram.tab.c"
+ break;
+
+ case 63: /* pattern: pattern and pattern */
+#line 227 "awkgram.y"
+ { (yyval.p) = op2(AND, notnull((yyvsp[-2].p)), notnull((yyvsp[0].p))); }
+#line 2586 "awkgram.tab.c"
+ break;
+
+ case 64: /* pattern: pattern EQ pattern */
+#line 228 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2592 "awkgram.tab.c"
+ break;
+
+ case 65: /* pattern: pattern GE pattern */
+#line 229 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2598 "awkgram.tab.c"
+ break;
+
+ case 66: /* pattern: pattern GT pattern */
+#line 230 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2604 "awkgram.tab.c"
+ break;
+
+ case 67: /* pattern: pattern LE pattern */
+#line 231 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2610 "awkgram.tab.c"
+ break;
+
+ case 68: /* pattern: pattern LT pattern */
+#line 232 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2616 "awkgram.tab.c"
+ break;
+
+ case 69: /* pattern: pattern NE pattern */
+#line 233 "awkgram.y"
+ { (yyval.p) = op2((yyvsp[-1].i), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2622 "awkgram.tab.c"
+ break;
+
+ case 70: /* pattern: pattern MATCHOP reg_expr */
+#line 234 "awkgram.y"
+ { (yyval.p) = op3((yyvsp[-1].i), NIL, (yyvsp[-2].p), (Node*)makedfa((yyvsp[0].s), 0)); }
+#line 2628 "awkgram.tab.c"
+ break;
+
+ case 71: /* pattern: pattern MATCHOP pattern */
+#line 236 "awkgram.y"
+ { if (constnode((yyvsp[0].p)))
+ (yyval.p) = op3((yyvsp[-1].i), NIL, (yyvsp[-2].p), (Node*)makedfa(strnode((yyvsp[0].p)), 0));
+ else
+ (yyval.p) = op3((yyvsp[-1].i), (Node *)1, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2637 "awkgram.tab.c"
+ break;
+
+ case 72: /* pattern: pattern IN varname */
+#line 240 "awkgram.y"
+ { (yyval.p) = op2(INTEST, (yyvsp[-2].p), makearr((yyvsp[0].p))); }
+#line 2643 "awkgram.tab.c"
+ break;
+
+ case 73: /* pattern: '(' plist ')' IN varname */
+#line 241 "awkgram.y"
+ { (yyval.p) = op2(INTEST, (yyvsp[-3].p), makearr((yyvsp[0].p))); }
+#line 2649 "awkgram.tab.c"
+ break;
+
+ case 74: /* pattern: pattern '|' GETLINE var */
+#line 242 "awkgram.y"
+ {
+ if (safe) SYNTAX("cmd | getline is unsafe");
+ else (yyval.p) = op3(GETLINE, (yyvsp[0].p), itonp((yyvsp[-2].i)), (yyvsp[-3].p)); }
+#line 2657 "awkgram.tab.c"
+ break;
+
+ case 75: /* pattern: pattern '|' GETLINE */
+#line 245 "awkgram.y"
+ {
+ if (safe) SYNTAX("cmd | getline is unsafe");
+ else (yyval.p) = op3(GETLINE, (Node*)0, itonp((yyvsp[-1].i)), (yyvsp[-2].p)); }
+#line 2665 "awkgram.tab.c"
+ break;
+
+ case 76: /* pattern: pattern term */
+#line 248 "awkgram.y"
+ { (yyval.p) = op2(CAT, (yyvsp[-1].p), (yyvsp[0].p)); }
+#line 2671 "awkgram.tab.c"
+ break;
+
+ case 79: /* plist: pattern comma pattern */
+#line 254 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2677 "awkgram.tab.c"
+ break;
+
+ case 80: /* plist: plist comma pattern */
+#line 255 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2683 "awkgram.tab.c"
+ break;
+
+ case 82: /* pplist: pplist comma ppattern */
+#line 260 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2689 "awkgram.tab.c"
+ break;
+
+ case 83: /* prarg: %empty */
+#line 264 "awkgram.y"
+ { (yyval.p) = rectonode(); }
+#line 2695 "awkgram.tab.c"
+ break;
+
+ case 85: /* prarg: '(' plist ')' */
+#line 266 "awkgram.y"
+ { (yyval.p) = (yyvsp[-1].p); }
+#line 2701 "awkgram.tab.c"
+ break;
+
+ case 94: /* re: reg_expr */
+#line 283 "awkgram.y"
+ { (yyval.p) = op3(MATCH, NIL, rectonode(), (Node*)makedfa((yyvsp[0].s), 0)); }
+#line 2707 "awkgram.tab.c"
+ break;
+
+ case 95: /* re: NOT re */
+#line 284 "awkgram.y"
+ { (yyval.p) = op1(NOT, notnull((yyvsp[0].p))); }
+#line 2713 "awkgram.tab.c"
+ break;
+
+ case 96: /* $@5: %empty */
+#line 288 "awkgram.y"
+ {startreg();}
+#line 2719 "awkgram.tab.c"
+ break;
+
+ case 97: /* reg_expr: '/' $@5 REGEXPR '/' */
+#line 288 "awkgram.y"
+ { (yyval.s) = (yyvsp[-1].s); }
+#line 2725 "awkgram.tab.c"
+ break;
+
+ case 100: /* simple_stmt: print prarg '|' term */
+#line 296 "awkgram.y"
+ {
+ if (safe) SYNTAX("print | is unsafe");
+ else (yyval.p) = stat3((yyvsp[-3].i), (yyvsp[-2].p), itonp((yyvsp[-1].i)), (yyvsp[0].p)); }
+#line 2733 "awkgram.tab.c"
+ break;
+
+ case 101: /* simple_stmt: print prarg APPEND term */
+#line 299 "awkgram.y"
+ {
+ if (safe) SYNTAX("print >> is unsafe");
+ else (yyval.p) = stat3((yyvsp[-3].i), (yyvsp[-2].p), itonp((yyvsp[-1].i)), (yyvsp[0].p)); }
+#line 2741 "awkgram.tab.c"
+ break;
+
+ case 102: /* simple_stmt: print prarg GT term */
+#line 302 "awkgram.y"
+ {
+ if (safe) SYNTAX("print > is unsafe");
+ else (yyval.p) = stat3((yyvsp[-3].i), (yyvsp[-2].p), itonp((yyvsp[-1].i)), (yyvsp[0].p)); }
+#line 2749 "awkgram.tab.c"
+ break;
+
+ case 103: /* simple_stmt: print prarg */
+#line 305 "awkgram.y"
+ { (yyval.p) = stat3((yyvsp[-1].i), (yyvsp[0].p), NIL, NIL); }
+#line 2755 "awkgram.tab.c"
+ break;
+
+ case 104: /* simple_stmt: DELETE varname '[' patlist ']' */
+#line 306 "awkgram.y"
+ { (yyval.p) = stat2(DELETE, makearr((yyvsp[-3].p)), (yyvsp[-1].p)); }
+#line 2761 "awkgram.tab.c"
+ break;
+
+ case 105: /* simple_stmt: DELETE varname */
+#line 307 "awkgram.y"
+ { (yyval.p) = stat2(DELETE, makearr((yyvsp[0].p)), 0); }
+#line 2767 "awkgram.tab.c"
+ break;
+
+ case 106: /* simple_stmt: pattern */
+#line 308 "awkgram.y"
+ { (yyval.p) = exptostat((yyvsp[0].p)); }
+#line 2773 "awkgram.tab.c"
+ break;
+
+ case 107: /* simple_stmt: error */
+#line 309 "awkgram.y"
+ { yyclearin; SYNTAX("illegal statement"); }
+#line 2779 "awkgram.tab.c"
+ break;
+
+ case 110: /* stmt: BREAK st */
+#line 318 "awkgram.y"
+ { if (!inloop) SYNTAX("break illegal outside of loops");
+ (yyval.p) = stat1(BREAK, NIL); }
+#line 2786 "awkgram.tab.c"
+ break;
+
+ case 111: /* stmt: CONTINUE st */
+#line 320 "awkgram.y"
+ { if (!inloop) SYNTAX("continue illegal outside of loops");
+ (yyval.p) = stat1(CONTINUE, NIL); }
+#line 2793 "awkgram.tab.c"
+ break;
+
+ case 112: /* $@6: %empty */
+#line 322 "awkgram.y"
+ {inloop++;}
+#line 2799 "awkgram.tab.c"
+ break;
+
+ case 113: /* $@7: %empty */
+#line 322 "awkgram.y"
+ {--inloop;}
+#line 2805 "awkgram.tab.c"
+ break;
+
+ case 114: /* stmt: do $@6 stmt $@7 WHILE '(' pattern ')' st */
+#line 323 "awkgram.y"
+ { (yyval.p) = stat2(DO, (yyvsp[-6].p), notnull((yyvsp[-2].p))); }
+#line 2811 "awkgram.tab.c"
+ break;
+
+ case 115: /* stmt: EXIT pattern st */
+#line 324 "awkgram.y"
+ { (yyval.p) = stat1(EXIT, (yyvsp[-1].p)); }
+#line 2817 "awkgram.tab.c"
+ break;
+
+ case 116: /* stmt: EXIT st */
+#line 325 "awkgram.y"
+ { (yyval.p) = stat1(EXIT, NIL); }
+#line 2823 "awkgram.tab.c"
+ break;
+
+ case 118: /* stmt: if stmt else stmt */
+#line 327 "awkgram.y"
+ { (yyval.p) = stat3(IF, (yyvsp[-3].p), (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2829 "awkgram.tab.c"
+ break;
+
+ case 119: /* stmt: if stmt */
+#line 328 "awkgram.y"
+ { (yyval.p) = stat3(IF, (yyvsp[-1].p), (yyvsp[0].p), NIL); }
+#line 2835 "awkgram.tab.c"
+ break;
+
+ case 120: /* stmt: lbrace stmtlist rbrace */
+#line 329 "awkgram.y"
+ { (yyval.p) = (yyvsp[-1].p); }
+#line 2841 "awkgram.tab.c"
+ break;
+
+ case 121: /* stmt: NEXT st */
+#line 330 "awkgram.y"
+ { if (infunc)
+ SYNTAX("next is illegal inside a function");
+ (yyval.p) = stat1(NEXT, NIL); }
+#line 2849 "awkgram.tab.c"
+ break;
+
+ case 122: /* stmt: NEXTFILE st */
+#line 333 "awkgram.y"
+ { if (infunc)
+ SYNTAX("nextfile is illegal inside a function");
+ (yyval.p) = stat1(NEXTFILE, NIL); }
+#line 2857 "awkgram.tab.c"
+ break;
+
+ case 123: /* stmt: RETURN pattern st */
+#line 336 "awkgram.y"
+ { (yyval.p) = stat1(RETURN, (yyvsp[-1].p)); }
+#line 2863 "awkgram.tab.c"
+ break;
+
+ case 124: /* stmt: RETURN st */
+#line 337 "awkgram.y"
+ { (yyval.p) = stat1(RETURN, NIL); }
+#line 2869 "awkgram.tab.c"
+ break;
+
+ case 126: /* $@8: %empty */
+#line 339 "awkgram.y"
+ {inloop++;}
+#line 2875 "awkgram.tab.c"
+ break;
+
+ case 127: /* stmt: while $@8 stmt */
+#line 339 "awkgram.y"
+ { --inloop; (yyval.p) = stat2(WHILE, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2881 "awkgram.tab.c"
+ break;
+
+ case 128: /* stmt: ';' opt_nl */
+#line 340 "awkgram.y"
+ { (yyval.p) = 0; }
+#line 2887 "awkgram.tab.c"
+ break;
+
+ case 130: /* stmtlist: stmtlist stmt */
+#line 345 "awkgram.y"
+ { (yyval.p) = linkum((yyvsp[-1].p), (yyvsp[0].p)); }
+#line 2893 "awkgram.tab.c"
+ break;
+
+ case 134: /* string: string STRING */
+#line 354 "awkgram.y"
+ { (yyval.cp) = catstr((yyvsp[-1].cp), (yyvsp[0].cp)); }
+#line 2899 "awkgram.tab.c"
+ break;
+
+ case 135: /* term: term '/' ASGNOP term */
+#line 358 "awkgram.y"
+ { (yyval.p) = op2(DIVEQ, (yyvsp[-3].p), (yyvsp[0].p)); }
+#line 2905 "awkgram.tab.c"
+ break;
+
+ case 136: /* term: term '+' term */
+#line 359 "awkgram.y"
+ { (yyval.p) = op2(ADD, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2911 "awkgram.tab.c"
+ break;
+
+ case 137: /* term: term '-' term */
+#line 360 "awkgram.y"
+ { (yyval.p) = op2(MINUS, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2917 "awkgram.tab.c"
+ break;
+
+ case 138: /* term: term '*' term */
+#line 361 "awkgram.y"
+ { (yyval.p) = op2(MULT, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2923 "awkgram.tab.c"
+ break;
+
+ case 139: /* term: term '/' term */
+#line 362 "awkgram.y"
+ { (yyval.p) = op2(DIVIDE, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2929 "awkgram.tab.c"
+ break;
+
+ case 140: /* term: term '%' term */
+#line 363 "awkgram.y"
+ { (yyval.p) = op2(MOD, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2935 "awkgram.tab.c"
+ break;
+
+ case 141: /* term: term POWER term */
+#line 364 "awkgram.y"
+ { (yyval.p) = op2(POWER, (yyvsp[-2].p), (yyvsp[0].p)); }
+#line 2941 "awkgram.tab.c"
+ break;
+
+ case 142: /* term: '-' term */
+#line 365 "awkgram.y"
+ { (yyval.p) = op1(UMINUS, (yyvsp[0].p)); }
+#line 2947 "awkgram.tab.c"
+ break;
+
+ case 143: /* term: '+' term */
+#line 366 "awkgram.y"
+ { (yyval.p) = op1(UPLUS, (yyvsp[0].p)); }
+#line 2953 "awkgram.tab.c"
+ break;
+
+ case 144: /* term: NOT term */
+#line 367 "awkgram.y"
+ { (yyval.p) = op1(NOT, notnull((yyvsp[0].p))); }
+#line 2959 "awkgram.tab.c"
+ break;
+
+ case 145: /* term: BLTIN '(' ')' */
+#line 368 "awkgram.y"
+ { (yyval.p) = op2(BLTIN, itonp((yyvsp[-2].i)), rectonode()); }
+#line 2965 "awkgram.tab.c"
+ break;
+
+ case 146: /* term: BLTIN '(' patlist ')' */
+#line 369 "awkgram.y"
+ { (yyval.p) = op2(BLTIN, itonp((yyvsp[-3].i)), (yyvsp[-1].p)); }
+#line 2971 "awkgram.tab.c"
+ break;
+
+ case 147: /* term: BLTIN */
+#line 370 "awkgram.y"
+ { (yyval.p) = op2(BLTIN, itonp((yyvsp[0].i)), rectonode()); }
+#line 2977 "awkgram.tab.c"
+ break;
+
+ case 148: /* term: CALL '(' ')' */
+#line 371 "awkgram.y"
+ { (yyval.p) = op2(CALL, celltonode((yyvsp[-2].cp),CVAR), NIL); }
+#line 2983 "awkgram.tab.c"
+ break;
+
+ case 149: /* term: CALL '(' patlist ')' */
+#line 372 "awkgram.y"
+ { (yyval.p) = op2(CALL, celltonode((yyvsp[-3].cp),CVAR), (yyvsp[-1].p)); }
+#line 2989 "awkgram.tab.c"
+ break;
+
+ case 150: /* term: CLOSE term */
+#line 373 "awkgram.y"
+ { (yyval.p) = op1(CLOSE, (yyvsp[0].p)); }
+#line 2995 "awkgram.tab.c"
+ break;
+
+ case 151: /* term: DECR var */
+#line 374 "awkgram.y"
+ { (yyval.p) = op1(PREDECR, (yyvsp[0].p)); }
+#line 3001 "awkgram.tab.c"
+ break;
+
+ case 152: /* term: INCR var */
+#line 375 "awkgram.y"
+ { (yyval.p) = op1(PREINCR, (yyvsp[0].p)); }
+#line 3007 "awkgram.tab.c"
+ break;
+
+ case 153: /* term: var DECR */
+#line 376 "awkgram.y"
+ { (yyval.p) = op1(POSTDECR, (yyvsp[-1].p)); }
+#line 3013 "awkgram.tab.c"
+ break;
+
+ case 154: /* term: var INCR */
+#line 377 "awkgram.y"
+ { (yyval.p) = op1(POSTINCR, (yyvsp[-1].p)); }
+#line 3019 "awkgram.tab.c"
+ break;
+
+ case 155: /* term: GETLINE var LT term */
+#line 378 "awkgram.y"
+ { (yyval.p) = op3(GETLINE, (yyvsp[-2].p), itonp((yyvsp[-1].i)), (yyvsp[0].p)); }
+#line 3025 "awkgram.tab.c"
+ break;
+
+ case 156: /* term: GETLINE LT term */
+#line 379 "awkgram.y"
+ { (yyval.p) = op3(GETLINE, NIL, itonp((yyvsp[-1].i)), (yyvsp[0].p)); }
+#line 3031 "awkgram.tab.c"
+ break;
+
+ case 157: /* term: GETLINE var */
+#line 380 "awkgram.y"
+ { (yyval.p) = op3(GETLINE, (yyvsp[0].p), NIL, NIL); }
+#line 3037 "awkgram.tab.c"
+ break;
+
+ case 158: /* term: GETLINE */
+#line 381 "awkgram.y"
+ { (yyval.p) = op3(GETLINE, NIL, NIL, NIL); }
+#line 3043 "awkgram.tab.c"
+ break;
+
+ case 159: /* term: INDEX '(' pattern comma pattern ')' */
+#line 383 "awkgram.y"
+ { (yyval.p) = op2(INDEX, (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 3049 "awkgram.tab.c"
+ break;
+
+ case 160: /* term: INDEX '(' pattern comma reg_expr ')' */
+#line 385 "awkgram.y"
+ { SYNTAX("index() doesn't permit regular expressions");
+ (yyval.p) = op2(INDEX, (yyvsp[-3].p), (Node*)(yyvsp[-1].s)); }
+#line 3056 "awkgram.tab.c"
+ break;
+
+ case 161: /* term: '(' pattern ')' */
+#line 387 "awkgram.y"
+ { (yyval.p) = (yyvsp[-1].p); }
+#line 3062 "awkgram.tab.c"
+ break;
+
+ case 162: /* term: MATCHFCN '(' pattern comma reg_expr ')' */
+#line 389 "awkgram.y"
+ { (yyval.p) = op3(MATCHFCN, NIL, (yyvsp[-3].p), (Node*)makedfa((yyvsp[-1].s), 1)); }
+#line 3068 "awkgram.tab.c"
+ break;
+
+ case 163: /* term: MATCHFCN '(' pattern comma pattern ')' */
+#line 391 "awkgram.y"
+ { if (constnode((yyvsp[-1].p)))
+ (yyval.p) = op3(MATCHFCN, NIL, (yyvsp[-3].p), (Node*)makedfa(strnode((yyvsp[-1].p)), 1));
+ else
+ (yyval.p) = op3(MATCHFCN, (Node *)1, (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 3077 "awkgram.tab.c"
+ break;
+
+ case 164: /* term: NUMBER */
+#line 395 "awkgram.y"
+ { (yyval.p) = celltonode((yyvsp[0].cp), CCON); }
+#line 3083 "awkgram.tab.c"
+ break;
+
+ case 165: /* term: SPLIT '(' pattern comma varname comma pattern ')' */
+#line 397 "awkgram.y"
+ { (yyval.p) = op4(SPLIT, (yyvsp[-5].p), makearr((yyvsp[-3].p)), (yyvsp[-1].p), (Node*)STRING); }
+#line 3089 "awkgram.tab.c"
+ break;
+
+ case 166: /* term: SPLIT '(' pattern comma varname comma reg_expr ')' */
+#line 399 "awkgram.y"
+ { (yyval.p) = op4(SPLIT, (yyvsp[-5].p), makearr((yyvsp[-3].p)), (Node*)makedfa((yyvsp[-1].s), 1), (Node *)REGEXPR); }
+#line 3095 "awkgram.tab.c"
+ break;
+
+ case 167: /* term: SPLIT '(' pattern comma varname ')' */
+#line 401 "awkgram.y"
+ { (yyval.p) = op4(SPLIT, (yyvsp[-3].p), makearr((yyvsp[-1].p)), NIL, (Node*)STRING); }
+#line 3101 "awkgram.tab.c"
+ break;
+
+ case 168: /* term: SPRINTF '(' patlist ')' */
+#line 402 "awkgram.y"
+ { (yyval.p) = op1((yyvsp[-3].i), (yyvsp[-1].p)); }
+#line 3107 "awkgram.tab.c"
+ break;
+
+ case 169: /* term: string */
+#line 403 "awkgram.y"
+ { (yyval.p) = celltonode((yyvsp[0].cp), CCON); }
+#line 3113 "awkgram.tab.c"
+ break;
+
+ case 170: /* term: subop '(' reg_expr comma pattern ')' */
+#line 405 "awkgram.y"
+ { (yyval.p) = op4((yyvsp[-5].i), NIL, (Node*)makedfa((yyvsp[-3].s), 1), (yyvsp[-1].p), rectonode()); }
+#line 3119 "awkgram.tab.c"
+ break;
+
+ case 171: /* term: subop '(' pattern comma pattern ')' */
+#line 407 "awkgram.y"
+ { if (constnode((yyvsp[-3].p)))
+ (yyval.p) = op4((yyvsp[-5].i), NIL, (Node*)makedfa(strnode((yyvsp[-3].p)), 1), (yyvsp[-1].p), rectonode());
+ else
+ (yyval.p) = op4((yyvsp[-5].i), (Node *)1, (yyvsp[-3].p), (yyvsp[-1].p), rectonode()); }
+#line 3128 "awkgram.tab.c"
+ break;
+
+ case 172: /* term: subop '(' reg_expr comma pattern comma var ')' */
+#line 412 "awkgram.y"
+ { (yyval.p) = op4((yyvsp[-7].i), NIL, (Node*)makedfa((yyvsp[-5].s), 1), (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 3134 "awkgram.tab.c"
+ break;
+
+ case 173: /* term: subop '(' pattern comma pattern comma var ')' */
+#line 414 "awkgram.y"
+ { if (constnode((yyvsp[-5].p)))
+ (yyval.p) = op4((yyvsp[-7].i), NIL, (Node*)makedfa(strnode((yyvsp[-5].p)), 1), (yyvsp[-3].p), (yyvsp[-1].p));
+ else
+ (yyval.p) = op4((yyvsp[-7].i), (Node *)1, (yyvsp[-5].p), (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 3143 "awkgram.tab.c"
+ break;
+
+ case 174: /* term: SUBSTR '(' pattern comma pattern comma pattern ')' */
+#line 419 "awkgram.y"
+ { (yyval.p) = op3(SUBSTR, (yyvsp[-5].p), (yyvsp[-3].p), (yyvsp[-1].p)); }
+#line 3149 "awkgram.tab.c"
+ break;
+
+ case 175: /* term: SUBSTR '(' pattern comma pattern ')' */
+#line 421 "awkgram.y"
+ { (yyval.p) = op3(SUBSTR, (yyvsp[-3].p), (yyvsp[-1].p), NIL); }
+#line 3155 "awkgram.tab.c"
+ break;
+
+ case 178: /* var: varname '[' patlist ']' */
+#line 427 "awkgram.y"
+ { (yyval.p) = op2(ARRAY, makearr((yyvsp[-3].p)), (yyvsp[-1].p)); }
+#line 3161 "awkgram.tab.c"
+ break;
+
+ case 179: /* var: IVAR */
+#line 428 "awkgram.y"
+ { (yyval.p) = op1(INDIRECT, celltonode((yyvsp[0].cp), CVAR)); }
+#line 3167 "awkgram.tab.c"
+ break;
+
+ case 180: /* var: INDIRECT term */
+#line 429 "awkgram.y"
+ { (yyval.p) = op1(INDIRECT, (yyvsp[0].p)); }
+#line 3173 "awkgram.tab.c"
+ break;
+
+ case 181: /* varlist: %empty */
+#line 433 "awkgram.y"
+ { arglist = (yyval.p) = 0; }
+#line 3179 "awkgram.tab.c"
+ break;
+
+ case 182: /* varlist: VAR */
+#line 434 "awkgram.y"
+ { arglist = (yyval.p) = celltonode((yyvsp[0].cp),CVAR); }
+#line 3185 "awkgram.tab.c"
+ break;
+
+ case 183: /* varlist: varlist comma VAR */
+#line 435 "awkgram.y"
+ {
+ checkdup((yyvsp[-2].p), (yyvsp[0].cp));
+ arglist = (yyval.p) = linkum((yyvsp[-2].p),celltonode((yyvsp[0].cp),CVAR)); }
+#line 3193 "awkgram.tab.c"
+ break;
+
+ case 184: /* varname: VAR */
+#line 441 "awkgram.y"
+ { (yyval.p) = celltonode((yyvsp[0].cp), CVAR); }
+#line 3199 "awkgram.tab.c"
+ break;
+
+ case 185: /* varname: ARG */
+#line 442 "awkgram.y"
+ { (yyval.p) = op1(ARG, itonp((yyvsp[0].i))); }
+#line 3205 "awkgram.tab.c"
+ break;
+
+ case 186: /* varname: VARNF */
+#line 443 "awkgram.y"
+ { (yyval.p) = op1(VARNF, (Node *) (yyvsp[0].cp)); }
+#line 3211 "awkgram.tab.c"
+ break;
+
+ case 187: /* while: WHILE '(' pattern rparen */
+#line 448 "awkgram.y"
+ { (yyval.p) = notnull((yyvsp[-1].p)); }
+#line 3217 "awkgram.tab.c"
+ break;
+
+
+#line 3221 "awkgram.tab.c"
+
+ default: break;
+ }
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+
+ *++yyvsp = yyval;
+
+ /* Now 'shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
+
+ goto yynewstate;
+
+
+/*--------------------------------------.
+| yyerrlab -- here on detecting error. |
+`--------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+ yyerror (YY_("syntax error"));
+ }
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
+ ++yynerrs;
+
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ /* Pop stack until we find a state that shifts the error token. */
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYSYMBOL_YYerror;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ YY_ACCESSING_SYMBOL (yystate), yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturnlab;
+
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturnlab;
+
+
+/*-----------------------------------------------------------.
+| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
+`-----------------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ goto yyreturnlab;
+
+
+/*----------------------------------------------------------.
+| yyreturnlab -- parsing is finished, clean up and return. |
+`----------------------------------------------------------*/
+yyreturnlab:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
+ }
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+
+ return yyresult;
+}
+
+#line 451 "awkgram.y"
+
+
+void setfname(Cell *p)
+{
+ if (isarr(p))
+ SYNTAX("%s is an array, not a function", p->nval);
+ else if (isfcn(p))
+ SYNTAX("you can't define function %s more than once", p->nval);
+ curfname = p->nval;
+}
+
+int constnode(Node *p)
+{
+ return isvalue(p) && ((Cell *) (p->narg[0]))->csub == CCON;
+}
+
+char *strnode(Node *p)
+{
+ return ((Cell *)(p->narg[0]))->sval;
+}
+
+Node *notnull(Node *n)
+{
+ switch (n->nobj) {
+ case LE: case LT: case EQ: case NE: case GT: case GE:
+ case BOR: case AND: case NOT:
+ return n;
+ default:
+ return op2(NE, n, nullnode);
+ }
+}
+
+void checkdup(Node *vl, Cell *cp) /* check if name already in list */
+{
+ char *s = cp->nval;
+ for ( ; vl; vl = vl->nnext) {
+ if (strcmp(s, ((Cell *)(vl->narg[0]))->nval) == 0) {
+ SYNTAX("duplicate argument %s", s);
+ break;
+ }
+ }
+}
Index: pkgsrc/lang/nawk/files/awkgram.tab.h
diff -u /dev/null pkgsrc/lang/nawk/files/awkgram.tab.h:1.1
--- /dev/null Fri Feb 24 20:57:50 2023
+++ pkgsrc/lang/nawk/files/awkgram.tab.h Fri Feb 24 20:57:50 2023
@@ -0,0 +1,182 @@
+/* A Bison parser, made by GNU Bison 3.8.2. */
+
+/* Bison interface for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
+ especially those whose name start with YY_ or yy_. They are
+ private implementation details that can be changed or removed. */
+
+#ifndef YY_YY_AWKGRAM_TAB_H_INCLUDED
+# define YY_YY_AWKGRAM_TAB_H_INCLUDED
+/* Debug traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int yydebug;
+#endif
+
+/* Token kinds. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ enum yytokentype
+ {
+ YYEMPTY = -2,
+ YYEOF = 0, /* "end of file" */
+ YYerror = 256, /* error */
+ YYUNDEF = 257, /* "invalid token" */
+ FIRSTTOKEN = 258, /* FIRSTTOKEN */
+ PROGRAM = 259, /* PROGRAM */
+ PASTAT = 260, /* PASTAT */
+ PASTAT2 = 261, /* PASTAT2 */
+ XBEGIN = 262, /* XBEGIN */
+ XEND = 263, /* XEND */
+ NL = 264, /* NL */
+ ARRAY = 265, /* ARRAY */
+ MATCH = 266, /* MATCH */
+ NOTMATCH = 267, /* NOTMATCH */
+ MATCHOP = 268, /* MATCHOP */
+ FINAL = 269, /* FINAL */
+ DOT = 270, /* DOT */
+ ALL = 271, /* ALL */
+ CCL = 272, /* CCL */
+ NCCL = 273, /* NCCL */
+ CHAR = 274, /* CHAR */
+ OR = 275, /* OR */
+ STAR = 276, /* STAR */
+ QUEST = 277, /* QUEST */
+ PLUS = 278, /* PLUS */
+ EMPTYRE = 279, /* EMPTYRE */
+ ZERO = 280, /* ZERO */
+ AND = 281, /* AND */
+ BOR = 282, /* BOR */
+ APPEND = 283, /* APPEND */
+ EQ = 284, /* EQ */
+ GE = 285, /* GE */
+ GT = 286, /* GT */
+ LE = 287, /* LE */
+ LT = 288, /* LT */
+ NE = 289, /* NE */
+ IN = 290, /* IN */
+ ARG = 291, /* ARG */
+ BLTIN = 292, /* BLTIN */
+ BREAK = 293, /* BREAK */
+ CLOSE = 294, /* CLOSE */
+ CONTINUE = 295, /* CONTINUE */
+ DELETE = 296, /* DELETE */
+ DO = 297, /* DO */
+ EXIT = 298, /* EXIT */
+ FOR = 299, /* FOR */
+ FUNC = 300, /* FUNC */
+ SUB = 301, /* SUB */
+ GSUB = 302, /* GSUB */
+ IF = 303, /* IF */
+ INDEX = 304, /* INDEX */
+ LSUBSTR = 305, /* LSUBSTR */
+ MATCHFCN = 306, /* MATCHFCN */
+ NEXT = 307, /* NEXT */
+ NEXTFILE = 308, /* NEXTFILE */
+ ADD = 309, /* ADD */
+ MINUS = 310, /* MINUS */
+ MULT = 311, /* MULT */
+ DIVIDE = 312, /* DIVIDE */
+ MOD = 313, /* MOD */
+ ASSIGN = 314, /* ASSIGN */
+ ASGNOP = 315, /* ASGNOP */
+ ADDEQ = 316, /* ADDEQ */
+ SUBEQ = 317, /* SUBEQ */
+ MULTEQ = 318, /* MULTEQ */
+ DIVEQ = 319, /* DIVEQ */
+ MODEQ = 320, /* MODEQ */
+ POWEQ = 321, /* POWEQ */
+ PRINT = 322, /* PRINT */
+ PRINTF = 323, /* PRINTF */
+ SPRINTF = 324, /* SPRINTF */
+ ELSE = 325, /* ELSE */
+ INTEST = 326, /* INTEST */
+ CONDEXPR = 327, /* CONDEXPR */
+ POSTINCR = 328, /* POSTINCR */
+ PREINCR = 329, /* PREINCR */
+ POSTDECR = 330, /* POSTDECR */
+ PREDECR = 331, /* PREDECR */
+ VAR = 332, /* VAR */
+ IVAR = 333, /* IVAR */
+ VARNF = 334, /* VARNF */
+ CALL = 335, /* CALL */
+ NUMBER = 336, /* NUMBER */
+ STRING = 337, /* STRING */
+ REGEXPR = 338, /* REGEXPR */
+ GETLINE = 339, /* GETLINE */
+ RETURN = 340, /* RETURN */
+ SPLIT = 341, /* SPLIT */
+ SUBSTR = 342, /* SUBSTR */
+ WHILE = 343, /* WHILE */
+ CAT = 344, /* CAT */
+ NOT = 345, /* NOT */
+ UMINUS = 346, /* UMINUS */
+ UPLUS = 347, /* UPLUS */
+ POWER = 348, /* POWER */
+ DECR = 349, /* DECR */
+ INCR = 350, /* INCR */
+ INDIRECT = 351, /* INDIRECT */
+ LASTTOKEN = 352 /* LASTTOKEN */
+ };
+ typedef enum yytokentype yytoken_kind_t;
+#endif
+
+/* Value type. */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+union YYSTYPE
+{
+#line 41 "awkgram.y"
+
+ Node *p;
+ Cell *cp;
+ int i;
+ char *s;
+
+#line 168 "awkgram.tab.h"
+
+};
+typedef union YYSTYPE YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+extern YYSTYPE yylval;
+
+
+int yyparse (void);
+
+
+#endif /* !YY_YY_AWKGRAM_TAB_H_INCLUDED */
Home |
Main Index |
Thread Index |
Old Index