snapshot of project "mawk", label t20240827

This commit is contained in:
Thomas E. Dickey 2024-08-27 23:54:59 +00:00
parent 367f23764f
commit 28d7bf8a51
No known key found for this signature in database
GPG Key ID: CC2AF4472167BE03
15 changed files with 869 additions and 404 deletions

View File

@ -1,4 +1,10 @@
-- $MawkId: CHANGES,v 1.386 2024/08/25 22:51:21 tom Exp $
-- $MawkId: CHANGES,v 1.391 2024/08/27 23:54:59 tom Exp $
20240827
+ amend fix for Original Mawk #48, providing for deep function
recursion, but disallowing more than 255 parameters for printf, etc.
+ add test-cases to test/mawkerrs
+ update config.guess and config.sub
20240825
+ modify struct declarations to simplify further changes to reduce use

View File

@ -1,4 +1,4 @@
MANIFEST for mawk, version t20240825
MANIFEST for mawk, version t20240827
--------------------------------------------------------------------------------
MANIFEST this file
ACKNOWLEDGMENT acknowledgements

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: bi_funct.c,v 1.131 2024/08/25 18:27:52 tom Exp $
* $MawkId: bi_funct.c,v 1.132 2024/08/26 08:11:02 tom Exp $
*/
#define Visible_ARRAY
@ -63,7 +63,7 @@ const BI_REC bi_funct[] =
{ "index", bi_index, 2, 2 },
{ "substr", bi_substr, 2, 3 },
{ "sprintf", bi_sprintf, 1, 255 },
{ "sprintf", bi_sprintf, 1, MAX_ARGS },
{ "sin", bi_sin, 1, 1 },
{ "cos", bi_cos, 1, 1 },
{ "atan2", bi_atan2, 2, 2 },

15
config.guess vendored
View File

@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2023 Free Software Foundation, Inc.
# Copyright 1992-2024 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2023-10-19'
timestamp='2024-07-27'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -60,7 +60,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2023 Free Software Foundation, Inc.
Copyright 1992-2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -123,7 +123,7 @@ set_cc_for_build() {
dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c"
for driver in cc gcc c89 c99 ; do
for driver in cc gcc c17 c99 c89 ; do
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD=$driver
break
@ -634,7 +634,8 @@ EOF
sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
main()
int
main ()
{
if (!__power_pc())
exit(1);
@ -718,7 +719,8 @@ EOF
#include <stdlib.h>
#include <unistd.h>
int main ()
int
main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
@ -1621,6 +1623,7 @@ cat > "$dummy.c" <<EOF
#endif
#endif
#endif
int
main ()
{
#if defined (sony)

733
config.sub vendored
View File

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2023 Free Software Foundation, Inc.
# Copyright 1992-2024 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
timestamp='2023-12-02'
timestamp='2024-05-27'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -76,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2023 Free Software Foundation, Inc.
Copyright 1992-2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -120,7 +120,6 @@ case $# in
esac
# Split fields of configuration type
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read field1 field2 field3 field4 <<EOF
$1
@ -142,10 +141,20 @@ case $1 in
# parts
maybe_os=$field2-$field3
case $maybe_os in
nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
cloudabi*-eabi* \
| kfreebsd*-gnu* \
| knetbsd*-gnu* \
| kopensolaris*-gnu* \
| linux-* \
| managarm-* \
| netbsd*-eabi* \
| netbsd*-gnu* \
| nto-qnx* \
| os2-emx* \
| rtmk-nova* \
| storm-chaos* \
| uclinux-gnu* \
| uclinux-uclibc* \
| windows-* )
basic_machine=$field1
basic_os=$maybe_os
@ -161,8 +170,12 @@ case $1 in
esac
;;
*-*)
# A lone config we happen to match not fitting any pattern
case $field1-$field2 in
# Shorthands that happen to contain a single dash
convex-c[12] | convex-c3[248])
basic_machine=$field2-convex
basic_os=
;;
decstation-3100)
basic_machine=mips-dec
basic_os=
@ -170,28 +183,88 @@ case $1 in
*-*)
# Second component is usually, but not always the OS
case $field2 in
# Prevent following clause from handling this valid os
# Do not treat sunos as a manufacturer
sun*os*)
basic_machine=$field1
basic_os=$field2
;;
# Manufacturers
3100* \
| 32* \
| 3300* \
| 3600* \
| 7300* \
| acorn \
| altos* \
| apollo \
| apple \
| atari \
| att* \
| axis \
| be \
| bull \
| cbm \
| ccur \
| cisco \
| commodore \
| convergent* \
| convex* \
| cray \
| crds \
| dec* \
| delta* \
| dg \
| digital \
| dolphin \
| encore* \
| gould \
| harris \
| highlevel \
| hitachi* \
| hp \
| ibm* \
| intergraph \
| isi* \
| knuth \
| masscomp \
| microblaze* \
| mips* \
| motorola* \
| ncr* \
| news \
| next \
| ns \
| oki \
| omron* \
| pc533* \
| rebel \
| rom68k \
| rombug \
| semi \
| sequent* \
| siemens \
| sgi* \
| siemens \
| sim \
| sni \
| sony* \
| stratus \
| sun \
| sun[234]* \
| tektronix \
| tti* \
| ultra \
| unicom* \
| wec \
| winbond \
| wrs)
basic_machine=$field1-$field2
basic_os=
;;
zephyr*)
basic_machine=$field1-unknown
basic_os=$field2
;;
# Manufacturers
dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
| unicom* | ibm* | next | hp | isi* | apollo | altos* \
| convergent* | ncr* | news | 32* | 3600* | 3100* \
| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
| ultra | tti* | harris | dolphin | highlevel | gould \
| cbm | ns | masscomp | apple | axis | knuth | cray \
| microblaze* | sim | cisco \
| oki | wec | wrs | winbond)
basic_machine=$field1-$field2
basic_os=
;;
*)
basic_machine=$field1
basic_os=$field2
@ -272,26 +345,6 @@ case $1 in
basic_machine=arm-unknown
basic_os=cegcc
;;
convex-c1)
basic_machine=c1-convex
basic_os=bsd
;;
convex-c2)
basic_machine=c2-convex
basic_os=bsd
;;
convex-c32)
basic_machine=c32-convex
basic_os=bsd
;;
convex-c34)
basic_machine=c34-convex
basic_os=bsd
;;
convex-c38)
basic_machine=c38-convex
basic_os=bsd
;;
cray)
basic_machine=j90-cray
basic_os=unicos
@ -714,15 +767,26 @@ case $basic_machine in
vendor=dec
basic_os=tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
cpu=m68k
vendor=motorola
;;
dpx2*)
# This used to be dpx2*, but that gets the RS6000-based
# DPX/20 and the x86-based DPX/2-100 wrong. See
# https://oldskool.silicium.org/stations/bull_dpx20.htm
# https://www.feb-patrimoine.com/english/bull_dpx2.htm
# https://www.feb-patrimoine.com/english/unix_and_bull.htm
dpx2 | dpx2[23]00 | dpx2[23]xx)
cpu=m68k
vendor=bull
basic_os=sysv3
;;
dpx2100 | dpx21xx)
cpu=i386
vendor=bull
;;
dpx20)
cpu=rs6000
vendor=bull
;;
encore | umax | mmax)
cpu=ns32k
@ -837,18 +901,6 @@ case $basic_machine in
next | m*-next)
cpu=m68k
vendor=next
case $basic_os in
openstep*)
;;
nextstep*)
;;
ns2*)
basic_os=nextstep2
;;
*)
basic_os=nextstep3
;;
esac
;;
np1)
cpu=np1
@ -937,7 +989,6 @@ case $basic_machine in
;;
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read cpu vendor <<EOF
$basic_machine
@ -972,15 +1023,19 @@ unset -v basic_machine
# Decode basic machines in the full and proper CPU-Company form.
case $cpu-$vendor in
# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
# some cases the only manufacturer, in others, it is the most popular.
# Here we handle the default manufacturer of certain CPU types in canonical form.
# It is in some cases the only manufacturer, in others, it is the most popular.
c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
vendor=convex
basic_os=${basic_os:-bsd}
;;
craynv-unknown)
vendor=cray
basic_os=${basic_os:-unicosmp}
;;
c90-unknown | c90-cray)
vendor=cray
basic_os=${Basic_os:-unicos}
basic_os=${basic_os:-unicos}
;;
fx80-unknown)
vendor=alliant
@ -1026,11 +1081,29 @@ case $cpu-$vendor in
vendor=alt
basic_os=${basic_os:-linux-gnueabihf}
;;
dpx20-unknown | dpx20-bull)
cpu=rs6000
vendor=bull
# Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
m68k-isi)
basic_os=${basic_os:-sysv}
;;
m68k-sony)
basic_os=${basic_os:-newsos}
;;
m68k-tektronix)
basic_os=${basic_os:-bsd}
;;
m88k-harris)
basic_os=${basic_os:-sysv3}
;;
i386-bull | m68k-bull)
basic_os=${basic_os:-sysv3}
;;
rs6000-bull)
basic_os=${basic_os:-bosx}
;;
mips-sni)
basic_os=${basic_os:-sysv4}
;;
# Here we normalize CPU types irrespective of the vendor
amd64-*)
@ -1038,7 +1111,7 @@ case $cpu-$vendor in
;;
blackfin-*)
cpu=bfin
basic_os=linux
basic_os=${basic_os:-linux}
;;
c54x-*)
cpu=tic54x
@ -1061,7 +1134,7 @@ case $cpu-$vendor in
;;
m68knommu-*)
cpu=m68k
basic_os=linux
basic_os=${basic_os:-linux}
;;
m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
cpu=s12z
@ -1071,7 +1144,7 @@ case $cpu-$vendor in
;;
parisc-*)
cpu=hppa
basic_os=linux
basic_os=${basic_os:-linux}
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586
@ -1085,9 +1158,6 @@ case $cpu-$vendor in
pentium4-*)
cpu=i786
;;
pc98-*)
cpu=i386
;;
ppc-* | ppcbe-*)
cpu=powerpc
;;
@ -1121,9 +1191,6 @@ case $cpu-$vendor in
tx39el-*)
cpu=mipstx39el
;;
x64-*)
cpu=x86_64
;;
xscale-* | xscalee[bl]-*)
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
;;
@ -1179,90 +1246,227 @@ case $cpu-$vendor in
# Recognize the canonical CPU types that are allowed with any
# company name.
case $cpu in
1750a | 580 \
1750a \
| 580 \
| [cjt]90 \
| a29k \
| aarch64 | aarch64_be | aarch64c | arm64ec \
| aarch64 \
| aarch64_be \
| aarch64c \
| abacus \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
| alphapca5[67] | alpha64pca5[67] \
| alpha \
| alpha64 \
| alpha64ev56 \
| alpha64ev6[78] \
| alpha64ev[4-8] \
| alpha64pca5[67] \
| alphaev56 \
| alphaev6[78] \
| alphaev[4-8] \
| alphapca5[67] \
| am33_2.0 \
| amdgcn \
| arc | arceb | arc32 | arc64 \
| arm | arm[lb]e | arme[lb] | armv* \
| avr | avr32 \
| arc \
| arc32 \
| arc64 \
| arceb \
| arm \
| arm64e \
| arm64ec \
| arm[lb]e \
| arme[lb] \
| armv* \
| asmjs \
| avr \
| avr32 \
| ba \
| be32 | be64 \
| bfin | bpf | bs2000 \
| c[123]* | c30 | [cjt]90 | c4x \
| c8051 | clipper | craynv | csky | cydra \
| d10v | d30v | dlx | dsp16xx \
| e2k | elxsi | epiphany \
| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
| javascript \
| h8300 | h8500 \
| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| be32 \
| be64 \
| bfin \
| bpf \
| bs2000 \
| c30 \
| c4x \
| c8051 \
| c[123]* \
| clipper \
| craynv \
| csky \
| cydra \
| d10v \
| d30v \
| dlx \
| dsp16xx \
| e2k \
| elxsi \
| epiphany \
| f30[01] \
| f700 \
| fido \
| fr30 \
| frv \
| ft32 \
| fx80 \
| h8300 \
| h8500 \
| hexagon \
| i370 | i*86 | i860 | i960 | ia16 | ia64 \
| ip2k | iq2000 \
| hppa \
| hppa1.[01] \
| hppa2.0 \
| hppa2.0[nw] \
| hppa64 \
| i*86 \
| i370 \
| i860 \
| i960 \
| ia16 \
| ia64 \
| ip2k \
| iq2000 \
| javascript \
| k1om \
| kvx \
| le32 | le64 \
| le32 \
| le64 \
| lm32 \
| loongarch32 | loongarch64 \
| m32c | m32r | m32rle \
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
| m88110 | m88k | maxq | mb | mcore | mep | metag \
| microblaze | microblazeel \
| loongarch32 \
| loongarch64 \
| m32c \
| m32r \
| m32rle \
| m5200 \
| m68000 \
| m680[012346]0 \
| m6811 \
| m6812 \
| m68360 \
| m683?2 \
| m68hc11 \
| m68hc12 \
| m68hcs12x \
| m68k \
| m88110 \
| m88k \
| maxq \
| mb \
| mcore \
| mep \
| metag \
| microblaze \
| microblazeel \
| mips* \
| mmix \
| mn10200 | mn10300 \
| mn10200 \
| mn10300 \
| moxie \
| mt \
| msp430 \
| mt \
| nanomips* \
| nds32 | nds32le | nds32be \
| nds32 \
| nds32be \
| nds32le \
| nfp \
| nios | nios2 | nios2eb | nios2el \
| none | np1 | ns16k | ns32k | nvptx \
| nios \
| nios2 \
| nios2eb \
| nios2el \
| none \
| np1 \
| ns16k \
| ns32k \
| nvptx \
| open8 \
| or1k* \
| or32 \
| orion \
| pdp10 \
| pdp11 \
| picochip \
| pdp10 | pdp11 | pj | pjl | pn | power \
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
| pj \
| pjl \
| pn \
| power \
| powerpc \
| powerpc64 \
| powerpc64le \
| powerpcle \
| powerpcspe \
| pru \
| pyramid \
| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
| rl78 | romp | rs6000 | rx \
| s390 | s390x \
| riscv \
| riscv32 \
| riscv32be \
| riscv64 \
| riscv64be \
| rl78 \
| romp \
| rs6000 \
| rx \
| s390 \
| s390x \
| score \
| sh | shl \
| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
| sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
| sh \
| sh64 \
| sh64le \
| sh[12345][lb]e \
| sh[1234] \
| sh[1234]e[lb] \
| sh[23]e \
| sh[23]ele \
| sh[24]a \
| sh[24]ae[lb] \
| sh[lb]e \
| she[lb] \
| shl \
| sparc \
| sparc64 \
| sparc64b \
| sparc64v \
| sparc86x \
| sparclet \
| sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
| sparcv8 \
| sparcv9 \
| sparcv9b \
| sparcv9v \
| spu \
| sv1 \
| sx* \
| tahoe \
| thumbv7* \
| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
| tic30 \
| tic4x \
| tic54x \
| tic55x \
| tic6x \
| tic80 \
| tron \
| ubicom32 \
| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
| v70 \
| v810 \
| v850 \
| v850e \
| v850e1 \
| v850e2 \
| v850e2v3 \
| v850es \
| vax \
| vc4 \
| visium \
| w65 \
| wasm32 | wasm64 \
| wasm32 \
| wasm64 \
| we32k \
| x86 | x86_64 | xc16x | xgate | xps100 \
| xstormy16 | xtensa* \
| x86 \
| x86_64 \
| xc16x \
| xgate \
| xps100 \
| xstormy16 \
| xtensa* \
| ymp \
| z8k | z80)
| z80 \
| z8k)
;;
*)
@ -1307,7 +1511,6 @@ case $basic_os in
os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
;;
*-*)
# shellcheck disable=SC2162
saved_IFS=$IFS
IFS="-" read kernel os <<EOF
$basic_os
@ -1354,6 +1557,23 @@ case $os in
unixware*)
os=sysv4.2uw
;;
# The marketing names for NeXT's operating systems were
# NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
# mapped to 'openstep3', but 'openstep1' and 'openstep2' are
# mapped to 'nextstep' and 'nextstep2', consistent with the
# treatment of SunOS/Solaris.
ns | ns1 | nextstep | nextstep1 | openstep1)
os=nextstep
;;
ns2 | nextstep2 | openstep2)
os=nextstep2
;;
ns3 | nextstep3 | openstep | openstep3)
os=openstep3
;;
ns4 | nextstep4 | openstep4)
os=openstep4
;;
# es1800 is here to avoid being matched by es* (a different OS)
es1800*)
os=ose
@ -1424,6 +1644,7 @@ case $os in
;;
utek*)
os=bsd
vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
;;
dynix*)
os=bsd
@ -1440,21 +1661,25 @@ case $os in
386bsd)
os=bsd
;;
ctix* | uts*)
ctix*)
os=sysv
vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
;;
uts*)
os=sysv
;;
nova*)
os=rtmk-nova
;;
ns2)
os=nextstep2
kernel=rtmk
os=nova
;;
# Preserve the version number of sinix5.
sinix5.*)
os=`echo "$os" | sed -e 's|sinix|sysv|'`
vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
;;
sinix*)
os=sysv4
vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
;;
tpf*)
os=tpf
@ -1595,6 +1820,14 @@ case $cpu-$vendor in
os=
obj=elf
;;
# The -sgi and -siemens entries must be before the mips- entry
# or we get the wrong os.
*-sgi)
os=irix
;;
*-siemens)
os=sysv4
;;
mips*-cisco)
os=
obj=elf
@ -1607,7 +1840,8 @@ case $cpu-$vendor in
os=
obj=coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
# This must be before the sparc-* entry or we get the wrong os.
*-tti)
os=sysv3
;;
sparc-* | *-sun)
@ -1639,7 +1873,7 @@ case $cpu-$vendor in
os=hpux
;;
*-hitachi)
os=hiux
os=hiuxwe2
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=sysv
@ -1683,12 +1917,6 @@ case $cpu-$vendor in
*-encore)
os=bsd
;;
*-sgi)
os=irix
;;
*-siemens)
os=sysv4
;;
*-masscomp)
os=rtu
;;
@ -1735,40 +1963,193 @@ case $os in
ghcjs)
;;
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
| *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
| sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
| hiux* | abug | nacl* | netware* | windows* \
| os9* | macos* | osx* | ios* | tvos* | watchos* \
| mpw* | magic* | mmixware* | mon960* | lnews* \
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
| aos* | aros* | cloudabi* | sortix* | twizzler* \
| nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
| clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
| mirbsd* | netbsd* | dicos* | openedition* | ose* \
| bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
| ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
| bosx* | nextstep* | cxux* | oabi* \
| ptx* | ecoff* | winnt* | domain* | vsta* \
| udi* | lites* | ieee* | go32* | aux* | hcos* \
| chorusrdb* | cegcc* | glidix* | serenity* \
| cygwin* | msys* | moss* | proelf* | rtems* \
| midipix* | mingw32* | mingw64* | mint* \
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
| interix* | uwin* | mks* | rhapsody* | darwin* \
| openstep* | oskit* | conix* | pw32* | nonstopux* \
| storm-chaos* | tops10* | tenex* | tops20* | its* \
| os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
| scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
| powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
| fiwix* | mlibc* | cos* | mbr* | ironclad* )
abug \
| aix* \
| amdhsa* \
| amigados* \
| amigaos* \
| android* \
| aof* \
| aos* \
| aros* \
| atheos* \
| auroraux* \
| aux* \
| beos* \
| bitrig* \
| bme* \
| bosx* \
| bsd* \
| cegcc* \
| chorusos* \
| chorusrdb* \
| clix* \
| cloudabi* \
| cnk* \
| conix* \
| cos* \
| cxux* \
| cygwin* \
| darwin* \
| dgux* \
| dicos* \
| dnix* \
| domain* \
| dragonfly* \
| drops* \
| ebmon* \
| ecoff* \
| ekkobsd* \
| emscripten* \
| emx* \
| es* \
| fiwix* \
| freebsd* \
| fuchsia* \
| genix* \
| genode* \
| glidix* \
| gnu* \
| go32* \
| haiku* \
| hcos* \
| hiux* \
| hms* \
| hpux* \
| ieee* \
| interix* \
| ios* \
| iris* \
| irix* \
| ironclad* \
| isc* \
| its* \
| l4re* \
| libertybsd* \
| lites* \
| lnews* \
| luna* \
| lynxos* \
| mach* \
| macos* \
| magic* \
| mbr* \
| midipix* \
| midnightbsd* \
| mingw32* \
| mingw64* \
| minix* \
| mint* \
| mirbsd* \
| mks* \
| mlibc* \
| mmixware* \
| mon960* \
| morphos* \
| moss* \
| moxiebox* \
| mpeix* \
| mpw* \
| msdos* \
| msys* \
| mvs* \
| nacl* \
| netbsd* \
| netware* \
| newsos* \
| nextstep* \
| nindy* \
| nonstopux* \
| nova* \
| nsk* \
| nucleus* \
| nx6 \
| nx7 \
| oabi* \
| ohos* \
| onefs* \
| openbsd* \
| openedition* \
| openstep* \
| os108* \
| os2* \
| os400* \
| os68k* \
| os9* \
| ose* \
| osf* \
| oskit* \
| osx* \
| palmos* \
| phoenix* \
| plan9* \
| powermax* \
| powerunix* \
| proelf* \
| psos* \
| psp* \
| ptx* \
| pw32* \
| qnx* \
| rdos* \
| redox* \
| rhapsody* \
| riscix* \
| riscos* \
| rtems* \
| rtmk* \
| rtu* \
| scout* \
| secbsd* \
| sei* \
| serenity* \
| sim* \
| skyos* \
| solaris* \
| solidbsd* \
| sortix* \
| storm-chaos* \
| sunos \
| sunos[34]* \
| superux* \
| syllable* \
| sym* \
| sysv* \
| tenex* \
| tirtos* \
| toppers* \
| tops10* \
| tops20* \
| tpf* \
| tvos* \
| twizzler* \
| uclinux* \
| udi* \
| udk* \
| ultrix* \
| unicos* \
| uniplus* \
| unleashed* \
| unos* \
| uwin* \
| uxpv* \
| v88r* \
|*vms* \
| vos* \
| vsta* \
| vxsim* \
| vxworks* \
| wasi* \
| watchos* \
| wince* \
| windiss* \
| windows* \
| winnt* \
| xenix* \
| xray* \
| zephyr* \
| zvmoe* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
@ -1829,9 +2210,9 @@ esac
case $kernel-$os-$obj in
linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
| linux-mlibc*- | linux-musl*- | linux-newlib*- \
| linux-relibc*- | linux-uclibc*- )
| linux-relibc*- | linux-uclibc*- | linux-ohos*- )
;;
uclinux-uclibc*- )
uclinux-uclibc*- | uclinux-gnu*- )
;;
managarm-mlibc*- | managarm-kernel*- )
;;
@ -1856,7 +2237,7 @@ case $kernel-$os-$obj in
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
exit 1
;;
kfreebsd*-gnu*- | kopensolaris*-gnu*-)
kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
;;
vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
;;
@ -1864,6 +2245,8 @@ case $kernel-$os-$obj in
;;
os2-emx-)
;;
rtmk-nova-)
;;
*-eabi*- | *-gnueabi*-)
;;
none--*)
@ -1890,7 +2273,7 @@ case $vendor in
*-riscix*)
vendor=acorn
;;
*-sunos*)
*-sunos* | *-solaris*)
vendor=sun
;;
*-cnk* | *-aix*)

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: execute.c,v 1.60 2024/08/25 19:43:50 tom Exp $
* $MawkId: execute.c,v 1.61 2024/08/26 23:38:53 tom Exp $
*/
#define Visible_ARRAY
@ -45,11 +45,8 @@ static char dz_msg[] = "division by zero";
#define CHECK_DIVZERO(x) do { if ((x) == 0.0 ) rt_error(dz_msg); } while (0)
#endif
#define inc_sp() if ( ++sp == stack_danger) eval_overflow()
#define dec_sp() if ( sp-- == stack_under) eval_underflow()
#define SAFETY 16
#define DANGER (EVAL_STACK_SIZE-SAFETY)
#define DANGER (EVAL_STACK_SIZE - SAFETY - MAX_ARGS)
/* The stack machine that executes the code */
@ -59,6 +56,7 @@ static CELL *stack_base = eval_stack;
static CELL *stack_under = eval_stack;
static CELL *stack_danger = eval_stack + DANGER;
#ifdef DEBUG
static void
eval_overflow(void)
{
@ -71,6 +69,16 @@ eval_underflow(void)
bozo("eval stack underflow");
}
#define inc_sp() if ( ++sp == stack_danger) eval_overflow()
#define dec_sp() if ( sp-- == stack_under) eval_underflow()
#else
#define inc_sp() ++sp
#define dec_sp() sp--
#endif
/* holds info for array loops (on a stack) */
typedef struct aloop_state {
struct aloop_state *link;

View File

@ -1,3 +1,9 @@
mawk-cur (1.3.4-20240827) unstable; urgency=low
* maintenance updates
-- Thomas E. Dickey <dickey@invisible-island.net> Sun, 25 Aug 2024 19:46:51 -0400
mawk-cur (1.3.4-20240825) unstable; urgency=low
* maintenance updates

View File

@ -2,7 +2,7 @@
# $FreeBSD: head/lang/mawk/Makefile 516890 2019-11-06 14:17:48Z wen $
PORTNAME= mawk
DISTVERSION= 1.3.4.20240825
DISTVERSION= 1.3.4.20240827
CATEGORIES= lang
MASTER_SITES= https://invisible-island.net/archives/${PORTNAME}/ \
https://invisible-mirror.net/archives/${PORTNAME}/

View File

@ -1,9 +1,9 @@
Summary: mawk - pattern scanning and text processing language
%global AppProgram mawk
%global AppVersion 1.3.4
%global AppPatched 20240825
%global AppPatched 20240827
%global MySite https://invisible-island.net
# $MawkId: mawk.spec,v 1.124 2024/08/25 22:51:21 tom Exp $
# $MawkId: mawk.spec,v 1.126 2024/08/27 07:48:11 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: %{AppPatched}

396
parse.c
View File

@ -1704,7 +1704,7 @@ static YYINT *yylexp = 0;
static YYINT *yylexemes = 0;
#endif /* YYBTYACC */
#line 1184 "parse.y"
#line 1192 "parse.y"
/*
* Check for special case where there is a forward reference to a newly
@ -3119,112 +3119,120 @@ case 81:
#line 432 "parse.y"
{ const BI_REC *p = yystack.l_mark[-4].bip ;
yyval.start = yystack.l_mark[-3].start ;
if ( (int)p->min_args > yystack.l_mark[-1].ival || (int)p->max_args < yystack.l_mark[-1].ival )
compile_error(
"wrong number of arguments in call to %s" ,
p->name ) ;
if ( (int)p->min_args > yystack.l_mark[-1].ival )
compile_error(
"not enough arguments in call to %s: %d (need %d)" ,
p->name, yystack.l_mark[-1].ival, (int)p->min_args ) ;
if ( (int)p->max_args < yystack.l_mark[-1].ival )
compile_error(
"too many arguments in call to %s: %d (maximum %d)" ,
p->name, yystack.l_mark[-1].ival, (int)p->max_args ) ;
if ( p->min_args != p->max_args ) /* variable args */
{ code1(_PUSHINT) ; code1(yystack.l_mark[-1].ival) ; }
func2(_BUILTIN , p->fp) ;
}
#line 3131 "parse.c"
#line 3135 "parse.c"
break;
case 82:
#line 446 "parse.y"
#line 450 "parse.y"
{ yyval.start = code_offset ; }
#line 3136 "parse.c"
#line 3140 "parse.c"
break;
case 83:
#line 451 "parse.y"
#line 455 "parse.y"
{ func2(_PRINT, yystack.l_mark[-4].fp) ;
if ( yystack.l_mark[-2].ival > MAX_ARGS )
compile_error("too many arguments in call to %s: %d (maximum %d)",
( yystack.l_mark[-4].fp == bi_printf ) ? "printf" : "print",
yystack.l_mark[-2].ival, MAX_ARGS) ;
if ( yystack.l_mark[-4].fp == bi_printf && yystack.l_mark[-2].ival == 0 )
compile_error("no arguments in call to printf") ;
compile_error("no arguments in call to printf") ;
print_flag = 0 ;
yyval.start = yystack.l_mark[-3].start ;
}
#line 3146 "parse.c"
#line 3154 "parse.c"
break;
case 84:
#line 459 "parse.y"
#line 467 "parse.y"
{ yyval.fp = bi_print ; print_flag = 1 ;}
#line 3151 "parse.c"
#line 3159 "parse.c"
break;
case 85:
#line 460 "parse.y"
#line 468 "parse.y"
{ yyval.fp = bi_printf ; print_flag = 1 ; }
#line 3156 "parse.c"
#line 3164 "parse.c"
break;
case 86:
#line 463 "parse.y"
#line 471 "parse.y"
{ code2op(_PUSHINT, yystack.l_mark[0].ival) ; }
#line 3161 "parse.c"
#line 3169 "parse.c"
break;
case 87:
#line 465 "parse.y"
#line 473 "parse.y"
{ yyval.ival = yystack.l_mark[-1].arg2p->cnt ; zfree(yystack.l_mark[-1].arg2p,sizeof(ARG2_REC)) ;
code2op(_PUSHINT, yyval.ival) ;
}
#line 3168 "parse.c"
#line 3176 "parse.c"
break;
case 88:
#line 469 "parse.y"
#line 477 "parse.y"
{ yyval.ival=0 ; code2op(_PUSHINT, 0) ; }
#line 3173 "parse.c"
#line 3181 "parse.c"
break;
case 89:
#line 473 "parse.y"
#line 481 "parse.y"
{ yyval.arg2p = ZMALLOC(ARG2_REC) ;
yyval.arg2p->start = yystack.l_mark[-2].start ;
yyval.arg2p->cnt = 2 ;
}
#line 3181 "parse.c"
#line 3189 "parse.c"
break;
case 90:
#line 478 "parse.y"
#line 486 "parse.y"
{ yyval.arg2p = yystack.l_mark[-2].arg2p ; yyval.arg2p->cnt++ ; }
#line 3186 "parse.c"
#line 3194 "parse.c"
break;
case 92:
#line 483 "parse.y"
#line 491 "parse.y"
{ code2op(_PUSHINT, yystack.l_mark[-1].ival) ; }
#line 3191 "parse.c"
#line 3199 "parse.c"
break;
case 93:
#line 490 "parse.y"
#line 498 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; eat_nl() ; code_jmp(_JZ, (INST*)0) ; }
#line 3196 "parse.c"
#line 3204 "parse.c"
break;
case 94:
#line 495 "parse.y"
#line 503 "parse.y"
{ patch_jmp( code_ptr ) ; }
#line 3201 "parse.c"
#line 3209 "parse.c"
break;
case 95:
#line 498 "parse.y"
#line 506 "parse.y"
{ eat_nl() ; code_jmp(_JMP, (INST*)0) ; }
#line 3206 "parse.c"
#line 3214 "parse.c"
break;
case 96:
#line 503 "parse.y"
#line 511 "parse.y"
{ patch_jmp(code_ptr) ;
patch_jmp(CDP(yystack.l_mark[0].start)) ;
}
#line 3213 "parse.c"
#line 3221 "parse.c"
break;
case 97:
#line 512 "parse.y"
#line 520 "parse.y"
{ eat_nl() ; BC_new() ; }
#line 3218 "parse.c"
#line 3226 "parse.c"
break;
case 98:
#line 517 "parse.y"
#line 525 "parse.y"
{ yyval.start = yystack.l_mark[-5].start ;
code_jmp(_JNZ, CDP(yystack.l_mark[-5].start)) ;
BC_clear(code_ptr, CDP(yystack.l_mark[-2].start)) ; }
#line 3225 "parse.c"
#line 3233 "parse.c"
break;
case 99:
#line 523 "parse.y"
#line 531 "parse.y"
{ eat_nl() ; BC_new() ;
yyval.start = yystack.l_mark[-1].start ;
@ -3241,10 +3249,10 @@ case 99:
code2(_JMP, (INST*)0) ; /* code2() not code_jmp() */
}
}
#line 3245 "parse.c"
#line 3253 "parse.c"
break;
case 100:
#line 543 "parse.y"
#line 551 "parse.y"
{
INST *p1 = CDP(yystack.l_mark[-1].start) ;
INST *p2 = CDP(yystack.l_mark[0].start) ;
@ -3267,10 +3275,10 @@ case 100:
BC_clear(code_ptr, CDP(yystack.l_mark[0].start)) ;
}
}
#line 3271 "parse.c"
#line 3279 "parse.c"
break;
case 101:
#line 570 "parse.y"
#line 578 "parse.y"
{
int cont_offset = code_offset ;
unsigned len = code_pop(code_ptr) ;
@ -3292,25 +3300,25 @@ case 101:
BC_clear(code_ptr, CDP(cont_offset)) ;
}
#line 3296 "parse.c"
#line 3304 "parse.c"
break;
case 102:
#line 593 "parse.y"
#line 601 "parse.y"
{ yyval.start = code_offset ; }
#line 3301 "parse.c"
#line 3309 "parse.c"
break;
case 103:
#line 595 "parse.y"
#line 603 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; code1(_POP) ; }
#line 3306 "parse.c"
#line 3314 "parse.c"
break;
case 104:
#line 598 "parse.y"
#line 606 "parse.y"
{ yyval.start = code_offset ; }
#line 3311 "parse.c"
#line 3319 "parse.c"
break;
case 105:
#line 600 "parse.y"
#line 608 "parse.y"
{
if ( code_ptr - 2 == CDP(yystack.l_mark[-1].start) &&
code_ptr[-2].op == _PUSHD &&
@ -3325,17 +3333,17 @@ case 105:
code2(_JMP, (INST*)0) ;
}
}
#line 3329 "parse.c"
#line 3337 "parse.c"
break;
case 106:
#line 617 "parse.y"
#line 625 "parse.y"
{ eat_nl() ; BC_new() ;
code_push((INST*)0,0, scope, active_funct) ;
}
#line 3336 "parse.c"
#line 3344 "parse.c"
break;
case 107:
#line 621 "parse.y"
#line 629 "parse.y"
{ INST *p1 = CDP(yystack.l_mark[-1].start) ;
eat_nl() ; BC_new() ;
@ -3343,18 +3351,18 @@ case 107:
code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ;
code_ptr -= code_ptr - p1 ;
}
#line 3347 "parse.c"
#line 3355 "parse.c"
break;
case 108:
#line 634 "parse.y"
#line 642 "parse.y"
{ check_array(yystack.l_mark[0].stp) ;
code_array(yystack.l_mark[0].stp) ;
code1(A_TEST) ;
}
#line 3355 "parse.c"
#line 3363 "parse.c"
break;
case 109:
#line 639 "parse.y"
#line 647 "parse.y"
{ yyval.start = yystack.l_mark[-3].arg2p->start ;
code2op(A_CAT, yystack.l_mark[-3].arg2p->cnt) ;
zfree(yystack.l_mark[-3].arg2p, sizeof(ARG2_REC)) ;
@ -3363,10 +3371,10 @@ case 109:
code_array(yystack.l_mark[0].stp) ;
code1(A_TEST) ;
}
#line 3367 "parse.c"
#line 3375 "parse.c"
break;
case 110:
#line 650 "parse.y"
#line 658 "parse.y"
{
if ( yystack.l_mark[-1].ival > 1 )
{ code2op(A_CAT, yystack.l_mark[-1].ival) ; }
@ -3377,10 +3385,10 @@ case 110:
else code2(AE_PUSHA, yystack.l_mark[-4].stp->stval.array) ;
yyval.start = yystack.l_mark[-3].start ;
}
#line 3381 "parse.c"
#line 3389 "parse.c"
break;
case 111:
#line 663 "parse.y"
#line 671 "parse.y"
{
if ( yystack.l_mark[-1].ival > 1 )
{ code2op(A_CAT, yystack.l_mark[-1].ival) ; }
@ -3391,10 +3399,10 @@ case 111:
else code2(AE_PUSHI, yystack.l_mark[-4].stp->stval.array) ;
yyval.start = yystack.l_mark[-3].start ;
}
#line 3395 "parse.c"
#line 3403 "parse.c"
break;
case 112:
#line 675 "parse.y"
#line 683 "parse.y"
{
if ( yystack.l_mark[-2].ival > 1 )
{ code2op(A_CAT,yystack.l_mark[-2].ival) ; }
@ -3408,10 +3416,10 @@ case 112:
yyval.start = yystack.l_mark[-4].start ;
}
#line 3412 "parse.c"
#line 3420 "parse.c"
break;
case 113:
#line 692 "parse.y"
#line 700 "parse.y"
{
yyval.start = yystack.l_mark[-4].start ;
if ( yystack.l_mark[-2].ival > 1 ) { code2op(A_CAT, yystack.l_mark[-2].ival) ; }
@ -3419,20 +3427,20 @@ case 113:
code_array(yystack.l_mark[-5].stp) ;
code1(A_DEL) ;
}
#line 3423 "parse.c"
#line 3431 "parse.c"
break;
case 114:
#line 700 "parse.y"
#line 708 "parse.y"
{
yyval.start = code_offset ;
check_array(yystack.l_mark[-1].stp) ;
code_array(yystack.l_mark[-1].stp) ;
code1(DEL_A) ;
}
#line 3433 "parse.c"
#line 3441 "parse.c"
break;
case 115:
#line 711 "parse.y"
#line 719 "parse.y"
{ eat_nl() ; BC_new() ;
yyval.start = code_offset ;
@ -3443,10 +3451,10 @@ case 115:
code2(SET_ALOOP, (INST*)0) ;
}
#line 3447 "parse.c"
#line 3455 "parse.c"
break;
case 116:
#line 725 "parse.y"
#line 733 "parse.y"
{
INST *p2 = CDP(yystack.l_mark[0].start) ;
@ -3455,15 +3463,15 @@ case 116:
code_jmp(ALOOP, p2) ;
code1(POP_AL) ;
}
#line 3459 "parse.c"
#line 3467 "parse.c"
break;
case 117:
#line 742 "parse.y"
#line 750 "parse.y"
{ yyval.start = code_offset ; code2(F_PUSHA, yystack.l_mark[0].cp) ; }
#line 3464 "parse.c"
#line 3472 "parse.c"
break;
case 118:
#line 744 "parse.y"
#line 752 "parse.y"
{ check_var(yystack.l_mark[0].stp) ;
yyval.start = code_offset ;
if ( is_local(yystack.l_mark[0].stp) )
@ -3472,10 +3480,10 @@ case 118:
CODE_FE_PUSHA() ;
}
#line 3476 "parse.c"
#line 3484 "parse.c"
break;
case 119:
#line 753 "parse.y"
#line 761 "parse.y"
{
if ( yystack.l_mark[-1].ival > 1 )
{ code2op(A_CAT, yystack.l_mark[-1].ival) ; }
@ -3489,78 +3497,78 @@ case 119:
yyval.start = yystack.l_mark[-3].start ;
}
#line 3493 "parse.c"
#line 3501 "parse.c"
break;
case 120:
#line 767 "parse.y"
#line 775 "parse.y"
{ yyval.start = yystack.l_mark[0].start ; CODE_FE_PUSHA() ; }
#line 3498 "parse.c"
#line 3506 "parse.c"
break;
case 121:
#line 769 "parse.y"
#line 777 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; }
#line 3503 "parse.c"
#line 3511 "parse.c"
break;
case 122:
#line 773 "parse.y"
#line 781 "parse.y"
{ field_A2I() ; }
#line 3508 "parse.c"
#line 3516 "parse.c"
break;
case 123:
#line 776 "parse.y"
#line 784 "parse.y"
{ code1(F_ASSIGN) ; }
#line 3513 "parse.c"
#line 3521 "parse.c"
break;
case 124:
#line 777 "parse.y"
#line 785 "parse.y"
{ code1(F_ADD_ASG) ; }
#line 3518 "parse.c"
#line 3526 "parse.c"
break;
case 125:
#line 778 "parse.y"
#line 786 "parse.y"
{ code1(F_SUB_ASG) ; }
#line 3523 "parse.c"
#line 3531 "parse.c"
break;
case 126:
#line 779 "parse.y"
#line 787 "parse.y"
{ code1(F_MUL_ASG) ; }
#line 3528 "parse.c"
#line 3536 "parse.c"
break;
case 127:
#line 780 "parse.y"
#line 788 "parse.y"
{ code1(F_DIV_ASG) ; }
#line 3533 "parse.c"
#line 3541 "parse.c"
break;
case 128:
#line 781 "parse.y"
#line 789 "parse.y"
{ code1(F_MOD_ASG) ; }
#line 3538 "parse.c"
#line 3546 "parse.c"
break;
case 129:
#line 782 "parse.y"
#line 790 "parse.y"
{ code1(F_POW_ASG) ; }
#line 3543 "parse.c"
#line 3551 "parse.c"
break;
case 130:
#line 789 "parse.y"
#line 797 "parse.y"
{ func2(_BUILTIN, bi_split) ; }
#line 3548 "parse.c"
#line 3556 "parse.c"
break;
case 131:
#line 793 "parse.y"
#line 801 "parse.y"
{ yyval.start = yystack.l_mark[-2].start ;
check_array(yystack.l_mark[0].stp) ;
code_array(yystack.l_mark[0].stp) ;
}
#line 3556 "parse.c"
#line 3564 "parse.c"
break;
case 132:
#line 800 "parse.y"
#line 808 "parse.y"
{ code2(_PUSHI, &fs_shadow) ; }
#line 3561 "parse.c"
#line 3569 "parse.c"
break;
case 133:
#line 802 "parse.y"
#line 810 "parse.y"
{
if ( CDP(yystack.l_mark[-1].start) == code_ptr - 2 )
{
@ -3580,25 +3588,25 @@ case 133:
}
}
}
#line 3584 "parse.c"
#line 3592 "parse.c"
break;
case 134:
#line 825 "parse.y"
#line 833 "parse.y"
{ yyval.start = code_offset ;
code2(_PUSHI,field) ;
func2(_BUILTIN,bi_length) ;
}
#line 3592 "parse.c"
#line 3600 "parse.c"
break;
case 135:
#line 830 "parse.y"
#line 838 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ;
func2(_BUILTIN,bi_length) ;
}
#line 3599 "parse.c"
#line 3607 "parse.c"
break;
case 136:
#line 834 "parse.y"
#line 842 "parse.y"
{
SYMTAB* stp = yystack.l_mark[-1].stp;
yyval.start = code_offset;
@ -3645,25 +3653,25 @@ case 136:
break;
}
}
#line 3649 "parse.c"
#line 3657 "parse.c"
break;
case 137:
#line 882 "parse.y"
#line 890 "parse.y"
{ yyval.start = code_offset ;
code2(_PUSHI,field) ;
func2(_BUILTIN,bi_length) ;
}
#line 3657 "parse.c"
#line 3665 "parse.c"
break;
case 138:
#line 891 "parse.y"
#line 899 "parse.y"
{ yyval.start = yystack.l_mark[-3].start ;
func2(_BUILTIN, bi_match) ;
}
#line 3664 "parse.c"
#line 3672 "parse.c"
break;
case 139:
#line 898 "parse.y"
#line 906 "parse.y"
{
INST *p1 = CDP(yystack.l_mark[0].start) ;
@ -3683,92 +3691,92 @@ case 139:
}
}
}
#line 3687 "parse.c"
#line 3695 "parse.c"
break;
case 140:
#line 922 "parse.y"
#line 930 "parse.y"
{ yyval.start = code_offset ;
code1(_EXIT0) ; }
#line 3693 "parse.c"
#line 3701 "parse.c"
break;
case 141:
#line 925 "parse.y"
#line 933 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; code1(_EXIT) ; }
#line 3698 "parse.c"
#line 3706 "parse.c"
break;
case 142:
#line 929 "parse.y"
#line 937 "parse.y"
{ yyval.start = code_offset ;
code1(_RET0) ; }
#line 3704 "parse.c"
#line 3712 "parse.c"
break;
case 143:
#line 932 "parse.y"
#line 940 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; code1(_RET) ; }
#line 3709 "parse.c"
#line 3717 "parse.c"
break;
case 144:
#line 938 "parse.y"
#line 946 "parse.y"
{ yyval.start = code_offset ;
code2(F_PUSHA, &field[0]) ;
code1(_PUSHINT) ; code1(0) ;
func2(_BUILTIN, bi_getline) ;
getline_flag = 0 ;
}
#line 3719 "parse.c"
#line 3727 "parse.c"
break;
case 145:
#line 945 "parse.y"
#line 953 "parse.y"
{ yyval.start = yystack.l_mark[0].start ;
code1(_PUSHINT) ; code1(0) ;
func2(_BUILTIN, bi_getline) ;
getline_flag = 0 ;
}
#line 3728 "parse.c"
#line 3736 "parse.c"
break;
case 146:
#line 951 "parse.y"
#line 959 "parse.y"
{ code1(_PUSHINT) ; code1(F_IN) ;
func2(_BUILTIN, bi_getline) ;
/* getline_flag already off in yylex() */
}
#line 3736 "parse.c"
break;
case 147:
#line 956 "parse.y"
{ code2(F_PUSHA, &field[0]) ;
code1(_PUSHINT) ; code1(PIPE_IN) ;
func2(_BUILTIN, bi_getline) ;
}
#line 3744 "parse.c"
break;
case 148:
#line 961 "parse.y"
{
case 147:
#line 964 "parse.y"
{ code2(F_PUSHA, &field[0]) ;
code1(_PUSHINT) ; code1(PIPE_IN) ;
func2(_BUILTIN, bi_getline) ;
}
#line 3752 "parse.c"
break;
case 148:
#line 969 "parse.y"
{
code1(_PUSHINT) ; code1(PIPE_IN) ;
func2(_BUILTIN, bi_getline) ;
}
#line 3760 "parse.c"
break;
case 149:
#line 967 "parse.y"
#line 975 "parse.y"
{ getline_flag = 1 ; }
#line 3757 "parse.c"
#line 3765 "parse.c"
break;
case 152:
#line 972 "parse.y"
#line 980 "parse.y"
{ yyval.start = code_offset ;
code2(F_PUSHA, field+0) ;
}
#line 3764 "parse.c"
#line 3772 "parse.c"
break;
case 153:
#line 976 "parse.y"
#line 984 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; }
#line 3769 "parse.c"
#line 3777 "parse.c"
break;
case 154:
#line 984 "parse.y"
#line 992 "parse.y"
{
INST *p5 = CDP(yystack.l_mark[-1].start) ;
INST *p6 = CDP(yystack.l_mark[0].start) ;
@ -3786,41 +3794,41 @@ case 154:
func2(_BUILTIN, yystack.l_mark[-5].fp) ;
yyval.start = yystack.l_mark[-3].start ;
}
#line 3790 "parse.c"
#line 3798 "parse.c"
break;
case 155:
#line 1003 "parse.y"
#line 1011 "parse.y"
{ yyval.fp = bi_sub ; }
#line 3795 "parse.c"
#line 3803 "parse.c"
break;
case 156:
#line 1004 "parse.y"
#line 1012 "parse.y"
{ yyval.fp = bi_gsub ; }
#line 3800 "parse.c"
#line 3808 "parse.c"
break;
case 157:
#line 1009 "parse.y"
#line 1017 "parse.y"
{ yyval.start = code_offset ;
code2(F_PUSHA, &field[0]) ;
}
#line 3807 "parse.c"
#line 3815 "parse.c"
break;
case 158:
#line 1014 "parse.y"
#line 1022 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ; }
#line 3812 "parse.c"
#line 3820 "parse.c"
break;
case 159:
#line 1022 "parse.y"
#line 1030 "parse.y"
{
resize_fblock(yystack.l_mark[-1].fbp) ;
restore_ids() ;
switch_code_to_main() ;
}
#line 3821 "parse.c"
#line 3829 "parse.c"
break;
case 160:
#line 1031 "parse.y"
#line 1039 "parse.y"
{ eat_nl() ;
scope = SCOPE_FUNCT ;
active_funct = yystack.l_mark[-3].fbp ;
@ -3839,10 +3847,10 @@ case 160:
improve_arglist(yystack.l_mark[-3].fbp->name);
free_arglist();
}
#line 3843 "parse.c"
#line 3851 "parse.c"
break;
case 161:
#line 1052 "parse.y"
#line 1060 "parse.y"
{ FBLOCK *fbp ;
if ( yystack.l_mark[0].stp == NULL )
@ -3868,32 +3876,32 @@ case 161:
}
yyval.fbp = fbp ;
}
#line 3872 "parse.c"
#line 3880 "parse.c"
break;
case 162:
#line 1079 "parse.y"
#line 1087 "parse.y"
{ yyval.fbp = yystack.l_mark[0].fbp ;
if ( yystack.l_mark[0].fbp->code )
compile_error("redefinition of %s" , yystack.l_mark[0].fbp->name) ;
}
#line 3880 "parse.c"
#line 3888 "parse.c"
break;
case 163:
#line 1085 "parse.y"
#line 1093 "parse.y"
{ yyval.ival = init_arglist() ; }
#line 3885 "parse.c"
#line 3893 "parse.c"
break;
case 165:
#line 1090 "parse.y"
#line 1098 "parse.y"
{ init_arglist();
yystack.l_mark[0].stp = save_arglist(yystack.l_mark[0].stp->name) ;
yystack.l_mark[0].stp->offset = 0 ;
yyval.ival = 1 ;
}
#line 3894 "parse.c"
#line 3902 "parse.c"
break;
case 166:
#line 1096 "parse.y"
#line 1104 "parse.y"
{ if ( is_local(yystack.l_mark[0].stp) )
compile_error("%s is duplicated in argument list",
yystack.l_mark[0].stp->name) ;
@ -3903,10 +3911,10 @@ case 166:
yyval.ival = yystack.l_mark[-2].ival + 1 ;
}
}
#line 3907 "parse.c"
#line 3915 "parse.c"
break;
case 167:
#line 1108 "parse.y"
#line 1116 "parse.y"
{ /* we may have to recover from a bungled function
definition */
/* can have local ids, before code scope
@ -3915,10 +3923,10 @@ case 167:
switch_code_to_main() ;
}
#line 3919 "parse.c"
#line 3927 "parse.c"
break;
case 168:
#line 1121 "parse.y"
#line 1129 "parse.y"
{ yyval.start = yystack.l_mark[-1].start ;
code2(_CALL, yystack.l_mark[-2].fbp) ;
@ -3927,29 +3935,29 @@ case 168:
check_fcall(yystack.l_mark[-2].fbp, scope, code_move_level, active_funct, yystack.l_mark[0].ca_p) ;
}
#line 3931 "parse.c"
#line 3939 "parse.c"
break;
case 169:
#line 1132 "parse.y"
#line 1140 "parse.y"
{ yyval.ca_p = (CA_REC *) 0 ; }
#line 3936 "parse.c"
#line 3944 "parse.c"
break;
case 170:
#line 1134 "parse.y"
#line 1142 "parse.y"
{ yyval.ca_p = yystack.l_mark[0].ca_p ;
yyval.ca_p->link = yystack.l_mark[-1].ca_p ;
yyval.ca_p->arg_num = (NUM_ARGS) (yystack.l_mark[-1].ca_p ? yystack.l_mark[-1].ca_p->arg_num+1 : 0) ;
yyval.ca_p->call_lineno = token_lineno;
}
#line 3945 "parse.c"
#line 3953 "parse.c"
break;
case 171:
#line 1150 "parse.y"
#line 1158 "parse.y"
{ yyval.ca_p = (CA_REC *) 0 ; }
#line 3950 "parse.c"
#line 3958 "parse.c"
break;
case 172:
#line 1152 "parse.y"
#line 1160 "parse.y"
{ yyval.ca_p = ZMALLOC(CA_REC) ;
yyval.ca_p->link = yystack.l_mark[-2].ca_p ;
yyval.ca_p->type = CA_EXPR ;
@ -3957,10 +3965,10 @@ case 172:
yyval.ca_p->call_offset = code_offset ;
yyval.ca_p->call_lineno = token_lineno;
}
#line 3961 "parse.c"
#line 3969 "parse.c"
break;
case 173:
#line 1160 "parse.y"
#line 1168 "parse.y"
{ yyval.ca_p = ZMALLOC(CA_REC) ;
yyval.ca_p->type = ST_NONE ;
yyval.ca_p->link = yystack.l_mark[-2].ca_p ;
@ -3969,25 +3977,25 @@ case 173:
code_call_id(yyval.ca_p, yystack.l_mark[-1].stp) ;
}
#line 3973 "parse.c"
#line 3981 "parse.c"
break;
case 174:
#line 1171 "parse.y"
#line 1179 "parse.y"
{ yyval.ca_p = ZMALLOC(CA_REC) ;
yyval.ca_p->type = CA_EXPR ;
yyval.ca_p->call_offset = code_offset ;
}
#line 3981 "parse.c"
#line 3989 "parse.c"
break;
case 175:
#line 1177 "parse.y"
#line 1185 "parse.y"
{ yyval.ca_p = ZMALLOC(CA_REC) ;
yyval.ca_p->type = ST_NONE ;
code_call_id(yyval.ca_p, yystack.l_mark[-1].stp) ;
}
#line 3989 "parse.c"
#line 3997 "parse.c"
break;
#line 3991 "parse.c"
#line 3999 "parse.c"
default:
break;
}

22
parse.y
View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: parse.y,v 1.39 2024/08/25 19:49:34 tom Exp $
* $MawkId: parse.y,v 1.41 2024/08/26 21:04:00 tom Exp $
*/
%{
@ -431,10 +431,14 @@ builtin :
BUILTIN mark LPAREN arglist RPAREN
{ const BI_REC *p = $1 ;
$$ = $2 ;
if ( (int)p->min_args > $4 || (int)p->max_args < $4 )
compile_error(
"wrong number of arguments in call to %s" ,
p->name ) ;
if ( (int)p->min_args > $4 )
compile_error(
"not enough arguments in call to %s: %d (need %d)" ,
p->name, $4, (int)p->min_args ) ;
if ( (int)p->max_args < $4 )
compile_error(
"too many arguments in call to %s: %d (maximum %d)" ,
p->name, $4, (int)p->max_args ) ;
if ( p->min_args != p->max_args ) /* variable args */
{ code1(_PUSHINT) ; code1($4) ; }
func2(_BUILTIN , p->fp) ;
@ -449,8 +453,12 @@ mark : /* empty */
/* print_statement */
statement : print mark pr_args pr_direction separator
{ func2(_PRINT, $1) ;
if ( $3 > MAX_ARGS )
compile_error("too many arguments in call to %s: %d (maximum %d)",
( $1 == bi_printf ) ? "printf" : "print",
$3, MAX_ARGS) ;
if ( $1 == bi_printf && $3 == 0 )
compile_error("no arguments in call to printf") ;
compile_error("no arguments in call to printf") ;
print_flag = 0 ;
$$ = $2 ;
}
@ -878,7 +886,7 @@ p_expr : LENGTH LPAREN RPAREN
}
}
;
p_expr : LENGTH %prec CAT /* fixes s/r conflict length vs length() */
p_expr : LENGTH %prec CAT /* fixes s/r conflict length vs length() */
{ $$ = code_offset ;
code2(_PUSHI,field) ;
func2(_BUILTIN,bi_length) ;

View File

@ -11,9 +11,9 @@ the GNU General Public License, version 2, 1991.
*/
/*
* $MawkId: patchlev.h,v 1.151 2024/08/25 22:51:21 tom Exp $
* $MawkId: patchlev.h,v 1.153 2024/08/27 07:48:11 tom Exp $
*/
#define PATCH_BASE 1
#define PATCH_LEVEL 3
#define PATCH_STRING ".4"
#define DATE_STRING "20240825"
#define DATE_STRING "20240827"

View File

@ -12,7 +12,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: rexp3.c,v 1.63 2024/08/25 17:16:24 tom Exp $
* $MawkId: rexp3.c,v 1.65 2024/08/27 20:48:02 tom Exp $
*/
/* match a string against a machine */
@ -259,10 +259,8 @@ REmatch(char *str, /* string to test */
m++;
RE_CASE();
#ifndef LCOV_UNUSED
case M_CLASS + U_OFF + END_ON:
/* NOTREACHED */
if (s >= str_end || !ison(*m->s_data.bvp, s[0])) {
if (s >= str_end || s[1] || !ison(*m->s_data.bvp, s[0])) {
RE_FILL();
} else if (!ss) {
if (cb_ss && current_best(s)) {
@ -274,7 +272,6 @@ REmatch(char *str, /* string to test */
s = str_end;
m++;
RE_CASE();
#endif
case M_CLASS + U_ON + END_OFF:
if (s < str)

View File

@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: symtype.h,v 1.28 2024/08/25 17:21:52 tom Exp $
* $MawkId: symtype.h,v 1.29 2024/08/26 08:08:39 tom Exp $
*/
/* types related to symbols are defined here */
@ -21,6 +21,7 @@ the GNU General Public License, version 2, 1991.
#include <types.h>
#define MAX_ARGS 255
typedef unsigned char NUM_ARGS;
typedef unsigned char SYM_TYPE;

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MawkId: mawkerrs,v 1.12 2024/08/19 20:49:13 tom Exp $
# $MawkId: mawkerrs,v 1.18 2024/08/27 07:50:27 tom Exp $
###############################################################################
# copyright 2024, Thomas E. Dickey
#
@ -205,12 +205,57 @@ echo 'mawk: line 2: missing } near end of file' >$STDERR
$PROG -Wd 'BEGIN{ printf "?\n"' 2>&1 | cmp -s - "$STDERR" || Fail "missing right brace"
Finish "test for missing right-brace"
Begin "test for enough arguments of index()"
echo 'mawk: line 1: not enough arguments in call to index: 1 (need 2)' >$STDERR
$PROG -Wd 'BEGIN{ foo = index("?"); }' 2>&1 | cmp -s - "$STDERR" || Fail "enough arguments for index()"
Finish "test for enough arguments of index()"
Begin "test for too many arguments of index()"
echo 'mawk: line 1: too many arguments in call to index: 4 (maximum 2)' >$STDERR
$PROG -Wd 'BEGIN{ foo = index("?",1,2,3); }' 2>&1 | cmp -s - "$STDERR" || Fail "too many arguments for index()"
Finish "test for too many arguments of index()"
Begin "test for too many arguments of print()"
echo 'mawk: line 1: too many arguments in call to print: 256 (maximum 255)' >$STDERR
$PROG -Wd 'BEGIN{ print 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ; }' 2>&1 | cmp -s - "$STDERR" || Fail "too many arguments for print()"
Finish "test for too many arguments of print()"
Begin "test for return outside function"
echo 'mawk: line 1: return outside function body' >$STDERR
$PROG -Wd 'BEGIN{ return ; }' 2>&1 | cmp -s - "$STDERR" || Fail "return outside function"
Finish "test for return outside function"
Begin "test for improper use of next"
echo 'mawk: line 1: improper use of next' >$STDERR
$PROG -Wd 'function foo() { next; }BEGIN{ }' 2>&1 | cmp -s - "$STDERR" || Fail "improper use of next"
Finish "test for improper use of next"
Begin "test for improper use of nextfile"
echo 'mawk: line 1: improper use of nextfile' >$STDERR
$PROG -Wd 'function foo() { nextfile; }BEGIN{ }' 2>&1 | cmp -s - "$STDERR" || Fail "improper use of nextfile"
Finish "test for improper use of nextfile"
Begin "test for redefinition of function"
echo 'mawk: line 1: redefinition of foo' >$STDERR
$PROG -Wd 'function foo() { print; }function foo(){ printf "?"; }BEGIN{ }' 2>&1 | cmp -s - "$STDERR" || Fail "redefinition of function"
Finish "test for redefinition of function"
Begin "test for illegal reference to variable"
echo 'mawk: line 1: illegal reference to variable bar' >$STDERR
$PROG -Wd 'function foo() { bar = 1; }function bar(){ }BEGIN{ print(); }' 2>&1 | cmp -s - "$STDERR" || Fail "illegal reference to variable"
Finish "test for illegal reference to variable"
Begin "test for illegal reference to array"
echo 'mawk: line 1: illegal reference to array A' >$STDERR
$PROG -Wd 'function foo() { A[1] = 1; }function A(){ }BEGIN{ print(); }' 2>&1 | cmp -s - "$STDERR" || Fail "illegal reference to array"
Finish "test for illegal reference to array"
######## print.c
Begin "test sprintf buffer-overflow"
echo 'mawk: program limit exceeded: sprintf buffer size=8192' >$STDERR
echo ' FILENAME="" FNR=0 NR=0' >>$STDERR
$PROG 'BEGIN{ foo = sprintf("%10000s\n", "x"); print length(foo); }' 2>&1 | cmp -s - "$STDERR" || Fail "missing right brace"
$PROG 'BEGIN{ foo = sprintf("%10000s\n", "x"); print length(foo); }' 2>&1 | cmp -s - "$STDERR" || Fail "sprintf buffer-overflow"
Finish "test sprintf buffer-overflow"
######## scan.c