├── CHANGELOG.md ├── LICENSE ├── Makefile ├── Makefile.in ├── README.md ├── configure ├── getline.c ├── onefile └── wak.c ├── scripts ├── make_mono.awk └── make_toybox_awk.awk ├── src ├── common.c ├── common.h ├── compile.c ├── lib.c ├── main.c ├── run.c └── scan.c ├── test ├── COPYING └── gawktests │ ├── addcomma.awk │ ├── addcomma.in │ ├── addcomma.ok │ ├── anchgsub.awk │ ├── anchgsub.in │ ├── anchgsub.ok │ ├── anchor.awk │ ├── anchor.in │ ├── anchor.ok │ ├── arrayind1.awk │ ├── arrayind1.in │ ├── arrayind1.ok │ ├── arrayind3.awk │ ├── arrayind3.ok │ ├── arrayprm2.awk │ ├── arrayprm2.ok │ ├── arrayprm3.awk │ ├── arrayprm3.ok │ ├── arrayref.awk │ ├── arrayref.ok │ ├── arrymem1.awk │ ├── arrymem1.ok │ ├── arynasty.awk │ ├── arynasty.ok │ ├── aryprm8.awk │ ├── aryprm8.ok │ ├── aryprm9.awk │ ├── aryprm9.ok │ ├── arysubnm.awk │ ├── arysubnm.ok │ ├── aryunasgn.awk │ ├── aryunasgn.ok │ ├── asgext.awk │ ├── asgext.in │ ├── asgext.ok │ ├── assignnumfield.awk │ ├── assignnumfield.in │ ├── assignnumfield.ok │ ├── assignnumfield2.awk │ ├── assignnumfield2.ok │ ├── backgsub.awk │ ├── backgsub.in │ ├── backgsub.ok │ ├── backsmalls2.awk │ ├── backsmalls2.ok │ ├── clobber.awk │ ├── clobber.ok │ ├── closebad.awk │ ├── closebad.ok │ ├── compare2.awk │ ├── compare2.ok │ ├── concat1.awk │ ├── concat1.in │ ├── concat1.ok │ ├── concat2.awk │ ├── concat2.ok │ ├── concat3.awk │ ├── concat3.ok │ ├── concat4.awk │ ├── concat4.in │ ├── concat4.ok │ ├── concat5.awk │ ├── concat5.ok │ ├── convfmt.awk │ ├── convfmt.ok │ ├── crlf.awk │ ├── crlf.ok │ ├── delarprm.awk │ ├── delarprm.ok │ ├── dfacheck2.awk │ ├── dfacheck2.in │ ├── dfacheck2.ok │ ├── dfastress.awk │ ├── dfastress.ok │ ├── divzero2.awk │ ├── divzero2.ok │ ├── dynlj.awk │ ├── dynlj.ok │ ├── elemnew1.awk │ ├── elemnew1.ok │ ├── elemnew2.awk │ ├── elemnew2.ok │ ├── eofsplit.awk │ ├── eofsplit.ok │ ├── escapebrace.awk │ ├── escapebrace.in │ ├── escapebrace.ok │ ├── exit2.awk │ ├── exit2.ok │ ├── exitval2.awk │ ├── exitval2.ok │ ├── fieldassign.awk │ ├── fieldassign.in │ ├── fieldassign.ok │ ├── fldchg.awk │ ├── fldchg.in │ ├── fldchg.ok │ ├── fldchgnf.awk │ ├── fldchgnf.in │ ├── fldchgnf.ok │ ├── fldterm.awk │ ├── fldterm.in │ ├── fldterm.ok │ ├── fmttest.awk │ ├── fmttest.ok │ ├── fnarydel.awk │ ├── fnarydel.ok │ ├── fnparydl.awk │ ├── fnparydl.ok │ ├── fordel.awk │ ├── fordel.ok │ ├── forref.awk │ ├── forref.ok │ ├── forsimp.awk │ ├── forsimp.ok │ ├── fpat8.awk │ ├── fpat8.in │ ├── fpat8.ok │ ├── fsbs.awk │ ├── fsbs.in │ ├── fsbs.ok │ ├── fscaret.awk │ ├── fscaret.in │ ├── fscaret.ok │ ├── fsfwfs.awk │ ├── fsfwfs.in │ ├── fsfwfs.ok │ ├── fsrs.awk │ ├── fsrs.in │ ├── fsrs.ok │ ├── fstabplus.awk │ ├── fstabplus.in │ ├── fstabplus.ok │ ├── funlen.awk │ ├── funlen.in │ ├── funlen.ok │ ├── funsemnl.awk │ ├── funsemnl.ok │ ├── gensub3.awk │ ├── gensub3.in │ ├── gensub3.ok │ ├── getline.awk │ ├── getline.in │ ├── getline.ok │ ├── getline3.awk │ ├── getline3.ok │ ├── getline4.awk │ ├── getline4.in │ ├── getline4.ok │ ├── getline5.awk │ ├── getline5.ok │ ├── getlnbuf.awk │ ├── getlnbuf.in │ ├── getlnbuf.ok │ ├── getlnhd.awk │ ├── getlnhd.ok │ ├── getnr2tb.awk │ ├── getnr2tb.in │ ├── getnr2tb.ok │ ├── getnr2tm.awk │ ├── getnr2tm.in │ ├── getnr2tm.ok │ ├── gsubtest.awk │ ├── gsubtest.ok │ ├── gsubtst2.awk │ ├── gsubtst2.ok │ ├── gsubtst3.awk │ ├── gsubtst3.in │ ├── gsubtst3.ok │ ├── gsubtst4.awk │ ├── gsubtst4.ok │ ├── gsubtst8.awk │ ├── gsubtst8.in │ ├── gsubtst8.ok │ ├── hex.awk │ ├── hex.ok │ ├── igncdym.awk │ ├── igncdym.in │ ├── igncdym.ok │ ├── ignrcas2.awk │ ├── ignrcas2.ok │ ├── inpref.awk │ ├── inpref.in │ ├── inpref.ok │ ├── inputred.awk │ ├── inputred.ok │ ├── intarray.awk │ ├── intarray.ok │ ├── intest.awk │ ├── intest.ok │ ├── intprec.awk │ ├── intprec.ok │ ├── iobug1.awk │ ├── iobug1.ok │ ├── lc_num1.awk │ ├── lc_num1.ok │ ├── leaddig.awk │ ├── leaddig.ok │ ├── leadnl.awk │ ├── leadnl.in │ ├── leadnl.ok │ ├── longsub.awk │ ├── longsub.in │ ├── longsub.ok │ ├── longwrds.awk │ ├── longwrds.in │ ├── longwrds.ok │ ├── manglprm.awk │ ├── manglprm.in │ ├── manglprm.ok │ ├── match4.awk │ ├── match4.ok │ ├── math.awk │ ├── math.ok │ ├── mbprintf2.awk │ ├── mbprintf2.ok │ ├── mbprintf3.awk │ ├── mbprintf3.in │ ├── mbprintf3.ok │ ├── mdim3.awk │ ├── mdim3.ok │ ├── mdim4.awk │ ├── mdim4.in │ ├── mdim4.ok │ ├── mdim5.awk │ ├── mdim5.ok │ ├── mdim7.awk │ ├── mdim7.ok │ ├── mdim8.awk │ ├── mdim8.in │ ├── mdim8.ok │ ├── membug1.awk │ ├── membug1.in │ ├── membug1.ok │ ├── minusstr.awk │ ├── minusstr.ok │ ├── mmap8k.awk │ ├── mmap8k.in │ ├── mmap8k.ok │ ├── mpfrfield.awk │ ├── mpfrfield.in │ ├── mpfrfield.ok │ ├── mpfrieee.awk │ ├── mpfrieee.ok │ ├── mpfrnegzero.awk │ ├── mpfrnegzero.ok │ ├── mpfrnegzero2.awk │ ├── mpfrnegzero2.ok │ ├── mpfrnonum.awk │ ├── mpfrnonum.in │ ├── mpfrnonum.ok │ ├── mpfrrem.awk │ ├── mpfrrem.ok │ ├── mtchi18n.awk │ ├── mtchi18n.in │ ├── mtchi18n.ok │ ├── nasty.awk │ ├── nasty.ok │ ├── nasty2.awk │ ├── nasty2.ok │ ├── negexp.awk │ ├── negexp.ok │ ├── negrange.awk │ ├── negrange.ok │ ├── nested.awk │ ├── nested.in │ ├── nested.ok │ ├── nfldstr.awk │ ├── nfldstr.in │ ├── nfldstr.ok │ ├── nfloop.awk │ ├── nfloop.ok │ ├── nfset.awk │ ├── nfset.in │ ├── nfset.ok │ ├── nlfldsep.awk │ ├── nlfldsep.in │ ├── nlfldsep.ok │ ├── nlinstr.awk │ ├── nlinstr.in │ ├── nlinstr.ok │ ├── nlstrina.awk │ ├── nlstrina.ok │ ├── noloop1.awk │ ├── noloop1.in │ ├── noloop1.ok │ ├── noloop2.awk │ ├── noloop2.in │ ├── noloop2.ok │ ├── nondec.awk │ ├── nondec.ok │ ├── nulrsend.awk │ ├── nulrsend.in │ ├── nulrsend.ok │ ├── numindex.awk │ ├── numindex.in │ ├── numindex.ok │ ├── numstr1.awk │ ├── numstr1.ok │ ├── numsubstr.awk │ ├── numsubstr.in │ ├── numsubstr.ok │ ├── octsub.awk │ ├── octsub.ok │ ├── ofmt.awk │ ├── ofmt.in │ ├── ofmt.ok │ ├── ofmta.awk │ ├── ofmta.ok │ ├── ofmtbig.awk │ ├── ofmtbig.in │ ├── ofmtbig.ok │ ├── ofmtfidl.awk │ ├── ofmtfidl.in │ ├── ofmtfidl.ok │ ├── ofmts.awk │ ├── ofmts.in │ ├── ofmts.ok │ ├── ofmtstrnum.awk │ ├── ofmtstrnum.ok │ ├── ofs1.awk │ ├── ofs1.in │ ├── ofs1.ok │ ├── onlynl.awk │ ├── onlynl.in │ ├── onlynl.ok │ ├── opasnidx.awk │ ├── opasnidx.ok │ ├── opasnslf.awk │ ├── opasnslf.ok │ ├── paramtyp.awk │ ├── paramtyp.ok │ ├── paramuninitglobal.awk │ ├── paramuninitglobal.ok │ ├── pcntplus.awk │ ├── pcntplus.ok │ ├── pipeio1.awk │ ├── pipeio1.ok │ ├── posix.awk │ ├── posix.in │ ├── posix.ok │ ├── prdupval.awk │ ├── prdupval.in │ ├── prdupval.ok │ ├── prec.awk │ ├── prec.ok │ ├── printf1.awk │ ├── printf1.ok │ ├── printfbad3.awk │ ├── printfbad3.ok │ ├── printfchar.awk │ ├── printfchar.ok │ ├── prmreuse.awk │ ├── prmreuse.ok │ ├── profile12.awk │ ├── profile12.in │ ├── profile12.ok │ ├── prt1eval.awk │ ├── prt1eval.ok │ ├── prtoeval.awk │ ├── prtoeval.ok │ ├── range1.awk │ ├── range1.in │ ├── range1.ok │ ├── rebuf.awk │ ├── rebuf.in │ ├── rebuf.ok │ ├── regeq.awk │ ├── regeq.in │ ├── regeq.ok │ ├── regexprange.awk │ ├── regexprange.ok │ ├── reginttrad.awk │ ├── reginttrad.ok │ ├── reint.awk │ ├── reint.in │ ├── reint.ok │ ├── reint2.awk │ ├── reint2.in │ ├── reint2.ok │ ├── reparse.awk │ ├── reparse.in │ ├── reparse.ok │ ├── resplit.awk │ ├── resplit.in │ ├── resplit.ok │ ├── rri1.awk │ ├── rri1.in │ ├── rri1.ok │ ├── rs.awk │ ├── rs.in │ ├── rs.ok │ ├── rsnul1nl.awk │ ├── rsnul1nl.in │ ├── rsnul1nl.ok │ ├── rsnullre.awk │ ├── rsnullre.in │ ├── rsnullre.ok │ ├── rsstart1.awk │ ├── rsstart1.in │ ├── rsstart1.ok │ ├── rstest1.awk │ ├── rstest1.ok │ ├── rstest2.awk │ ├── rstest2.ok │ ├── rstest3.awk │ ├── rstest3.ok │ ├── rstest4.awk │ ├── rstest4.ok │ ├── rstest5.awk │ ├── rstest5.ok │ ├── rstest6.awk │ ├── rstest6.in │ ├── rstest6.ok │ ├── rswhite.awk │ ├── rswhite.in │ ├── rswhite.ok │ ├── setrec0.awk │ ├── setrec0.in │ ├── setrec0.ok │ ├── setrec1.awk │ ├── setrec1.ok │ ├── shadowbuiltin.awk │ ├── shadowbuiltin.ok │ ├── sigpipe1.awk │ ├── sigpipe1.ok │ ├── sortfor2.awk │ ├── sortfor2.in │ ├── sortfor2.ok │ ├── spacere.awk │ ├── spacere.ok │ ├── splitargv.awk │ ├── splitargv.in │ ├── splitargv.ok │ ├── splitarr.awk │ ├── splitarr.ok │ ├── splitdef.awk │ ├── splitdef.ok │ ├── splitvar.awk │ ├── splitvar.in │ ├── splitvar.ok │ ├── splitwht.awk │ ├── splitwht.ok │ ├── sprintfc.awk │ ├── sprintfc.in │ ├── sprintfc.ok │ ├── strcat1.awk │ ├── strcat1.ok │ ├── strfieldnum.awk │ ├── strfieldnum.in │ ├── strfieldnum.ok │ ├── strnum1.awk │ ├── strnum1.ok │ ├── strnum2.awk │ ├── strnum2.ok │ ├── strsubscript.awk │ ├── strsubscript.ok │ ├── stupid2.awk │ ├── stupid2.ok │ ├── subamp.awk │ ├── subamp.in │ ├── subamp.ok │ ├── subi18n.awk │ ├── subi18n.ok │ ├── subsepnm.awk │ ├── subsepnm.ok │ ├── subslash.awk │ ├── subslash.ok │ ├── substr.awk │ ├── substr.ok │ ├── swaplns.awk │ ├── swaplns.in │ ├── swaplns.ok │ ├── tailrecurse.awk │ ├── tailrecurse.ok │ ├── tradanch.awk │ ├── tradanch.in │ ├── tradanch.ok │ ├── tweakfld.awk │ ├── tweakfld.in │ ├── tweakfld.ok │ ├── unicode1.awk │ ├── unicode1.ok │ ├── uparrfs.awk │ ├── uparrfs.in │ ├── uparrfs.ok │ ├── uplus.awk │ ├── uplus.ok │ ├── wideidx.awk │ ├── wideidx.in │ ├── wideidx.ok │ ├── wideidx2.awk │ ├── wideidx2.ok │ ├── widesub.awk │ ├── widesub.ok │ ├── widesub2.awk │ ├── widesub2.ok │ ├── widesub3.awk │ ├── widesub3.in │ ├── widesub3.ok │ ├── wjposer1.awk │ ├── wjposer1.in │ ├── wjposer1.ok │ ├── zero2.awk │ ├── zero2.ok │ ├── zeroe0.awk │ ├── zeroe0.ok │ ├── zeroflag.awk │ └── zeroflag.ok ├── toybox └── awk.c ├── toybox_awk_parts ├── awk1.c └── awk2.c ├── toybox_awk_test ├── awk.test └── awk.test_orig ├── wak.man └── wak.pdf /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024 Ray Gardner 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 7 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 8 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 9 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 10 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 11 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 12 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #! /bin/sh - 2 | # 3 | # configure script for wak (awk implementation) 4 | # 5 | # This script writes a Makefile for wak, allowing 6 | # a little control over 'prefix', 'CC', 'CFLAGS' 7 | 8 | # For security 9 | IFS=' 10 | ' 11 | OLDPATH="$PATH" 12 | PATH=/bin:/usr/bin 13 | export PATH 14 | 15 | version='wak configure 24.10 20241008' 16 | 17 | # Default values 18 | prefix=${prefix-/usr/local} 19 | CC=${CC-gcc} 20 | CFLAGS=${CFLAGS--O3 -funsigned-char -std=c99 -Wall -Wextra -W -Wpointer-arith -Wstrict-prototypes -D_POSIX_C_SOURCE=200809L } 21 | 22 | help() { 23 | echo "'configure' configures $version" 24 | echo 25 | echo Usage: ./configure [OPTION]... [VAR=VALUE]... 26 | echo 27 | echo 'To assign environment variables (e.g., CC, CFLAGS...), specify them as' 28 | echo VAR=VALUE, e.g. \'CC=clang\' 29 | echo 30 | echo Option defaults are shown in brackets. 31 | echo 32 | echo Configuration: 33 | echo ' -h, --help display this help and exit' 34 | echo ' -V, --version display version information and exit' 35 | echo 36 | echo Installation directory: 37 | echo ' --prefix=PREFIX install architecture-independent files in PREFIX' 38 | echo ' [/usr/local]' 39 | echo \'make install\' will install to /usr/local/bin etc. by default. 40 | echo Use e.g. \'--prefix=\$HOME\' to change this. 41 | echo 42 | echo with no options, configure these defaults: 43 | show_defaults 44 | exit 0 45 | } 46 | 47 | show_defaults() { 48 | echo prefix=${prefix-/usr/local} 49 | echo CC=${CC-gcc} 50 | echo CFLAGS=${CFLAGS--O3 -funsigned-char -std=c99 -Wall -Wextra -W -Wpointer-arith -Wstrict-prototypes -D_POSIX_C_SOURCE=200809L } 51 | } 52 | 53 | error() { 54 | echo "$@" 1>&2 55 | exit 1 56 | } 57 | 58 | check_eq_arg() { 59 | # Ensure exactly one = sign, non-empty optval 60 | if [ x${arg##*=*=} != x${arg} ] || [ x${arg##*=} = x${arg} ] || [ -z $optval ] 61 | then 62 | error 'Bad arg:' ${arg} 63 | fi 64 | } 65 | 66 | make_makefile() { 67 | sed -e "s?@prefix@?${prefix}?g" \ 68 | -e "s?@CC@?${CC}?g" \ 69 | -e "s?@CFLAGS@?${CFLAGS}?g" \ 70 | < Makefile.in > Makefile 71 | } 72 | 73 | if [ $# = 0 ] 74 | then 75 | echo 'No args; using this config (--help to show options):' 76 | show_defaults 77 | make_makefile 78 | exit 0 79 | fi 80 | 81 | while [ $# != 0 ] 82 | do 83 | arg=$1 84 | option=${arg%=*} # arg up to an = (if any) 85 | optval=${arg#*=} # arg following = (if any) 86 | if [ -z $option ] 87 | then 88 | error 'Bad arg:' $1 89 | fi 90 | case $option in 91 | '--?' | '-?' | --h | --he | --hel | --help | -h | -he | -hel | -help) 92 | help 93 | ;; 94 | --v | --ve | --ver | --vers | --versi | --versio | --version | -v | -ve | -ver | -vers | -versi | -versio | -version | -V) 95 | echo $version 96 | exit 0 97 | ;; 98 | '--prefix') 99 | check_eq_arg 100 | prefix=$optval 101 | ;; 102 | 'CC') 103 | check_eq_arg 104 | CC=$optval 105 | ;; 106 | 'CFLAGS') 107 | check_eq_arg 108 | CFLAGS=$optval 109 | ;; 110 | -*) 111 | error Bad option arg: $1 112 | ;; 113 | *) 114 | error Bad arg: $1 115 | ;; 116 | esac 117 | shift 118 | done 119 | 120 | make_makefile 121 | 122 | exit 0 123 | -------------------------------------------------------------------------------- /getline.c: -------------------------------------------------------------------------------- 1 | /* getline.c 2 | * 3 | * getdelim(), getline() - read a delimited record from stream, ersatz implementation 4 | * 5 | * For more details, see: http://pubs.opengroup.org/onlinepubs/9799919799/functions/getline.html 6 | * 7 | */ 8 | /* Public domain getdelim(), getline() 9 | * Written by Ivan Radanovic ivanrad@protonmail.com 10 | * Found at https://github.com/ivanrad/getline 11 | * 20241005 Ray Gardner raygard@gmail.com edited to include (PD non-)license 12 | */ 13 | /* 14 | This is free and unencumbered software released into the public domain. 15 | 16 | Anyone is free to copy, modify, publish, use, compile, sell, or 17 | distribute this software, either in source code form or as a compiled 18 | binary, for any purpose, commercial or non-commercial, and by any 19 | means. 20 | 21 | In jurisdictions that recognize copyright laws, the author or authors 22 | of this software dedicate any and all copyright interest in the 23 | software to the public domain. We make this dedication for the benefit 24 | of the public at large and to the detriment of our heirs and 25 | successors. We intend this dedication to be an overt act of 26 | relinquishment in perpetuity of all present and future rights to this 27 | software under copyright law. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 32 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 33 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 34 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 35 | OTHER DEALINGS IN THE SOFTWARE. 36 | 37 | For more information, please refer to 38 | */ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) { 46 | char *cur_pos, *new_lineptr; 47 | size_t new_lineptr_len; 48 | int c; 49 | 50 | if (lineptr == NULL || n == NULL || stream == NULL) { 51 | errno = EINVAL; 52 | return -1; 53 | } 54 | 55 | if (*lineptr == NULL) { 56 | *n = 128; /* init len */ 57 | if ((*lineptr = (char *)malloc(*n)) == NULL) { 58 | errno = ENOMEM; 59 | return -1; 60 | } 61 | } 62 | 63 | cur_pos = *lineptr; 64 | for (;;) { 65 | c = getc(stream); 66 | 67 | if (ferror(stream) || (c == EOF && cur_pos == *lineptr)) 68 | return -1; 69 | 70 | if (c == EOF) 71 | break; 72 | 73 | if ((*lineptr + *n - cur_pos) < 2) { 74 | if (SSIZE_MAX / 2 < *n) { 75 | #ifdef EOVERFLOW 76 | errno = EOVERFLOW; 77 | #else 78 | errno = ERANGE; /* no EOVERFLOW defined */ 79 | #endif 80 | return -1; 81 | } 82 | new_lineptr_len = *n * 2; 83 | 84 | if ((new_lineptr = (char *)realloc(*lineptr, new_lineptr_len)) == NULL) { 85 | errno = ENOMEM; 86 | return -1; 87 | } 88 | cur_pos = new_lineptr + (cur_pos - *lineptr); 89 | *lineptr = new_lineptr; 90 | *n = new_lineptr_len; 91 | } 92 | 93 | *cur_pos++ = (char)c; 94 | 95 | if (c == delim) 96 | break; 97 | } 98 | 99 | *cur_pos = '\0'; 100 | return (ssize_t)(cur_pos - *lineptr); 101 | } 102 | 103 | ssize_t getline(char **lineptr, size_t *n, FILE *stream) { 104 | return getdelim(lineptr, n, '\n', stream); 105 | } 106 | 107 | -------------------------------------------------------------------------------- /scripts/make_mono.awk: -------------------------------------------------------------------------------- 1 | FNR<6 { next } 2 | NR==6 {printf \ 3 | "// wak.c -- \"monolithic\" (one-file) awk implementation\n"\ 4 | "// Copyright 2024 Ray Gardner\n"\ 5 | "// License: 0BSD\n"\ 6 | "// vi: tabstop=2 softtabstop=2 shiftwidth=2\n"\ 7 | "\n" 8 | } 9 | #/#if MODULAR/, /#endif/ { next } 10 | /#ifndef MONO/, /#endif.*MONO/ { next } 11 | /#include "/ { next } 12 | /int trace_sw = 0/ { next } 13 | /^EXTERN/ { sub(/EXTERN/, "static") } 14 | /remove_for_monolithic/, /END_remove_for_monolithic/ { next } 15 | /EXTERN/ { next } 16 | 17 | 1 # copy remaining lines 18 | -------------------------------------------------------------------------------- /scripts/make_toybox_awk.awk: -------------------------------------------------------------------------------- 1 | BEGIN {while ((getline < "./toybox_awk_parts/awk1.c") > 0) print} 2 | END {while ((getline < "./toybox_awk_parts/awk2.c") > 0) print} 3 | /#ifndef FOR_TOYBOX/, /#endif.*TOYBOX/ {next} 4 | NR < 6 {next} 5 | 1 6 | -------------------------------------------------------------------------------- /test/gawktests/addcomma.awk: -------------------------------------------------------------------------------- 1 | # addcomma - put commas in numbers 2 | # input: a number per line 3 | # output: the input number followed by 4 | # the number with commas and two decimal places 5 | 6 | { printf("%-12s %20s\n", $0, addcomma($0)) } 7 | 8 | function addcomma(x, num) { 9 | if (x < 0) 10 | return "-" addcomma(-x) 11 | num = sprintf("%.2f", x) # num is dddddd.dd 12 | while (num ~ /[0-9][0-9][0-9][0-9]/) 13 | sub(/[0-9][0-9][0-9][,.]/, ",&", num) 14 | return num 15 | } 16 | -------------------------------------------------------------------------------- /test/gawktests/addcomma.in: -------------------------------------------------------------------------------- 1 | 0 2 | -1 3 | -12.34 4 | 12345 5 | -1234567.89 6 | -123. 7 | -123456 8 | -------------------------------------------------------------------------------- /test/gawktests/addcomma.ok: -------------------------------------------------------------------------------- 1 | 0 0.00 2 | -1 -1.00 3 | -12.34 -12.34 4 | 12345 12,345.00 5 | -1234567.89 -1,234,567.89 6 | -123. -123.00 7 | -123456 -123,456.00 8 | -------------------------------------------------------------------------------- /test/gawktests/anchgsub.awk: -------------------------------------------------------------------------------- 1 | { gsub(/^[ ]*/, "", $0) ; print } 2 | -------------------------------------------------------------------------------- /test/gawktests/anchgsub.in: -------------------------------------------------------------------------------- 1 | This is a test, this is only a test. 2 | -------------------------------------------------------------------------------- /test/gawktests/anchgsub.ok: -------------------------------------------------------------------------------- 1 | This is a test, this is only a test. 2 | -------------------------------------------------------------------------------- /test/gawktests/anchor.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | 3 | { 4 | if (/^A/) 5 | print "ok" 6 | else 7 | print "not ok" 8 | 9 | if (/B$/) 10 | print "not ok" 11 | else 12 | print "ok" 13 | 14 | if (/^C/) 15 | print "not ok" 16 | else 17 | print "ok" 18 | 19 | if (/D$/) 20 | print "not ok" 21 | else 22 | print "ok" 23 | 24 | if (/^E/) 25 | print "not ok" 26 | else 27 | print "ok" 28 | 29 | if (/F$/) 30 | print "ok" 31 | else 32 | print "not ok" 33 | } 34 | -------------------------------------------------------------------------------- /test/gawktests/anchor.in: -------------------------------------------------------------------------------- 1 | A line1 B 2 | C line2 D 3 | E line3 F 4 | -------------------------------------------------------------------------------- /test/gawktests/anchor.ok: -------------------------------------------------------------------------------- 1 | ok 2 | ok 3 | ok 4 | ok 5 | ok 6 | ok 7 | -------------------------------------------------------------------------------- /test/gawktests/arrayind1.awk: -------------------------------------------------------------------------------- 1 | # this script renums pedigrees with metafounders 2 | # so that they are added *before*regular animals 3 | # mf are ascertained because they are not in the 1st column 4 | # also ordered by generation assuming that all metafounders 5 | # start at generation 1 6 | # 7 | # 8 | function maxval (a,b) { 9 | max=b 10 | if (a>b){max=a} 11 | return max 12 | } 13 | BEGIN{ 14 | pos[0]=0 # actual position in the original data file 15 | changed=1 16 | posout[0]=0 # position in the new file 17 | last=0 18 | cum[0]=0 #number of times it acts as parent 19 | gen[0]=0 20 | } 21 | # read and store pedigree file 22 | { 23 | pos[$1]=NR 24 | dam[$1]=$2 25 | sire[$1]=$3 26 | included[$1]=0 27 | gen[$1]=9999 28 | } 29 | END{ 30 | #printf("%10s%10s\n",NR,"animals") > "/dev/stderr" 31 | # find out who is a genetic group 32 | for (x in sire){ 33 | if(! (sire[x] in pos)){ 34 | is_group[sire[x]]=1 35 | #printf("%10s%10s\n","sire",sire[x]) > "/dev/stderr" 36 | cum[sire[x],"sire"]++ 37 | } 38 | } 39 | for (x in dam){ 40 | if(! (dam[x] in pos)){ 41 | is_group[dam[x]]=1 42 | #printf("%10s%10s\n","dam",dam[x]) > "/dev/stderr" 43 | cum[dam[x],"dam"]++ 44 | } 45 | } 46 | # compute numbers, but don't write them out 47 | #printf("%16s\n","info on mf") > "/dev/stderr" 48 | for (x in is_group){ 49 | nmf++ 50 | posout[x]=posout[last]+1 51 | printf("%16s%16s%16s%16s%16s%16s%16s\n", posout[x],0,0,x,0,0,0) 52 | included[x]=1 53 | gen[x]=0 54 | last=x 55 | cumgen[0]++ 56 | #printf("%10s%16s%10s%16s%10s%10s%10s\n","group",last," included as",posout[x]," as sire, as dam",cum[x,"sire"],cum[x,"dam"]) > "/dev/stderr" 57 | } 58 | # regular individuals 59 | # printf("%16s\n","recoding animals") > "/dev/stderr" 60 | iter=1 61 | #--> comment next line and this element of the associative array becomes null 62 | #printf("%s%16s\n","at the beginning it should be empty: ",posout["00000779770060"]) > "/dev/stderr" 63 | #--> 64 | while (changed){ 65 | changed=0 66 | for (x in pos){ 67 | if(x!=0 && !included[x]){ 68 | # change to number of generation 69 | # if(included[dam[x]] && included[sire[x]]){ 70 | if((gen[dam[x]] 86 | # printf("%s%16s\n","in the loop: ",posout["00000779770060"]) > "/dev/stderr" 87 | # fflush("/dev/stderr") 88 | #--> 89 | #printf("%10s%10s%10s%10s%16s%16s\n","round",iter,"included",posout[last],"last ",last) > "/dev/stderr" 90 | } 91 | #printf("%10s%10s%10s%10s%10s%10s\n","metafounders:",nmf," animals",nanim," total",posout[last]) > "/dev/stderr" 92 | #printf("%16s%16s\n","pseudogenerations:",gen[last]) > "/dev/stderr" 93 | for (x in cumgen){ 94 | #printf("%10s%16s%10s%16s\n","pseudogeneration:",x," including: ",cumgen[x]) > "/dev/stderr" 95 | } 96 | #--> this is the guilty line 97 | # printf("%s%16s\n","at the end: ",posout["00000779770060"]) > "/dev/stderr" 98 | # fflush("/dev/stderr") 99 | #--> 100 | } 101 | -------------------------------------------------------------------------------- /test/gawktests/arrayind1.in: -------------------------------------------------------------------------------- 1 | 64000757790003 00000779770060 00000757740011 1979 2 1975 0 2 | 00000779770060 1975su1du1 1975su1du1 1975 1 1975 1975su1du1 3 | -------------------------------------------------------------------------------- /test/gawktests/arrayind1.ok: -------------------------------------------------------------------------------- 1 | 1 0 0 00000757740011 0 0 0 2 | 2 0 0 1975su1du1 0 0 0 3 | 3 2 2 00000779770060 1975su1du1 1975su1du1 1 4 | 4 3 1 64000757790003 00000779770060 00000757740011 2 5 | -------------------------------------------------------------------------------- /test/gawktests/arrayind3.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | # initialize cint arrays 3 | pos[0] = 0 4 | posout[0] = 0 5 | split("00000779770060", f) # f[1] is a strnum 6 | pos[f[1]] = 1 # subscripts must be strings! 7 | for (x in pos) { 8 | # if x is a strnum, then the 9 | # x != 0 test may convert it to an integral NUMBER, 10 | # and we might lose the unusual string representation 11 | # if the cint code is not careful to recognize that this is 12 | # actually a string 13 | if (x != 0) 14 | posout[x] = pos[x] 15 | } 16 | # which array element is populated? 17 | print posout[779770060] 18 | print posout["00000779770060"] 19 | } 20 | -------------------------------------------------------------------------------- /test/gawktests/arrayind3.ok: -------------------------------------------------------------------------------- 1 | 2 | 1 3 | -------------------------------------------------------------------------------- /test/gawktests/arrayprm2.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Wed Apr 30 11:08:48 2003 2 | # Return-Path: 3 | # Received: from localhost (skeeve [127.0.0.1]) 4 | # by skeeve.com (8.12.5/8.12.5) with ESMTP id h3U7uZWr015489 5 | # for ; Wed, 30 Apr 2003 11:08:48 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Wed, 30 Apr 2003 11:08:48 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Wed Apr 30 11:05:01 2003) 11 | # X-From_: spcecdt@armory.com Wed Apr 30 04:06:46 2003 12 | # Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id h3U16iv04111 for ; 14 | # Wed, 30 Apr 2003 04:06:45 +0300 (EET DST) 15 | # (rfc931-sender: mail.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h3U16nEv009589 18 | # for ; Wed, 30 Apr 2003 04:06:50 +0300 19 | # Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) 20 | # by f7.net (8.11.7/8.11.6) with ESMTP id h3U16gj29182 21 | # for ; Tue, 29 Apr 2003 21:06:42 -0400 22 | # Received: from monty-python.gnu.org ([199.232.76.173]) 23 | # by fencepost.gnu.org with esmtp (Exim 4.10) 24 | # id 19Ag3W-00029w-00 25 | # for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:06:42 -0400 26 | # Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) 27 | # id 19Ag1V-0001AN-00 28 | # for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:04:39 -0400 29 | # Received: from deepthought.armory.com ([192.122.209.42] helo=armory.com) 30 | # by monty-python.gnu.org with smtp (Exim 4.10.13) 31 | # id 19Ag1V-0001A3-00 32 | # for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:04:37 -0400 33 | # Date: Tue, 29 Apr 2003 18:04:35 -0700 34 | # From: "John H. DuBois III" 35 | # To: bug-gawk@gnu.org 36 | # Subject: gawk 3.1.2a bug 37 | # Message-ID: <20030430010434.GA4278@armory.com> 38 | # Mime-Version: 1.0 39 | # Content-Type: text/plain; charset=us-ascii 40 | # Content-Disposition: inline 41 | # User-Agent: Mutt/1.3.28i 42 | # X-Www: http://www.armory.com./~spcecdt/ 43 | # Sender: spcecdt@armory.com 44 | # X-Spam-Status: No, hits=-7.2 required=5.0 45 | # tests=SIGNATURE_SHORT_DENSE,SPAM_PHRASE_00_01,USER_AGENT, 46 | # USER_AGENT_MUTT 47 | # version=2.41 48 | # X-Spam-Level: 49 | # X-SpamBouncer: 1.4 (10/07/01) 50 | # X-SBClass: OK 51 | # Status: RO 52 | # 53 | # gawk-3.1.2a 'BEGIN {foo(bar)};function foo(baz){split("x",baz)}' 54 | # gawk-3.1.2a: cmd. line:1: fatal: split: second argument is not an array 55 | # 56 | # John 57 | # -- 58 | # John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ 59 | # 60 | BEGIN { 61 | foo(bar) 62 | } 63 | 64 | function foo(baz) 65 | { 66 | split("x", baz) 67 | } 68 | -------------------------------------------------------------------------------- /test/gawktests/arrayprm2.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/arrayprm2.ok -------------------------------------------------------------------------------- /test/gawktests/arrayprm3.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Fri May 2 13:24:46 2003 2 | # Return-Path: 3 | # Received: from localhost (skeeve [127.0.0.1]) 4 | # by skeeve.com (8.12.5/8.12.5) with ESMTP id h42AChum021950 5 | # for ; Fri, 2 May 2003 13:24:46 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Fri, 02 May 2003 13:24:46 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Fri May 2 13:23:37 2003) 11 | # X-From_: spcecdt@armory.com Fri May 2 00:43:51 2003 12 | # Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id h41Lhm500217 for ; 14 | # Fri, 2 May 2003 00:43:49 +0300 (EET DST) 15 | # (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h41LiGcO022817 18 | # for ; Fri, 2 May 2003 00:44:18 +0300 19 | # Received: from armory.com (deepthought.armory.com [192.122.209.42]) 20 | # by f7.net (8.11.7/8.11.6) with SMTP id h41Lhj106516 21 | # for ; Thu, 1 May 2003 17:43:46 -0400 22 | # Date: Thu, 1 May 2003 14:43:45 -0700 23 | # From: "John H. DuBois III" 24 | # To: Aharon Robbins 25 | # Subject: Re: gawk 3.1.2a bug 26 | # Message-ID: <20030501214345.GA24615@armory.com> 27 | # References: <200305011738.h41Hcg76017565@localhost.localdomain> 28 | # Mime-Version: 1.0 29 | # Content-Type: text/plain; charset=us-ascii 30 | # Content-Disposition: inline 31 | # In-Reply-To: <200305011738.h41Hcg76017565@localhost.localdomain> 32 | # User-Agent: Mutt/1.3.28i 33 | # X-Www: http://www.armory.com./~spcecdt/ 34 | # Sender: spcecdt@armory.com 35 | # X-SpamBouncer: 1.4 (10/07/01) 36 | # X-SBClass: OK 37 | # Status: RO 38 | # 39 | # On Thu, May 01, 2003 at 08:38:42PM +0300, Aharon Robbins wrote: 40 | # > > That worked, thanks. 41 | # > 42 | # > Great. Your report motivated me to find everywhere such additional 43 | # > code ought to be needed. I think I did so. --Arnold 44 | # 45 | # Here's another one (perhaps fixed by your additional work): 46 | # 47 | BEGIN { foo(a) } 48 | function foo(a) { bar(a); print "" in a } 49 | function bar(a) { a[""]; } 50 | # 51 | # Prints 1 with gawk-3.1.1; 0 with 3.1.2a. 52 | # 53 | # John 54 | # -- 55 | # John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ 56 | # 57 | -------------------------------------------------------------------------------- /test/gawktests/arrayprm3.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/arrayref.awk: -------------------------------------------------------------------------------- 1 | BEGIN { # foo[10] = 0 # put this line in and it will work 2 | test(foo); print foo[1] 3 | test2(foo2); print foo2[1] 4 | } 5 | 6 | function test(foo) 7 | { 8 | test2(foo) 9 | } 10 | function test2(bar) 11 | { 12 | bar[1] = 1 13 | } 14 | -------------------------------------------------------------------------------- /test/gawktests/arrayref.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /test/gawktests/arrymem1.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Thu Jun 14 13:24:32 2001 2 | # Received: from mail.actcom.co.il [192.114.47.13] 3 | # by localhost with POP3 (fetchmail-5.5.0) 4 | # for arnold@localhost (single-drop); Thu, 14 Jun 2001 13:24:32 +0300 (IDT) 5 | # Received: by actcom.co.il (mbox arobbins) 6 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Thu Jun 14 13:25:13 2001) 7 | # X-From_: spcecdt@armory.com Thu Jun 14 06:34:47 2001 8 | # Received: from lmail.actcom.co.il by actcom.co.il with ESMTP 9 | # (8.9.1a/actcom-0.2) id GAA29661 for ; 10 | # Thu, 14 Jun 2001 06:34:46 +0300 (EET DST) 11 | # (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) 12 | # Received: from billohost.com (www.billohost.com [209.196.35.10]) 13 | # by lmail.actcom.co.il (8.11.2/8.11.2) with ESMTP id f5E3YiO27337 14 | # for ; Thu, 14 Jun 2001 06:34:45 +0300 15 | # Received: from fencepost.gnu.org (we-refuse-to-spy-on-our-users@fencepost.gnu.org [199.232.76.164]) 16 | # by billohost.com (8.9.3/8.9.3) with ESMTP id XAA02681 17 | # for ; Wed, 13 Jun 2001 23:33:57 -0400 18 | # Received: from deepthought.armory.com ([192.122.209.42]) 19 | # by fencepost.gnu.org with smtp (Exim 3.16 #1 (Debian)) 20 | # id 15ANu2-00005C-00 21 | # for ; Wed, 13 Jun 2001 23:34:38 -0400 22 | # Date: Wed, 13 Jun 2001 20:32:42 -0700 23 | # From: "John H. DuBois III" 24 | # To: bug-gawk@gnu.org 25 | # Subject: gawk 3.1.0 bug 26 | # Message-ID: <20010613203242.A29975@armory.com> 27 | # Mime-Version: 1.0 28 | # Content-Type: text/plain; charset=us-ascii 29 | # X-Mailer: Mutt 1.0.1i 30 | # X-Www: http://www.armory.com./~spcecdt/ 31 | # Sender: spcecdt@armory.com 32 | # Status: RO 33 | # 34 | # Under SCO OpenServer 5.0.6a using gawk 3.1.0 compiled with gcc 2.95.2, this 35 | # program: 36 | 37 | BEGIN { 38 | f1(Procs,b) 39 | print "test" 40 | } 41 | 42 | function f1(Procs,a) { 43 | # a[""] 44 | a[""] = "a" # ADR: Give it a value so can trace it 45 | f2() 46 | } 47 | 48 | function f2() { 49 | # b[""] 50 | b[""] = "b" # ADR: Give it a value so can trace it 51 | } 52 | 53 | # ADR: 1/28/2003: Added this: 54 | BEGIN { for (i in b) printf("b[\"%s\"] = \"%s\"\n", i, b[i]) } 55 | # END ADR added. 56 | 57 | # gives: 58 | # 59 | # gawk: ./gtest:5: fatal error: internal error 60 | # 61 | # and dumps core. 62 | # 63 | # gdb gives me this stack backtrace: 64 | # 65 | # #0 0x80019943 in kill () from /usr/lib/libc.so.1 66 | # #1 0x8003e754 in abort () from /usr/lib/libc.so.1 67 | # #2 0x8062a87 in catchsig (sig=0, code=0) at main.c:947 68 | # #3 0x80053a0c in _sigreturn () from /usr/lib/libc.so.1 69 | # #4 0x80023d36 in cleanfree () from /usr/lib/libc.so.1 70 | # #5 0x80023156 in _real_malloc () from /usr/lib/libc.so.1 71 | # #6 0x80023019 in malloc () from /usr/lib/libc.so.1 72 | # #7 0x8053b95 in do_print (tree=0x0) at builtin.c:1336 73 | # #8 0x806b47c in interpret (tree=0x8084ee4) at eval.c:606 74 | # #9 0x806ad8d in interpret (tree=0x8084f0c) at eval.c:384 75 | # #10 0x806ad21 in interpret (tree=0x8084f5c) at eval.c:367 76 | # #11 0x8061d5b in main (argc=4, argv=0x80478ac) at main.c:506 77 | # 78 | # John 79 | # -- 80 | # John DuBois spcecdt@armory.com. KC6QKZ/AE http://www.armory.com./~spcecdt/ 81 | # 82 | -------------------------------------------------------------------------------- /test/gawktests/arrymem1.ok: -------------------------------------------------------------------------------- 1 | test 2 | b[""] = "b" 3 | -------------------------------------------------------------------------------- /test/gawktests/arynasty.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | a = 12.153 3 | #print "-- stroring test[a]" > "/dev/stderr" ; fflush("/dev/stderr") 4 | test[a] = "hi" 5 | #print "-- setting CONVFMT" > "/dev/stderr" ; fflush("/dev/stderr") 6 | CONVFMT = "%.0f" 7 | #print "-- setting a" > "/dev/stderr" ; fflush("/dev/stderr") 8 | a = 5 9 | #stopme() 10 | #print "-- starting loop" > "/dev/stderr" ; fflush("/dev/stderr") 11 | for (i in test) { 12 | #print("-- i =", i) > "/dev/stderr" ; fflush("/dev/stderr"); 13 | #printf("-- i = <%s>\n", i) > "/dev/stderr" ; fflush("/dev/stderr"); 14 | printf ("test[%s] = %s\n", i, test[i]) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/gawktests/arynasty.ok: -------------------------------------------------------------------------------- 1 | test[12.153] = hi 2 | -------------------------------------------------------------------------------- /test/gawktests/aryprm8.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | f(0, a) # nothing 3 | f(1, a) 4 | } 5 | function f(i, a) { 6 | if (i == 0) return 7 | g(a, a) 8 | pr(a) 9 | } 10 | function g(x, y) { 11 | h(y, x, y) 12 | } 13 | function h(b, c, d) { 14 | b[1] = 1 15 | c[1] = 2 # rewrite 16 | print b[1], d[1] 17 | c[2] = 1 18 | b[2] = 2 # should rewrite 19 | } 20 | function pr(x) { 21 | print x[1], x[2] 22 | } 23 | -------------------------------------------------------------------------------- /test/gawktests/aryprm8.ok: -------------------------------------------------------------------------------- 1 | 2 2 2 | 2 2 3 | -------------------------------------------------------------------------------- /test/gawktests/aryprm9.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gawk -f 2 | BEGIN { 3 | 4 | for (i = 0; i < 100; i++) 5 | func_exec() 6 | } 7 | 8 | function func_exec(opaque) 9 | { 10 | func_a(1, opaque) #set additional argument, not expected by fname 11 | } 12 | 13 | function func_a(a, b, loc1, loc2) 14 | { 15 | b = 0 #unref Nnull_string 16 | } 17 | -------------------------------------------------------------------------------- /test/gawktests/aryprm9.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/aryprm9.ok -------------------------------------------------------------------------------- /test/gawktests/arysubnm.awk: -------------------------------------------------------------------------------- 1 | BEGIN { n = 11 ; foo[n] = n; print (2 <= n) } 2 | -------------------------------------------------------------------------------- /test/gawktests/arysubnm.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/aryunasgn.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | a[i] = "null" # i is initially undefined 3 | for (i in a) { # i is null string 4 | print length(i), a[i] # , typeof(i) # 0 null 5 | print (i==0), (i=="") # 1 1 should be 0 1 6 | } 7 | print a[""] # null 8 | print a[0] # 9 | 10 | b[$2] = "null also" # $2 is also undefined 11 | for (j in b) { 12 | print length(j), a[j] # , typeof(i) # 0 null 13 | print (j==0), (j=="") # 1 1 should be 0 1 14 | } 15 | print b[""] # null 16 | print b[0] # 17 | } 18 | -------------------------------------------------------------------------------- /test/gawktests/aryunasgn.ok: -------------------------------------------------------------------------------- 1 | 0 null 2 | 0 1 3 | null 4 | 5 | 0 null 6 | 0 1 7 | null also 8 | 9 | -------------------------------------------------------------------------------- /test/gawktests/asgext.awk: -------------------------------------------------------------------------------- 1 | { print $3; $4 = "a"; print } 2 | -------------------------------------------------------------------------------- /test/gawktests/asgext.in: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | 1 3 | 1 2 3 4 4 | -------------------------------------------------------------------------------- /test/gawktests/asgext.ok: -------------------------------------------------------------------------------- 1 | 3 2 | 1 2 3 a 3 | 4 | 1 a 5 | 3 6 | 1 2 3 a 7 | -------------------------------------------------------------------------------- /test/gawktests/assignnumfield.awk: -------------------------------------------------------------------------------- 1 | {$0 = ++i} 1 2 | -------------------------------------------------------------------------------- /test/gawktests/assignnumfield.in: -------------------------------------------------------------------------------- 1 | a b c 2 | a b c 3 | a b c 4 | a b c 5 | a b c 6 | -------------------------------------------------------------------------------- /test/gawktests/assignnumfield.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | -------------------------------------------------------------------------------- /test/gawktests/assignnumfield2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | $0 = 1 3 | print $1 4 | } 5 | -------------------------------------------------------------------------------- /test/gawktests/assignnumfield2.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/backgsub.awk: -------------------------------------------------------------------------------- 1 | { 2 | gsub( "\\\\", "\\\\") 3 | print 4 | } 5 | -------------------------------------------------------------------------------- /test/gawktests/backgsub.in: -------------------------------------------------------------------------------- 1 | \x\y\z 2 | -------------------------------------------------------------------------------- /test/gawktests/backgsub.ok: -------------------------------------------------------------------------------- 1 | \\x\\y\\z 2 | -------------------------------------------------------------------------------- /test/gawktests/backsmalls2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | pat["^\\s*$"] = pat["^\\s+$"] = pat["^\\s?$"] = pat["^\\s{1}$"] = 1 3 | for (i in pat) { 4 | if (" " !~ i) { 5 | printf("pattern \"%s\" failed!\n", i) > "/dev/stderr" 6 | exit 1 7 | } 8 | } 9 | exit 0 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/backsmalls2.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/backsmalls2.ok -------------------------------------------------------------------------------- /test/gawktests/clobber.ok: -------------------------------------------------------------------------------- 1 | 000801 -------------------------------------------------------------------------------- /test/gawktests/closebad.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | f = "/no/such/file/1" 3 | print (getline junk < f) 4 | print close(f) 5 | f = "/no/such/file/2" 6 | print close(f) 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/closebad.ok: -------------------------------------------------------------------------------- 1 | -1 2 | -1 3 | -1 4 | -------------------------------------------------------------------------------- /test/gawktests/compare2.ok: -------------------------------------------------------------------------------- 1 | OK: zero strings compare equal to number zero 2 | -------------------------------------------------------------------------------- /test/gawktests/concat1.awk: -------------------------------------------------------------------------------- 1 | #From deep@cicada-semi.com Wed Jan 23 13:15:52 2002 2 | #X-From_: deep@cicada-semi.com Wed Jan 23 01:24:54 2002 3 | #From: "Mandeep Chadha" 4 | #To: 5 | #Subject: gawk version 3.1.0 will not print a ";" 6 | #Date: Tue, 22 Jan 2002 17:23:57 -0600 7 | #Message-ID: 8 | #MIME-Version: 1.0 9 | #Content-Type: text/plain; 10 | # charset="iso-8859-1" 11 | #Content-Transfer-Encoding: 7bit 12 | #X-Priority: 3 (Normal) 13 | #X-MSMail-Priority: Normal 14 | #X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) 15 | #Importance: Normal 16 | #X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 17 | # 18 | # 19 | #The file "tmp" contains the following lines: 20 | # 21 | #A 22 | #B 23 | #C 24 | #D 25 | # 26 | #and when I run the command: 27 | # 28 | # gawk '{print "Input = "$_" ; "}' tmp 29 | {print "Input = "$_" ; "} 30 | # 31 | #I get the following output: 32 | # 33 | #Input = A 34 | #Input = B 35 | #Input = C 36 | #Input = D 37 | # 38 | #while I expect the following output: 39 | # 40 | #Input = A ; 41 | #Input = B ; 42 | #Input = C ; 43 | #Input = D ; 44 | # 45 | #Running gawk --version produces the following output: 46 | # 47 | #GNU Awk 3.1.0 48 | #Copyright (C) 1989, 1991-2001 Free Software Foundation. 49 | # 50 | #This program is free software; you can redistribute it and/or modify 51 | #it under the terms of the GNU General Public License as published by 52 | #the Free Software Foundation; either version 2 of the License, or 53 | #(at your option) any later version. 54 | # 55 | #This program is distributed in the hope that it will be useful, 56 | #but WITHOUT ANY WARRANTY; without even the implied warranty of 57 | #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 58 | #GNU General Public License for more details. 59 | # 60 | #You should have received a copy of the GNU General Public License 61 | #along with this program; if not, write to the Free Software 62 | #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 63 | # 64 | #I am running this on a i686 machine that is running RedHat 7.2 (out of the box). 65 | # 66 | #Thanks, 67 | # 68 | #Mandeep Chadha 69 | # 70 | #---------------------------------------- 71 | #Mandeep Chadha 72 | #Cicada Semiconductor Corp. 73 | #811 Barton Springs Road, Suite 550 74 | #Austin, TX 78704 75 | #Ph: (512) 327-3500 x111 76 | #E-mail: deep@cicada-semi.com 77 | #URL: http://www.cicada-semi.com 78 | #---------------------------------------- 79 | -------------------------------------------------------------------------------- /test/gawktests/concat1.in: -------------------------------------------------------------------------------- 1 | A 2 | B 3 | C 4 | D 5 | -------------------------------------------------------------------------------- /test/gawktests/concat1.ok: -------------------------------------------------------------------------------- 1 | Input = A ; 2 | Input = B ; 3 | Input = C ; 4 | Input = D ; 5 | -------------------------------------------------------------------------------- /test/gawktests/concat2.awk: -------------------------------------------------------------------------------- 1 | function f(s, x) { 2 | x = 1 3 | s = 3 4 | s = s x 5 | print s 6 | } 7 | 8 | BEGIN { for (i = 1; i <=12; i++) f() } 9 | -------------------------------------------------------------------------------- /test/gawktests/concat2.ok: -------------------------------------------------------------------------------- 1 | 31 2 | 31 3 | 31 4 | 31 5 | 31 6 | 31 7 | 31 8 | 31 9 | 31 10 | 31 11 | 31 12 | 31 13 | -------------------------------------------------------------------------------- /test/gawktests/concat3.awk: -------------------------------------------------------------------------------- 1 | BEGIN { a; a = a (b "c"); print a; print b } 2 | -------------------------------------------------------------------------------- /test/gawktests/concat3.ok: -------------------------------------------------------------------------------- 1 | c 2 | 3 | -------------------------------------------------------------------------------- /test/gawktests/concat4.awk: -------------------------------------------------------------------------------- 1 | { 2 | a = $0 3 | print a 4 | print index(a,"b") 5 | getline 6 | a = a $0 7 | print a 8 | print index(a,"b") 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/concat4.in: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | -------------------------------------------------------------------------------- /test/gawktests/concat4.ok: -------------------------------------------------------------------------------- 1 | foo 2 | 0 3 | foobar 4 | 4 5 | -------------------------------------------------------------------------------- /test/gawktests/concat5.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | OFMT = "%.8g" 3 | x = 1 4 | x += .1 5 | x = (x "a") 6 | print x 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/concat5.ok: -------------------------------------------------------------------------------- 1 | 1.1a 2 | -------------------------------------------------------------------------------- /test/gawktests/convfmt.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | CONVFMT = "%2.2f" 3 | a = 123.456 4 | b = a "" # give `a' string value also 5 | printf "a = %s\n", a 6 | CONVFMT = "%.6g" 7 | printf "a = %s\n", a 8 | a += 0 # make `a' numeric only again 9 | printf "a = %s\n", a # use `a' as string 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/convfmt.ok: -------------------------------------------------------------------------------- 1 | a = 123.46 2 | a = 123.456 3 | a = 123.456 4 | -------------------------------------------------------------------------------- /test/gawktests/crlf.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print \ 3 | "hi there" 4 | print "hello \ 5 | world" 6 | if ("foo" ~ /fo\ 7 | o/) 8 | print "matches" 9 | else 10 | print "does not match!" 11 | } 12 | -------------------------------------------------------------------------------- /test/gawktests/crlf.ok: -------------------------------------------------------------------------------- 1 | hi there 2 | hello world 3 | matches 4 | -------------------------------------------------------------------------------- /test/gawktests/delarprm.awk: -------------------------------------------------------------------------------- 1 | # From dragon!unagi.cis.upenn.edu!sjanet Tue Mar 25 17:12:20 1997 2 | # Return-Path: 3 | # Received: by skeeve.atl.ga.us (/\==/\ Smail3.1.22.1 #22.1) 4 | # id ; Tue, 25 Mar 97 17:12 EST 5 | # Received: by vecnet.com (DECUS UUCP /2.0/2.0/2.0/); 6 | # Tue, 25 Mar 97 16:58:36 EDT 7 | # Received: from gnu-life.ai.mit.edu by antaries.vec.net (MX V4.2 VAX) with SMTP; 8 | # Tue, 25 Mar 1997 16:58:26 EST 9 | # Received: from linc.cis.upenn.edu by gnu-life.ai.mit.edu (8.8.5/8.6.12GNU) with 10 | # ESMTP id QAA24350 for ; Tue, 25 Mar 11 | # 1997 16:56:59 -0500 (EST) 12 | # Received: from unagi.cis.upenn.edu (UNAGI.CIS.UPENN.EDU [158.130.8.153]) by 13 | # linc.cis.upenn.edu (8.8.5/8.8.5) with ESMTP id QAA09424; Tue, 25 Mar 14 | # 1997 16:56:54 -0500 (EST) 15 | # Received: (from sjanet@localhost) by unagi.cis.upenn.edu (8.8.5/8.8.5) id 16 | # QAA03969; Tue, 25 Mar 1997 16:56:50 -0500 (EST) 17 | # Date: Tue, 25 Mar 1997 16:56:50 -0500 (EST) 18 | # From: Stan Janet 19 | # Message-ID: <199703252156.QAA03969@unagi.cis.upenn.edu> 20 | # To: bug-gnu-utils@prep.ai.mit.edu 21 | # CC: arnold@gnu.ai.mit.edu 22 | # Subject: GNU awk 3.0.2 bug: fatal error deleting local array inside function 23 | # Status: ORf 24 | # 25 | # Version: GNU Awk 3.0.2 26 | # Platforms: SunOS 4.1.1 (compiled with Sun cc) 27 | # IRIX 5.3 (compiled with SGI cc) 28 | # Problem: Deleting local array inside function causes fatal internal error (and 29 | # core dump. The error does not occur when the variable "x", unused in 30 | # the example, is removed or when the function is declared foo(x,p). 31 | # When the function is declared foo(p,x), adding a dummy line that uses 32 | # "x", e.g. "x=1" does not prevent the error. If "p" is not deleted, 33 | # there is no error. If "p[1]" is used to delete the lone element, there 34 | # is no error. 35 | # 36 | # ==== The program x.gawk ==== 37 | 38 | function foo(p,x) { 39 | p[1]="bar" 40 | delete p 41 | return 0 42 | } 43 | 44 | BEGIN { 45 | foo() 46 | } 47 | 48 | # ==== The output for "gawk -f x.gawk" (SunOS) ==== 49 | # 50 | # gawk: x.gawk:4: fatal error: internal error 51 | -------------------------------------------------------------------------------- /test/gawktests/delarprm.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/delarprm.ok -------------------------------------------------------------------------------- /test/gawktests/dfacheck2.awk: -------------------------------------------------------------------------------- 1 | /^x+x+x+x+y$/ 2 | -------------------------------------------------------------------------------- /test/gawktests/dfacheck2.in: -------------------------------------------------------------------------------- 1 | xxy 2 | xxxy 3 | xxxxy 4 | -------------------------------------------------------------------------------- /test/gawktests/dfacheck2.ok: -------------------------------------------------------------------------------- 1 | xxxxy 2 | -------------------------------------------------------------------------------- /test/gawktests/dfastress.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print "a" ~ /(^| )*(a|b)*(c|d)( |$)/ } 2 | -------------------------------------------------------------------------------- /test/gawktests/dfastress.ok: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/gawktests/divzero2.awk: -------------------------------------------------------------------------------- 1 | # This program should NOT print error division by zero. 2 | BEGIN { print "2" / "3" } 3 | -------------------------------------------------------------------------------- /test/gawktests/divzero2.ok: -------------------------------------------------------------------------------- 1 | 0.666667 2 | -------------------------------------------------------------------------------- /test/gawktests/dynlj.awk: -------------------------------------------------------------------------------- 1 | BEGIN { printf "%*sworld\n", -20, "hello" } 2 | -------------------------------------------------------------------------------- /test/gawktests/dynlj.ok: -------------------------------------------------------------------------------- 1 | hello world 2 | -------------------------------------------------------------------------------- /test/gawktests/elemnew1.awk: -------------------------------------------------------------------------------- 1 | function tailmatch(string) { 2 | length(string) 3 | } 4 | 5 | BEGIN { 6 | tailmatch(defanchors["test"]) 7 | defanchors["test"] = defanchors["test"] 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/elemnew1.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/elemnew1.ok -------------------------------------------------------------------------------- /test/gawktests/elemnew2.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gawk -f 2 | 3 | function f(x) { 4 | return x; 5 | } 6 | 7 | BEGIN { 8 | print "a[b] is " (a["b"] ? "true" : "false"); 9 | 10 | f(a["b"]); 11 | 12 | print "a[b] is " (a["b"] ? "true" : "false"); 13 | 14 | print a["b"]; 15 | } 16 | -------------------------------------------------------------------------------- /test/gawktests/elemnew2.ok: -------------------------------------------------------------------------------- 1 | a[b] is false 2 | a[b] is false 3 | 4 | -------------------------------------------------------------------------------- /test/gawktests/eofsplit.awk: -------------------------------------------------------------------------------- 1 | # Date: Sat, 30 Mar 1996 12:47:17 -0800 (PST) 2 | # From: Charles Howes 3 | # To: bug-gnu-utils@prep.ai.mit.edu, arnold@gnu.ai.mit.edu 4 | # Subject: Bug in Gawk 3.0.0, sample code: 5 | # 6 | #!/usr/local/bin/gawk -f 7 | # 8 | # Hello! This is a bug report from chowes@direct.ca 9 | # 10 | # uname -a 11 | # SunOS hostname 5.5 Generic sun4m 12 | # 13 | # Gnu Awk (gawk) 3.0, patchlevel 0: 14 | BEGIN{ 15 | FS=":" 16 | while ((getline < "/etc/passwd") > 0) { 17 | r=$3 18 | z=0 19 | n[0]=1 20 | } 21 | FS=" " 22 | } 23 | #gawk: fp.new:16: fatal error: internal error 24 | #Abort 25 | 26 | # #!/usr/local/bin/gawk -f 27 | # # Gnu Awk (gawk) 2.15, patchlevel 6 28 | # 29 | # BEGIN{ 30 | # f="/etc/passwd" 31 | # while (getline < f) n[0]=1 32 | # FS=" " 33 | # } 34 | # #gawk: /staff/chowes/bin/fp:7: fatal error: internal error 35 | # #Abort 36 | 37 | # These examples are not perfect coding style because I took a real 38 | # piece of code and tried to strip away anything that didn't make the error 39 | # message go away. 40 | # 41 | # The interesting part of the 'truss' is: 42 | # 43 | # fstat(3, 0xEFFFF278) = 0 44 | # lseek(3, 0, SEEK_SET) = 0 45 | # read(3, " r o o t : x : 0 : 1 : S".., 2291) = 2291 46 | # brk(0x00050020) = 0 47 | # brk(0x00052020) = 0 48 | # read(3, 0x0004F4B8, 2291) = 0 49 | # close(3) = 0 50 | # Incurred fault #6, FLTBOUNDS %pc = 0x0001B810 51 | # siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 52 | # Received signal #11, SIGSEGV [caught] 53 | # siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 54 | # write(2, " g a w k", 4) = 4 55 | # write(2, " : ", 2) = 2 56 | # 57 | # -- 58 | # Charles Howes -- chowes@direct.ca Voice: (604) 691-1607 59 | # System Administrator Fax: (604) 691-1605 60 | # Internet Direct - 1050 - 555 West Hastings St - Vancouver, BC V6B 4N6 61 | # 62 | # A sysadmin's life is a sorry one. The only advantage he has over Emergency 63 | # Room doctors is that malpractice suits are rare. On the other hand, ER 64 | # doctors never have to deal with patients installing new versions of their 65 | # own innards! -Michael O'Brien 66 | # 67 | # "I think I know what may have gone wrong in the original s/w. 68 | # It's a bug in the way it was written." - Vagueness**n 69 | -------------------------------------------------------------------------------- /test/gawktests/eofsplit.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/eofsplit.ok -------------------------------------------------------------------------------- /test/gawktests/escapebrace.awk: -------------------------------------------------------------------------------- 1 | /\{/ 2 | # should be no warning 3 | -------------------------------------------------------------------------------- /test/gawktests/escapebrace.in: -------------------------------------------------------------------------------- 1 | foo{bar 2 | -------------------------------------------------------------------------------- /test/gawktests/escapebrace.ok: -------------------------------------------------------------------------------- 1 | foo{bar 2 | -------------------------------------------------------------------------------- /test/gawktests/exit2.awk: -------------------------------------------------------------------------------- 1 | function _fn0() { exit } 2 | BEGIN { ARRAY[_fn0()] } 3 | -------------------------------------------------------------------------------- /test/gawktests/exit2.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/exit2.ok -------------------------------------------------------------------------------- /test/gawktests/exitval2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print "foo" | "read x ; echo $x ; exit 12" } 2 | # this should still exit 0, as pointed out by kenny mccormack in 3 | # comp.lang.awk on 2 feb 2005 4 | -------------------------------------------------------------------------------- /test/gawktests/exitval2.ok: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/gawktests/fieldassign.awk: -------------------------------------------------------------------------------- 1 | gsub(/./, "@") && $0 = $1 2 | -------------------------------------------------------------------------------- /test/gawktests/fieldassign.in: -------------------------------------------------------------------------------- 1 | abc 2 | def 3 | -------------------------------------------------------------------------------- /test/gawktests/fieldassign.ok: -------------------------------------------------------------------------------- 1 | @@@ 2 | @@@ 3 | -------------------------------------------------------------------------------- /test/gawktests/fldchg.awk: -------------------------------------------------------------------------------- 1 | { 2 | # print "0:", $0 3 | gsub("aa", "+") 4 | print "1:", $0 5 | $3 = "<" $3 ">" 6 | print "2:", $0 7 | print "2a:" "%" $1 "%" $2 "%" $3 "%" $4 "%" $5 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/fldchg.in: -------------------------------------------------------------------------------- 1 | aa aab c d e f 2 | -------------------------------------------------------------------------------- /test/gawktests/fldchg.ok: -------------------------------------------------------------------------------- 1 | 1: + +b c d e f 2 | 2: + +b d e f 3 | 2a:%+%+b%%d%e 4 | -------------------------------------------------------------------------------- /test/gawktests/fldchgnf.awk: -------------------------------------------------------------------------------- 1 | { OFS = ":"; $2 = ""; print $0; print NF } 2 | -------------------------------------------------------------------------------- /test/gawktests/fldchgnf.in: -------------------------------------------------------------------------------- 1 | a b c d 2 | -------------------------------------------------------------------------------- /test/gawktests/fldchgnf.ok: -------------------------------------------------------------------------------- 1 | a::c:d 2 | 4 3 | -------------------------------------------------------------------------------- /test/gawktests/fldterm.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | # choose a field separator that is numeric, so we can test whether 3 | # force_number properly handles unterminated numeric field strings 4 | FS = "3" 5 | } 6 | 7 | { 8 | print $1+0 9 | print $1 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/fldterm.in: -------------------------------------------------------------------------------- 1 | 5.53apple 2 | -------------------------------------------------------------------------------- /test/gawktests/fldterm.ok: -------------------------------------------------------------------------------- 1 | 5.5 2 | 5.5 3 | -------------------------------------------------------------------------------- /test/gawktests/fmttest.ok: -------------------------------------------------------------------------------- 1 | 2 | 3 | Format item: c 4 | 5 | ABC with %c : A 6 | 123 with %c : { 7 | ABC with %.15c : A 8 | 123 with %.15c : { 9 | ABC with %15c : A 10 | 123 with %15c : { 11 | ABC with %-15c : A 12 | 123 with %-15c : { 13 | 14 | 15 | Format item: d 16 | 17 | ABC with %d : 0 18 | 123 with %d : 123 19 | ABC with %.15d : 000000000000000 20 | 123 with %.15d : 000000000000123 21 | ABC with %15d : 0 22 | 123 with %15d : 123 23 | ABC with %-15d : 0 24 | 123 with %-15d : 123 25 | 26 | 27 | Format item: e 28 | 29 | ABC with %e : 0.000000e+00 30 | 123 with %e : 1.230000e+02 31 | ABC with %.25e : 0.0000000000000000000000000e+00 32 | 123 with %.25e : 1.2300000000000000000000000e+02 33 | ABC with %25e : 0.000000e+00 34 | 123 with %25e : 1.230000e+02 35 | ABC with %-25e : 0.000000e+00 36 | 123 with %-25e : 1.230000e+02 37 | 38 | 39 | Format item: f 40 | 41 | ABC with %f : 0.000000 42 | 123 with %f : 123.000000 43 | ABC with %.25f : 0.0000000000000000000000000 44 | 123 with %.25f : 123.0000000000000000000000000 45 | ABC with %25f : 0.000000 46 | 123 with %25f : 123.000000 47 | ABC with %-25f : 0.000000 48 | 123 with %-25f : 123.000000 49 | 50 | 51 | Format item: g 52 | 53 | ABC with %g : 0 54 | 123 with %g : 123 55 | ABC with %.25g : 0 56 | 123 with %.25g : 123 57 | ABC with %25g : 0 58 | 123 with %25g : 123 59 | ABC with %-25g : 0 60 | 123 with %-25g : 123 61 | 62 | 63 | Format item: o 64 | 65 | ABC with %o : 0 66 | 123 with %o : 173 67 | ABC with %.15o : 000000000000000 68 | 123 with %.15o : 000000000000173 69 | ABC with %15o : 0 70 | 123 with %15o : 173 71 | ABC with %-15o : 0 72 | 123 with %-15o : 173 73 | 74 | 75 | Format item: s 76 | 77 | ABC with %s : ABC 78 | 123 with %s : 123 79 | ABC with %.15s : ABC 80 | 123 with %.15s : 123 81 | ABC with %15s : ABC 82 | 123 with %15s : 123 83 | ABC with %-15s : ABC 84 | 123 with %-15s : 123 85 | 86 | 87 | Format item: u 88 | 89 | ABC with %u : 0 90 | 123 with %u : 123 91 | ABC with %.15u : 000000000000000 92 | 123 with %.15u : 000000000000123 93 | ABC with %15u : 0 94 | 123 with %15u : 123 95 | ABC with %-15u : 0 96 | 123 with %-15u : 123 97 | 98 | 99 | Format item: x 100 | 101 | ABC with %x : 0 102 | 123 with %x : 7b 103 | ABC with %.15x : 000000000000000 104 | 123 with %.15x : 00000000000007b 105 | ABC with %15x : 0 106 | 123 with %15x : 7b 107 | ABC with %-15x : 0 108 | 123 with %-15x : 7b 109 | 110 | 111 | Format item: X 112 | 113 | ABC with %X : 0 114 | 123 with %X : 7B 115 | ABC with %.15X : 000000000000000 116 | 123 with %.15X : 00000000000007B 117 | ABC with %15X : 0 118 | 123 with %15X : 7B 119 | ABC with %-15X : 0 120 | 123 with %-15X : 7B 121 | -------------------------------------------------------------------------------- /test/gawktests/fnarydel.awk: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/gawk -f 2 | BEGIN { 3 | process() 4 | } 5 | 6 | function process(aa,a) { 7 | delete aa 8 | } 9 | 10 | BEGIN { 11 | for (i = 1; i < 10; i++) 12 | a[i] = i; 13 | 14 | print "first loop" 15 | for (i in a) 16 | print a[i] 17 | 18 | delete a 19 | 20 | print "second loop" 21 | for (i in a) 22 | print a[i] 23 | 24 | for (i = 1; i < 10; i++) 25 | a[i] = i; 26 | 27 | print "third loop" 28 | for (i in a) 29 | print a[i] 30 | 31 | print "call func" 32 | delit(a) 33 | 34 | print "fourth loop" 35 | for (i in a) 36 | print a[i] 37 | 38 | stressit() 39 | } 40 | 41 | function delit(arr) 42 | { 43 | delete arr 44 | } 45 | 46 | function stressit( array, i) 47 | { 48 | delete array 49 | array[4] = 4 50 | array[5] = 5 51 | delete array[5] 52 | print "You should just see: 4 4" 53 | for (i in array) 54 | print i, array[i] 55 | delete array 56 | print "You should see nothing between this line" 57 | for (i in array) 58 | print i, array[i] 59 | print "And this one" 60 | } 61 | -------------------------------------------------------------------------------- /test/gawktests/fnarydel.ok: -------------------------------------------------------------------------------- 1 | first loop 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 7 9 | 8 10 | 9 11 | second loop 12 | third loop 13 | 1 14 | 2 15 | 3 16 | 4 17 | 5 18 | 6 19 | 7 20 | 8 21 | 9 22 | call func 23 | fourth loop 24 | You should just see: 4 4 25 | 4 4 26 | You should see nothing between this line 27 | And this one 28 | -------------------------------------------------------------------------------- /test/gawktests/fnparydl.awk: -------------------------------------------------------------------------------- 1 | # fnparydl.awk --- check that deleting works with arrays 2 | # that are parameters. 3 | # 4 | # Tue Jul 11 14:20:58 EDT 2000 5 | 6 | function delit(a, k) 7 | { 8 | print "BEFORE LOOP" 9 | for (k in a) { 10 | print "DELETING KEY", k 11 | delete a[k] 12 | } 13 | print "AFTER LOOP" 14 | } 15 | 16 | BEGIN { 17 | for (i = 1 ; i <= 7; i++) { 18 | q[i] = sprintf("element %d", i) 19 | x[i] = i 20 | y[i] = q[i] 21 | } 22 | # adump(q) 23 | delit(q) 24 | # for (i in q) 25 | # delete q[i] 26 | j = 0; 27 | for (i in q) 28 | j++ 29 | print j, "elements still in q[]" 30 | # adump(q) 31 | } 32 | -------------------------------------------------------------------------------- /test/gawktests/fnparydl.ok: -------------------------------------------------------------------------------- 1 | BEFORE LOOP 2 | DELETING KEY 1 3 | DELETING KEY 2 4 | DELETING KEY 3 5 | DELETING KEY 4 6 | DELETING KEY 5 7 | DELETING KEY 6 8 | DELETING KEY 7 9 | AFTER LOOP 10 | 0 elements still in q[] 11 | -------------------------------------------------------------------------------- /test/gawktests/fordel.awk: -------------------------------------------------------------------------------- 1 | #Date: Mon, 7 Jun 2004 10:40:28 -0500 2 | #From: mary1john8@earthlink.net 3 | #To: arnold@skeeve.com 4 | #Subject: gawk internal errors 5 | #Message-ID: <20040607154028.GA2457@apollo> 6 | # 7 | #Hello, 8 | # 9 | # gawk-3.1.3i internal errors: 10 | # 11 | #[1] 12 | # 13 | #$> ./gawk 'BEGIN { for (i in a) delete a; }' 14 | BEGIN { for (i in a) delete a; } 15 | #gawk: fatal error: internal error 16 | #Aborted 17 | # 18 | #------------------------------------------------------------------ 19 | #--- awkgram.y.orig 2004-06-07 09:42:14.000000000 -0500 20 | #+++ awkgram.y 2004-06-07 09:45:58.000000000 -0500 21 | #@@ -387,7 +387,7 @@ 22 | # * Check that the body is a `delete a[i]' statement, 23 | # * and that both the loop var and array names match. 24 | # */ 25 | #- if ($8 != NULL && $8->type == Node_K_delete) { 26 | #+ if ($8 != NULL && $8->type == Node_K_delete && $8->rnode != NULL) { 27 | # NODE *arr, *sub; 28 | # 29 | # assert($8->rnode->type == Node_expression_list); 30 | #------------------------------------------------------------------ 31 | # 32 | # 33 | #[2] 34 | # 35 | #$> ./gawk 'BEGIN { printf("%3$*10$.*1$s\n", 20, 10, "hello"); }' 36 | #gawk: fatal error: internal error 37 | #Aborted 38 | # 39 | #------------------------------------------------------------------ 40 | #--- builtin.c.orig 2004-06-07 10:04:20.000000000 -0500 41 | #+++ builtin.c 2004-06-07 10:06:08.000000000 -0500 42 | #@@ -780,7 +780,10 @@ 43 | # s1++; 44 | # n0--; 45 | # } 46 | #- 47 | #+ if (val >= num_args) { 48 | #+ toofew = TRUE; 49 | #+ break; 50 | #+ } 51 | # arg = the_args[val]; 52 | # } else { 53 | # parse_next_arg(); 54 | #------------------------------------------------------------------ 55 | # 56 | # 57 | # Finally, a test for the rewritten get_src_buf(): 58 | # 59 | #$> AWKBUFSIZE=2 make check 60 | # 61 | #I get 3 failed tests. Not sure this is of any interest. 62 | # 63 | # 64 | #Thanks, 65 | #John 66 | -------------------------------------------------------------------------------- /test/gawktests/fordel.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/fordel.ok -------------------------------------------------------------------------------- /test/gawktests/forref.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | names[1] = "s" 3 | names[2] = "m" 4 | for (i in names) { 5 | x[names[i]] = i 6 | print i, names[i], x[names[i]] 7 | } 8 | print x["s"] 9 | # adump(x) 10 | # adump(names) 11 | } 12 | -------------------------------------------------------------------------------- /test/gawktests/forref.ok: -------------------------------------------------------------------------------- 1 | 1 s 1 2 | 2 m 2 3 | 1 4 | -------------------------------------------------------------------------------- /test/gawktests/forsimp.awk: -------------------------------------------------------------------------------- 1 | BEGIN { for (print 9; 0;); } 2 | -------------------------------------------------------------------------------- /test/gawktests/forsimp.ok: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /test/gawktests/fpat8.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS = "" 3 | FPAT = "\\w+" 4 | } 5 | 6 | { 7 | print 8 | $2 = "-" 9 | print 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/fpat8.in: -------------------------------------------------------------------------------- 1 | a b c d 2 | -------------------------------------------------------------------------------- /test/gawktests/fpat8.ok: -------------------------------------------------------------------------------- 1 | a b c d 2 | a - c d 3 | -------------------------------------------------------------------------------- /test/gawktests/fsbs.awk: -------------------------------------------------------------------------------- 1 | BEGIN { FS = "\\" } 2 | { print $1, $2} 3 | -------------------------------------------------------------------------------- /test/gawktests/fsbs.in: -------------------------------------------------------------------------------- 1 | 1\2 2 | -------------------------------------------------------------------------------- /test/gawktests/fsbs.ok: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /test/gawktests/fscaret.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | FS="^." 3 | OFS="|" 4 | } 5 | { 6 | $1 = $1 7 | } 8 | 1 9 | -------------------------------------------------------------------------------- /test/gawktests/fscaret.in: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/gawktests/fscaret.ok: -------------------------------------------------------------------------------- 1 | |oo 2 | -------------------------------------------------------------------------------- /test/gawktests/fsfwfs.awk: -------------------------------------------------------------------------------- 1 | BEGIN{FIELDWIDTHS="6 6 6 5";OFS=",";FS=FS}{print $1,$2,$3,$4} 2 | -------------------------------------------------------------------------------- /test/gawktests/fsfwfs.in: -------------------------------------------------------------------------------- 1 | 00000113000 00000000000 2 | 00000275000 00000000000 3 | 00000321334 00000000000 4 | 00000048709 00000010000 5 | 00000117000 00000100000 6 | 00000152000 00000138000 7 | 00000000000 00000150000 8 | 00000189425 00000000000 9 | 00000146128 00000000000 10 | 00000146128 00000000000 11 | 00000146128 00000000000 12 | 00000000000 00000050000 13 | 00000000000 00000050000 14 | 00000000000 00000000000 15 | 00000158014 00000000000 16 | 00000113656 00000000000 17 | -------------------------------------------------------------------------------- /test/gawktests/fsfwfs.ok: -------------------------------------------------------------------------------- 1 | 00000113000,00000000000,, 2 | 00000275000,00000000000,, 3 | 00000321334,00000000000,, 4 | 00000048709,00000010000,, 5 | 00000117000,00000100000,, 6 | 00000152000,00000138000,, 7 | 00000000000,00000150000,, 8 | 00000189425,00000000000,, 9 | 00000146128,00000000000,, 10 | 00000146128,00000000000,, 11 | 00000146128,00000000000,, 12 | 00000000000,00000050000,, 13 | 00000000000,00000050000,, 14 | 00000000000,00000000000,, 15 | 00000158014,00000000000,, 16 | 00000113656,00000000000,, 17 | -------------------------------------------------------------------------------- /test/gawktests/fsrs.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS=""; FS="\n"; 3 | ORS=""; OFS="\n"; 4 | } 5 | { 6 | split ($2,f," ") 7 | print $0; 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/fsrs.in: -------------------------------------------------------------------------------- 1 | a b 2 | c d 3 | e f 4 | 5 | 1 2 6 | 3 4 7 | 5 6 8 | -------------------------------------------------------------------------------- /test/gawktests/fsrs.ok: -------------------------------------------------------------------------------- 1 | a b 2 | c d 3 | e f1 2 4 | 3 4 5 | 5 6 -------------------------------------------------------------------------------- /test/gawktests/fstabplus.awk: -------------------------------------------------------------------------------- 1 | BEGIN { FS = "\t+" } 2 | { print $1, $2 } 3 | -------------------------------------------------------------------------------- /test/gawktests/fstabplus.in: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /test/gawktests/fstabplus.ok: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /test/gawktests/funlen.awk: -------------------------------------------------------------------------------- 1 | # Date: Sat, 15 Mar 2008 16:21:19 +0100 2 | # From: Hermann Peifer 3 | # Subject: [Fwd: Gawk length(array) bug] 4 | # To: bug-gawk@gnu.org 5 | # Cc: Aharon Robbins 6 | # Message-id: <47DBE96F.1060406@gmx.net> 7 | # 8 | # See below. Regards, Hermann 9 | # 10 | # -------- Original Message -------- 11 | # Subject: Re: Gawk length(array) question 12 | # Date: Sat, 15 Mar 2008 08:02:03 -0500 13 | # From: Ed Morton 14 | # Newsgroups: comp.lang.awk 15 | # References: <47DBAE29.4050709@gmx.eu> 16 | # 17 | # On 3/15/2008 6:08 AM, Hermann Peifer wrote: 18 | # > Hi All, 19 | # > 20 | # > The Gawk man page says: 21 | # > > Starting with version 3.1.5, as a non-standard extension, 22 | # > > with an array argument, length() returns the number 23 | # > > of elements in the array. 24 | # > 25 | # > It looks like Gawk's length(array) extension does not work inside 26 | # > functions. Is this a bug or feature or am I missing something? See the 27 | # > example below. I am using GNU Awk 3.1.6 28 | # > 29 | # > $ cat testdata 30 | # > CD NAME 31 | # > AT Austria 32 | # > BG Bulgaria 33 | # > CH Switzerland 34 | # > DE Germany 35 | # > EE Estonia 36 | # > FR France 37 | # > GR Greece 38 | # > 39 | # > $ cat test.awk 40 | # > 41 | # Populate array 42 | NR > 1 { array[$1] = $2 } 43 | 44 | # Print array length and call function A 45 | END { print "array:",length(array) ; A(array) } 46 | 47 | function A(array_A) { print "array_A:", length(array_A) } 48 | # > 49 | # > $ gawk -f test.awk testdata 50 | # > array: 7 51 | # > gawk: test.awk:8: (FILENAME=data FNR=8) fatal: attempt to use array 52 | # > `array_A (from array)' in a scalar context 53 | # > 54 | # > BTW, there is no such error if I have asort(array_A) or asorti(array_A) 55 | # > inside the function. 56 | # > 57 | # > Hermann 58 | # 59 | # I get the same result with gawk 3.1.6 for cygwin. Obviously you can work 60 | # around 61 | # it since asort() returns the number of elements in an array just like 62 | # length() 63 | # is supposed to (or "for (i in array) lgth++" if you don't want to be 64 | # gawk-specific) but it does seem like a bug. Anyone know if there's a list of 65 | # known gawk bugs on-line somewhere? 66 | # 67 | # Ed. 68 | # 69 | # 70 | -------------------------------------------------------------------------------- /test/gawktests/funlen.in: -------------------------------------------------------------------------------- 1 | CD NAME 2 | AT Austria 3 | BG Bulgaria 4 | CH Switzerland 5 | DE Germany 6 | EE Estonia 7 | FR France 8 | GR Greece 9 | -------------------------------------------------------------------------------- /test/gawktests/funlen.ok: -------------------------------------------------------------------------------- 1 | array: 7 2 | array_A: 7 3 | -------------------------------------------------------------------------------- /test/gawktests/funsemnl.awk: -------------------------------------------------------------------------------- 1 | # make sure that ; + \n at end after function works 2 | function foo() { print "foo" } ; 3 | BEGIN { foo() } 4 | -------------------------------------------------------------------------------- /test/gawktests/funsemnl.ok: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/gawktests/gensub3.awk: -------------------------------------------------------------------------------- 1 | /apple/ { 2 | $0 = $0 3 | x = $0 4 | } 5 | 6 | END { 7 | print x 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/gensub3.in: -------------------------------------------------------------------------------- 1 | apple 2 | pear 3 | -------------------------------------------------------------------------------- /test/gawktests/gensub3.ok: -------------------------------------------------------------------------------- 1 | apple 2 | -------------------------------------------------------------------------------- /test/gawktests/getline.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | x = y = "s" 3 | a = (getline x y) 4 | print a, x 5 | a = (getline x + 1) 6 | print a, x 7 | a = (getline x - 2) 8 | print a, x 9 | 10 | cmd = "echo A" 11 | a = (cmd | getline x y) 12 | close(cmd) 13 | print a, x 14 | 15 | cmd = "echo B" 16 | a = (cmd | getline x + 1) 17 | close(cmd) 18 | print a, x 19 | 20 | cmd = "echo C" 21 | a = (cmd | getline x - 2) 22 | close(cmd) 23 | print a, x 24 | 25 | cmd = "echo D" 26 | a = cmd | getline x 27 | close(cmd) 28 | print a, x 29 | 30 | # Concatenation has higher precedence than IO. 31 | "echo " "date" | getline 32 | print 33 | } 34 | -------------------------------------------------------------------------------- /test/gawktests/getline.in: -------------------------------------------------------------------------------- 1 | A 2 | B 3 | C 4 | -------------------------------------------------------------------------------- /test/gawktests/getline.ok: -------------------------------------------------------------------------------- 1 | 1s A 2 | 2 B 3 | -1 C 4 | 1s A 5 | 2 B 6 | -1 C 7 | 1 D 8 | date 9 | -------------------------------------------------------------------------------- /test/gawktests/getline3.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | cmd = "echo 3" 3 | y = 7 4 | cmd | getline x y 5 | close(cmd) 6 | print (cmd | getline x y) 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/getline3.ok: -------------------------------------------------------------------------------- 1 | 17 2 | -------------------------------------------------------------------------------- /test/gawktests/getline4.awk: -------------------------------------------------------------------------------- 1 | END { getline $2; print} 2 | -------------------------------------------------------------------------------- /test/gawktests/getline4.in: -------------------------------------------------------------------------------- 1 | aaa bbb 2 | -------------------------------------------------------------------------------- /test/gawktests/getline4.ok: -------------------------------------------------------------------------------- 1 | aaa bbb 2 | -------------------------------------------------------------------------------- /test/gawktests/getline5.awk: -------------------------------------------------------------------------------- 1 | # Message-ID: <4F7832BD.9030709@gmx.com> 2 | # Date: Sun, 01 Apr 2012 11:49:33 +0100 3 | # From: Duncan Moore 4 | # To: "bug-gawk@gnu.org" 5 | # Subject: [bug-gawk] getline difference from gawk versions >=4.0.0 6 | # 7 | # Hi 8 | # 9 | # b.awk: 10 | # 11 | # BEGIN { 12 | # system("echo 1 > f") 13 | # while ((getline a[++c] < "f") > 0) {} 14 | # print c 15 | # } 16 | # 17 | # gawk -f b.awk 18 | # 19 | # Prior to gawk 4.0.0 this outputs: 20 | # 21 | # 1 22 | # 23 | # For 4.0.0 and 4.0.1 it outputs: 24 | # 25 | # 2 26 | # 27 | # Regards 28 | # Duncan Moore 29 | 30 | BEGIN { 31 | system("echo 1 > f") 32 | while ((getline a[++c] < "f") > 0) {} 33 | print c 34 | system("rm -f f") 35 | } 36 | -------------------------------------------------------------------------------- /test/gawktests/getline5.ok: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/gawktests/getlnbuf.awk: -------------------------------------------------------------------------------- 1 | #Date: Tue, 21 Dec 1999 16:11:07 +0100 2 | #From: Daniel Schnell 3 | #To: bug-gnu-utils@gnu.org 4 | #CC: arnold@gnu.org 5 | #Subject: BUG in gawk (version 3.0.4 linux, windows): Text mangeling in between 6 | 7 | # search for "@K@CODE" segment 8 | 9 | $0 ~ /@K@CODE/ { 10 | # get next record 11 | getline temp 12 | printf ("@K@CODE\n") 13 | printf ("%s\n",temp) 14 | } 15 | 16 | $0 !~ /@K@CODE/ { 17 | printf ("%s\n", $0) 18 | } 19 | -------------------------------------------------------------------------------- /test/gawktests/getlnhd.awk: -------------------------------------------------------------------------------- 1 | BEGIN { pipe = "cat < 0) 7 | print 8 | 9 | exit 0 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/getlnhd.ok: -------------------------------------------------------------------------------- 1 | select * from user 2 | where Name = 'O\'Donell' 3 | -------------------------------------------------------------------------------- /test/gawktests/getnr2tb.in: -------------------------------------------------------------------------------- 1 | line 1 2 | line 2 3 | line 3 4 | line 4 5 | line 5 6 | line 6 7 | -------------------------------------------------------------------------------- /test/gawktests/getnr2tb.ok: -------------------------------------------------------------------------------- 1 | 1 10 2 | 2 5 3 | 3 3.33333 4 | 4 2.5 5 | 5 2 6 | 6 1.66667 7 | -------------------------------------------------------------------------------- /test/gawktests/getnr2tm.awk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/getnr2tm.awk -------------------------------------------------------------------------------- /test/gawktests/getnr2tm.in: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /test/gawktests/getnr2tm.ok: -------------------------------------------------------------------------------- 1 | 1 lines in 1 sec: 1 lines/sec; nlines=1 2 | -------------------------------------------------------------------------------- /test/gawktests/gsubtest.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | str = "abc"; print gsub("b+", "FOO", str), str 3 | str = "abc"; print gsub("x*", "X", str), str 4 | str = "abc"; print gsub("b*", "X", str), str 5 | str = "abc"; print gsub("c", "X", str), str 6 | str = "abc"; print gsub("c+", "X", str), str 7 | str = "abc"; print gsub("x*$", "X", str), str 8 | str = "abc"; print gsub("b|$", "X", str), str 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/gsubtest.ok: -------------------------------------------------------------------------------- 1 | 1 aFOOc 2 | 4 XaXbXcX 3 | 3 XaXcX 4 | 1 abX 5 | 1 abX 6 | 1 abcX 7 | 2 aXcX 8 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst2.ok: -------------------------------------------------------------------------------- 1 | input 12345 2 | output gsub(/regex/,"x",input) 3 | 4 | regex output 5 | (^) x12345 6 | ($) 12345x 7 | (^)|($) x12345x 8 | ($)|(^) x12345x 9 | (2) 1x345 10 | (^)|2 x1x345 11 | 2|(^) x1x345 12 | ($)|2 1x345x 13 | 2|($) 1x345x 14 | (2)|(^) x1x345 15 | (^)|(2) x1x345 16 | (2)|($) 1x345x 17 | ($)|(2) 1x345x 18 | .((2)|(^)) x345 19 | .((^)|(2)) x345 20 | .((2)|($)) x34x 21 | .(($)|(2)) x34x 22 | x*((2)|(^)) x1x345 23 | x*((^)|(2)) x1x345 24 | x*((2)|($)) 1x345x 25 | x*(($)|(2)) 1x345x 26 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst3.in: -------------------------------------------------------------------------------- 1 | (^) 12345 x12345 2 | ($) 12345 12345x 3 | (^)|($) 12345 x12345x 4 | ($)|(^) 12345 x12345x 5 | 2 12345 1x345 6 | (^)|2 12345 x1x345 7 | 2|(^) 12345 x1x345 8 | ($)|2 12345 1x345x 9 | 2|($) 12345 1x345x 10 | (2)|(^) 12345 x1x345 11 | (^)|(2) 12345 x1x345 12 | (2)|($) 12345 1x345x 13 | ($)|(2) 12345 1x345x 14 | ((2)|(^)). 12345 xx45 15 | ((^)|(2)). 12345 xx45 16 | .((2)|($)) 12345 x34x 17 | .(($)|(2)) 12345 x34x 18 | (^)|6 12345 x12345 19 | 6|(^) 12345 x12345 20 | ($)|6 12345 12345x 21 | 6|($) 12345 12345x 22 | 2|6|(^) 12345 x1x345 23 | 2|(^)|6 12345 x1x345 24 | 6|2|(^) 12345 x1x345 25 | 6|(^)|2 12345 x1x345 26 | (^)|6|2 12345 x1x345 27 | (^)|2|6 12345 x1x345 28 | 2|6|($) 12345 1x345x 29 | 2|($)|6 12345 1x345x 30 | 6|2|($) 12345 1x345x 31 | 6|($)|2 12345 1x345x 32 | ($)|6|2 12345 1x345x 33 | ($)|2|6 12345 1x345x 34 | 2|4|(^) 12345 x1x3x5 35 | 2|(^)|4 12345 x1x3x5 36 | 4|2|(^) 12345 x1x3x5 37 | 4|(^)|2 12345 x1x3x5 38 | (^)|4|2 12345 x1x3x5 39 | (^)|2|4 12345 x1x3x5 40 | 2|4|($) 12345 1x3x5x 41 | 2|($)|4 12345 1x3x5x 42 | 4|2|($) 12345 1x3x5x 43 | 4|($)|2 12345 1x3x5x 44 | ($)|4|2 12345 1x3x5x 45 | ($)|2|4 12345 1x3x5x 46 | x{0}((2)|(^)) 12345 x1x345 47 | x{0}((^)|(2)) 12345 x1x345 48 | x{0}((2)|($)) 12345 1x345x 49 | x{0}(($)|(2)) 12345 1x345x 50 | x*((2)|(^)) 12345 x1x345 51 | x*((^)|(2)) 12345 x1x345 52 | x*((2)|($)) 12345 1x345x 53 | x*(($)|(2)) 12345 1x345x 54 | x{0}^ 12345 x12345 55 | x{0}$ 12345 12345x 56 | (x{0}^)|2 12345 x1x345 57 | (x{0}$)|2 12345 1x345x 58 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst4.ok: -------------------------------------------------------------------------------- 1 | input 12345 2 | output gsub(/regex/,"x",input) 3 | 4 | regex output 5 | (^) x12345 6 | ($) 12345x 7 | (^)|($) x12345x 8 | ($)|(^) x12345x 9 | (2) 1x345 10 | (^)|2 x1x345 11 | 2|(^) x1x345 12 | ($)|2 1x345x 13 | 2|($) 1x345x 14 | (2)|(^) x1x345 15 | (^)|(2) x1x345 16 | (2)|($) 1x345x 17 | ($)|(2) 1x345x 18 | .((2)|(^)) x345 19 | .((^)|(2)) x345 20 | .((2)|($)) x34x 21 | .(($)|(2)) x34x 22 | x{0}((2)|(^)) x1x345 23 | x{0}((^)|(2)) x1x345 24 | x{0}((2)|($)) 1x345x 25 | x{0}(($)|(2)) 1x345x 26 | x*((2)|(^)) x1x345 27 | x*((^)|(2)) x1x345 28 | x*((2)|($)) 1x345x 29 | x*(($)|(2)) 1x345x 30 | x{0}^ x12345 31 | x{0}$ 12345x 32 | (x{0}^)|2 x1x345 33 | (x{0}$)|2 1x345x 34 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst8.awk: -------------------------------------------------------------------------------- 1 | { 2 | OFS = " " $2 " " 3 | gsub("foo", "_", OFS) 4 | print $1, $2 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst8.in: -------------------------------------------------------------------------------- 1 | a bar b 2 | c foo d 3 | -------------------------------------------------------------------------------- /test/gawktests/gsubtst8.ok: -------------------------------------------------------------------------------- 1 | a bar bar 2 | c _ foo 3 | -------------------------------------------------------------------------------- /test/gawktests/hex.awk: -------------------------------------------------------------------------------- 1 | # Test program from Paul Eggert, eggert@cs.ucla.edu, Jan. 14, 2005 2 | 3 | BEGIN { 4 | e = "1(e)" 5 | ex = "3e2(ex)" 6 | x = "6e5(x)" 7 | 8 | print e+0, x+0 9 | print 0x 10 | print 0e+x 11 | print 0ex 12 | print 010e2 13 | print 0e9.3 14 | } 15 | 16 | # Expected results: 17 | # 1 600000 18 | # 06e5(x) 19 | # 0600001 20 | # 03e2(ex) 21 | # 1000 22 | # 00.3 23 | -------------------------------------------------------------------------------- /test/gawktests/hex.ok: -------------------------------------------------------------------------------- 1 | 1 600000 2 | 06e5(x) 3 | 0600001 4 | 03e2(ex) 5 | 1000 6 | 00.3 7 | -------------------------------------------------------------------------------- /test/gawktests/igncdym.awk: -------------------------------------------------------------------------------- 1 | #From Jeffrey.B.Woodward@Hitchcock.ORG Mon Feb 21 09:33:32 2000 2 | #Message-id: <12901034@mailbox2.Hitchcock.ORG> 3 | #Date: 20 Feb 2000 18:14:11 EST 4 | #From: Jeffrey.B.Woodward@Hitchcock.ORG (Jeffrey B. Woodward) 5 | #Subject: gawk 3.0.4 bug 6 | #To: bug-gnu-utils@gnu.org 7 | #Cc: arnold@gnu.org 8 | # 9 | #O/S: Digital UNIX 4.0D 10 | # 11 | #C Compiler: DEC C 12 | # 13 | #gawk version: 3.0.4 14 | # 15 | #Sample Program: 16 | #gawk ' 17 | BEGIN { 18 | pattern[1] = "bar" ; ignore[1] = 1 19 | pattern[2] = "foo" ; ignore[2] = 0 20 | } 21 | 22 | { 23 | for (i = 1 ; i <= 2 ; i++) { 24 | IGNORECASE = ignore[i] 25 | print match($0, pattern[i]) " " pattern[i] ":" $0 26 | } 27 | } 28 | #' << -EOF- 29 | #This is foo 30 | #This is bar 31 | #-EOF- 32 | # 33 | #Program Output: 34 | #0 bar:This is foo 35 | #0 foo:This is foo 36 | #9 bar:This is bar 37 | #9 foo:This is bar 38 | # 39 | # 40 | #**Expected** Output: 41 | #0 bar:This is foo 42 | #9 foo:This is foo 43 | #9 bar:This is bar 44 | #0 foo:This is bar 45 | # 46 | # 47 | #This problem appears to be directly related to IGNORECASE. If 48 | #IGNORECASE remains constant, the program behaves as expected; 49 | #however, switching IGNORECASE seems to causes problems - it is 50 | #almost as though the pattern stored in the variable is treated 51 | #as a constant and the regexp() is not recompiled(?) - just a 52 | #guess... 53 | # 54 | # 55 | #Thanks, 56 | #-Jeff Woodward 57 | -------------------------------------------------------------------------------- /test/gawktests/igncdym.in: -------------------------------------------------------------------------------- 1 | This is foo 2 | This is bar 3 | -------------------------------------------------------------------------------- /test/gawktests/igncdym.ok: -------------------------------------------------------------------------------- 1 | 0 bar:This is foo 2 | 9 foo:This is foo 3 | 9 bar:This is bar 4 | 0 foo:This is bar 5 | -------------------------------------------------------------------------------- /test/gawktests/ignrcas2.awk: -------------------------------------------------------------------------------- 1 | # Based on test program submitted by: 2 | # Date: Sun, 7 Sep 2003 23:11:51 +0200 3 | # From: Michael Mauch 4 | # To: bug-gawk@gnu.org 5 | # Subject: Internal error in gawk-3.1.3 with character class 6 | 7 | BEGIN { 8 | IGNORECASE = 1 9 | if ("a" ~ /[[:alnum:]]/) 10 | print "OK" 11 | else 12 | print "NOT OK" 13 | } 14 | -------------------------------------------------------------------------------- /test/gawktests/ignrcas2.ok: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /test/gawktests/inpref.awk: -------------------------------------------------------------------------------- 1 | function test(x) { 2 | print x 3 | getline 4 | print x 5 | } 6 | 7 | { 8 | test($0) 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/inpref.in: -------------------------------------------------------------------------------- 1 | hello 2 | goodbye 3 | -------------------------------------------------------------------------------- /test/gawktests/inpref.ok: -------------------------------------------------------------------------------- 1 | hello 2 | hello 3 | -------------------------------------------------------------------------------- /test/gawktests/inputred.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print getline < "file" ".txt" } 2 | -------------------------------------------------------------------------------- /test/gawktests/inputred.ok: -------------------------------------------------------------------------------- 1 | -1.txt 2 | -------------------------------------------------------------------------------- /test/gawktests/intarray.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | nf = split("5 |05|0x4|00| 5|-0x12| 011|-013|1.0|5.1e1|-5|-05|+2", f, "|") 3 | for (i = 1; i <= nf; i++) { 4 | delete g 5 | g[f[i]] 6 | for (x in g) { 7 | if (x"" != f[i]"") 8 | printf "Error in string test: [%s] != [%s]\n", x, f[i] 9 | } 10 | 11 | delete g 12 | z = f[i]+0 # trigger numeric conversion 13 | g[f[i]] 14 | for (x in g) { 15 | if (x"" != f[i]"") 16 | printf "Error in strnum test: [%s] != [%s]\n", x, f[i] 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/gawktests/intarray.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/intarray.ok -------------------------------------------------------------------------------- /test/gawktests/intest.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | bool_result = ((b = 1) in c); 3 | print bool_result, b # gawk-3.0.1 prints "0 "; should print "0 1" 4 | } 5 | -------------------------------------------------------------------------------- /test/gawktests/intest.ok: -------------------------------------------------------------------------------- 1 | 0 1 2 | -------------------------------------------------------------------------------- /test/gawktests/intprec.awk: -------------------------------------------------------------------------------- 1 | BEGIN { printf "%.10d:%.10x\n", 5, 14 } 2 | -------------------------------------------------------------------------------- /test/gawktests/intprec.ok: -------------------------------------------------------------------------------- 1 | 0000000005:000000000e 2 | -------------------------------------------------------------------------------- /test/gawktests/iobug1.awk: -------------------------------------------------------------------------------- 1 | # From arnold@f7.net Fri Nov 26 11:53:12 2004 2 | # X-Envelope-From: james@nocrew.org 3 | # X-Envelope-To: 4 | # To: bug-gawk@gnu.org 5 | # Subject: gawk 3.1.4: reproducible hang, regression from 3.1.3 6 | # From: James Troup 7 | # Date: Fri, 26 Nov 2004 03:14:05 +0000 8 | # Message-ID: <877jo9qp36.fsf@shiri.gloaming.local> 9 | # User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) 10 | # MIME-Version: 1.0 11 | # Content-Type: text/plain; charset=us-ascii 12 | # 13 | # 14 | # Hi, 15 | # 16 | # A Debian user reported[0] gawk 3.1.4 broke a (relatively) complex 17 | # program that makes extensive use of awk, called 'apt-move'. I finally 18 | # managed to reduced the problem down to a 3 line test case, enclosed 19 | # below[1]. 20 | # 21 | # I believe the problem comes from the following code, introduced in 22 | # 3.1.4: 23 | # 24 | # [io.c, line 560] 25 | # | for (rp = red_head; rp != NULL; rp = rp->next) { 26 | # | if ((rp->flag & RED_EOF) && tree->type == Node_redirect_pipein) { 27 | # | if (rp->pid != -1) 28 | # | wait_any(0); 29 | # | } 30 | # 31 | # The problem is that, if we have an existing redirect which is a simple 32 | # file redirect[b] and it's hit EOF and we try to create a new '|' 33 | # redirect[c], this new code will try to wait(2) and if there are any 34 | # other redirects which _did_ spawn a child (like [a]) the wait() will 35 | # hang indefinitely waiting for it to exit. 36 | # 37 | # Hope that makes sense :) 38 | # 39 | # -- 40 | # James 41 | # 42 | # [0] http://bugs.debian.org/263964 43 | # 44 | # [1] 45 | # ================================================================================ 46 | #!/usr/bin/gawk -f 47 | 48 | BEGIN { 49 | printf "" | "cat" # [a] 50 | getline line < "/dev/null" # [b] 51 | "true" | getline line # [c] 52 | } 53 | # ================================================================================ 54 | -------------------------------------------------------------------------------- /test/gawktests/iobug1.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/iobug1.ok -------------------------------------------------------------------------------- /test/gawktests/lc_num1.awk: -------------------------------------------------------------------------------- 1 | # Bug reported by Ulrich Drepper. 2 | # BEGIN { 3 | # printf("%'d %d\n", 1000000, 1000000) 4 | # } 5 | 6 | # April 2010: 7 | # This needs to be a smarter test so that systems without the %'d flag 8 | # don't generate a needless failure. 9 | 10 | BEGIN { 11 | s = sprintf("%'d", 1234) 12 | if (s == "1,234" || s == "1234") 13 | print "ok, or at least the quote flag isn't supported" 14 | else { 15 | command = "od -c" 16 | print("fail:", s) | command 17 | close(command) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/gawktests/lc_num1.ok: -------------------------------------------------------------------------------- 1 | ok, or at least the quote flag isn't supported 2 | -------------------------------------------------------------------------------- /test/gawktests/leaddig.awk: -------------------------------------------------------------------------------- 1 | # check that values with leading digits get converted the 2 | # right way, based on a note in comp.lang.awk. 3 | # 4 | # run with gawk -v x=2E -f leaddig.awk 5 | 6 | BEGIN { 7 | # 4/2018: Put it into the program to make generation of the 8 | # recipe automatable 9 | x = "2E" 10 | 11 | print "x =", x, (x == 2), (x == 2E0), (x == 2E), (x == 2D) 12 | } 13 | -------------------------------------------------------------------------------- /test/gawktests/leaddig.ok: -------------------------------------------------------------------------------- 1 | x = 2E 0 0 0 0 2 | -------------------------------------------------------------------------------- /test/gawktests/leadnl.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS = ""; FS = "\n" 3 | } 4 | 5 | { 6 | print "Name is: ", $1 7 | print "Address is: ", $2 8 | print "City and State are: ", $3 9 | print "" 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/leadnl.in: -------------------------------------------------------------------------------- 1 | 2 | Jane Doe 3 | 123 Main Street 4 | Anywhere, SE 12345-6789 5 | 6 | John Smith 7 | 456 Tree-lined Avenue 8 | Smallville, MW 98765-4321 9 | 10 | -------------------------------------------------------------------------------- /test/gawktests/leadnl.ok: -------------------------------------------------------------------------------- 1 | Name is: Jane Doe 2 | Address is: 123 Main Street 3 | City and State are: Anywhere, SE 12345-6789 4 | 5 | Name is: John Smith 6 | Address is: 456 Tree-lined Avenue 7 | City and State are: Smallville, MW 98765-4321 8 | 9 | -------------------------------------------------------------------------------- /test/gawktests/longsub.awk: -------------------------------------------------------------------------------- 1 | {sub( "^.*AA", "BB"); print} 2 | -------------------------------------------------------------------------------- /test/gawktests/longwrds.awk: -------------------------------------------------------------------------------- 1 | # From Gawk Manual modified by bug fix and removal of punctuation 2 | 3 | # Invoker can customize sort command if necessary. 4 | BEGIN { 5 | if (!SORT) SORT = "LC_ALL=C sort" 6 | } 7 | 8 | # Record every word which is used at least once 9 | { 10 | for (i = 1; i <= NF; i++) { 11 | tmp = tolower($i) 12 | if (0 != (pos = match(tmp, /([[:lower:]]|-)+/))) 13 | used[substr(tmp, pos, RLENGTH)] = 1 14 | } 15 | } 16 | 17 | #Find a number of distinct words longer than 10 characters 18 | END { 19 | num_long_words = 0 20 | for (x in used) 21 | if (length(x) > 10) { 22 | ++num_long_words 23 | print x | SORT 24 | } 25 | print(num_long_words, "long words") | SORT 26 | close(SORT) 27 | } 28 | -------------------------------------------------------------------------------- /test/gawktests/longwrds.ok: -------------------------------------------------------------------------------- 1 | 20 long words 2 | compatibility 3 | concatenated 4 | consistency 5 | definitions 6 | description 7 | distributing 8 | fistatements 9 | gawk-options 10 | gnu-specific 11 | identically 12 | implementation 13 | implementations 14 | information 15 | non-portable 16 | pattern-action 17 | pre-defined 18 | program-file 19 | program-text 20 | programming 21 | restrictions 22 | -------------------------------------------------------------------------------- /test/gawktests/manglprm.awk: -------------------------------------------------------------------------------- 1 | # From beebe@sunshine.math.utah.edu Thu Jul 10 00:36:16 2003 2 | # Date: Wed, 9 Jul 2003 06:42:54 -0600 (MDT) 3 | # From: "Nelson H. F. Beebe" 4 | # To: "Arnold Robbins" 5 | # Cc: beebe@math.utah.edu 6 | # X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 110 7 | # LCB, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT 8 | # 84112-0090, USA" 9 | # X-Telephone: +1 801 581 5254 10 | # X-FAX: +1 801 585 1640, +1 801 581 4148 11 | # X-URL: http://www.math.utah.edu/~beebe 12 | # Subject: gawk-3.1.3 (and earlier): reproducible core dump 13 | # X-SpamBouncer: 1.4 (10/07/01) 14 | # X-SBClass: OK 15 | # 16 | # I have a reproducible core dump in gawk-3.1.3, and recent gawk 17 | # versions. 18 | # 19 | # Consider the following test program, reduced from a much larger one: 20 | # 21 | # % cat gawk-dump.awk 22 | 23 | { process($0) } 24 | 25 | function out_debug(s) 26 | { 27 | print s 28 | } 29 | 30 | function process(s, n,parts) 31 | { 32 | out_debug("Buffer = [" protect(Buffer) "]") 33 | Buffer = Buffer s 34 | n = split(Buffer,parts,"\n") 35 | } 36 | 37 | function protect(s) 38 | { 39 | gsub("\n", "\\n", s) 40 | return (s) 41 | } 42 | -------------------------------------------------------------------------------- /test/gawktests/manglprm.in: -------------------------------------------------------------------------------- 1 | Testing 2 | -------------------------------------------------------------------------------- /test/gawktests/manglprm.ok: -------------------------------------------------------------------------------- 1 | Buffer = [] 2 | -------------------------------------------------------------------------------- /test/gawktests/match4.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print match (m, /a?/) } 2 | -------------------------------------------------------------------------------- /test/gawktests/match4.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/math.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | pi = 3.1415927 3 | printf "cos(%f) = %f\n", pi/4, cos(pi/4) 4 | printf "sin(%f) = %f\n", pi/4, sin(pi/4) 5 | e = exp(1) 6 | printf "e = %f\n", e 7 | printf "log(e) = %f\n", log(e) 8 | printf "sqrt(pi ^ 2) = %f\n", sqrt(pi ^ 2) 9 | printf "atan2(1, 1) = %f\n", atan2(1, 1) 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/math.ok: -------------------------------------------------------------------------------- 1 | cos(0.785398) = 0.707107 2 | sin(0.785398) = 0.707107 3 | e = 2.718282 4 | log(e) = 1.000000 5 | sqrt(pi ^ 2) = 3.141593 6 | atan2(1, 1) = 0.785398 7 | -------------------------------------------------------------------------------- /test/gawktests/mbprintf2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf "%c\n", 65 3 | printf "%c\n", "AA" 4 | } 5 | -------------------------------------------------------------------------------- /test/gawktests/mbprintf2.ok: -------------------------------------------------------------------------------- 1 | A 2 | A 3 | -------------------------------------------------------------------------------- /test/gawktests/mbprintf3.awk: -------------------------------------------------------------------------------- 1 | FNR == 1 { print $0; printf "%s\n", $0 } 2 | -------------------------------------------------------------------------------- /test/gawktests/mbprintf3.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/mbprintf3.in -------------------------------------------------------------------------------- /test/gawktests/mbprintf3.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/mbprintf3.ok -------------------------------------------------------------------------------- /test/gawktests/mdim3.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | inp[0] = "blah" 3 | inp[1] = "blah" 4 | inp[2] = "" 5 | inp[3] = "Summary Statistics" 6 | inp[4] = "temperature,0" 7 | inp[5] = "rain,1" 8 | 9 | for (i = 1; i <= 40; i++) { 10 | print "i =", i 11 | mode = 0 12 | nr = 0 13 | delete val 14 | for (j = 0; j < 6; j++) { 15 | x = inp[j] 16 | print "\tj =", j 17 | # if (i == 27 && j == 3) 18 | # stopme() 19 | nf = split(x,f,",") 20 | print "\tnf =", nf 21 | if (++nr > 1) { 22 | if (!nf) 23 | mode = 1 24 | else if (mode == 1) 25 | val[f[1]] = f[2] 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/gawktests/mdim5.awk: -------------------------------------------------------------------------------- 1 | function add_flags(old) { 2 | if (old) 3 | return 0 4 | if (!old) 5 | return 1 6 | } 7 | BEGIN { 8 | a[0]=add_flags(a[0]) 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/mdim5.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/mdim5.ok -------------------------------------------------------------------------------- /test/gawktests/mdim7.awk: -------------------------------------------------------------------------------- 1 | function foo(x) 2 | { 3 | if (x == int(x)) 4 | return (int(x) != 0) 5 | } 6 | BEGIN { 7 | foo(P["bar"]) 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/mdim7.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/mdim7.ok -------------------------------------------------------------------------------- /test/gawktests/membug1.awk: -------------------------------------------------------------------------------- 1 | { one != one = $1 } 2 | -------------------------------------------------------------------------------- /test/gawktests/membug1.in: -------------------------------------------------------------------------------- 1 | yes 2 | yes 3 | -------------------------------------------------------------------------------- /test/gawktests/membug1.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/membug1.ok -------------------------------------------------------------------------------- /test/gawktests/minusstr.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print-"6" } 2 | -------------------------------------------------------------------------------- /test/gawktests/minusstr.ok: -------------------------------------------------------------------------------- 1 | -6 2 | -------------------------------------------------------------------------------- /test/gawktests/mmap8k.awk: -------------------------------------------------------------------------------- 1 | { print } 2 | -------------------------------------------------------------------------------- /test/gawktests/mpfrfield.awk: -------------------------------------------------------------------------------- 1 | #! /bin/gawk -Mf 2 | 3 | NR == 1 { 4 | min = $1 5 | } 6 | 7 | { 8 | if ($1 < min) 9 | min = $1 10 | } 11 | 12 | END { 13 | print "min", min 14 | } 15 | -------------------------------------------------------------------------------- /test/gawktests/mpfrfield.in: -------------------------------------------------------------------------------- 1 | 7 2 | 9 3 | 1 4 | 3 5 | 9 6 | 1 7 | 9 8 | 5 9 | 0 10 | 8 11 | -------------------------------------------------------------------------------- /test/gawktests/mpfrfield.ok: -------------------------------------------------------------------------------- 1 | min 0 2 | -------------------------------------------------------------------------------- /test/gawktests/mpfrieee.awk: -------------------------------------------------------------------------------- 1 | # Test IEEE-754 binary double format 2 | BEGIN { 3 | x = 1.0e-320 4 | i = 0 5 | while (x > 0) { 6 | printf("%.15e\n", x) 7 | x /= 2 8 | 9 | # terminate early when the test is going to fail. 10 | if (++i > 50) 11 | break 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/gawktests/mpfrieee.ok: -------------------------------------------------------------------------------- 1 | 9.999888671826830e-321 2 | 4.999944335913415e-321 3 | 2.499972167956708e-321 4 | 1.249986083978354e-321 5 | 6.225227137599706e-322 6 | 3.112613568799853e-322 7 | 1.581010066691989e-322 8 | 7.905050333459945e-323 9 | 3.952525166729972e-323 10 | 1.976262583364986e-323 11 | 9.881312916824931e-324 12 | 4.940656458412465e-324 13 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnegzero.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf("-0 -> %f, -0.0 -> %f\n", -0, -0.0) 3 | 4 | printf("atan2(+0, -0) = %f\n", atan2(+0, -0)) 5 | printf("atan2(+0.0, -0.0) = %f\n", atan2(+0.0, -0.0)) 6 | 7 | printf("atan2(-0, -0) = %f\n", atan2(-0, -0)) 8 | printf("atan2(-0.0, -0.0) = %f\n", atan2(-0.0, -0.0)) 9 | 10 | printf("atan2(+0, +0) = %f\n", atan2(+0, +0)) 11 | printf("atan2(+0.0, +0.0) = %f\n", atan2(+0.0, +0.0)) 12 | 13 | printf("atan2(-0, +0) = %f\n", atan2(-0, +0)) 14 | printf("atan2(-0.0, +0.0) = %f\n", atan2(-0.0, +0.0)) 15 | } 16 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnegzero.ok: -------------------------------------------------------------------------------- 1 | -0 -> -0.000000, -0.0 -> -0.000000 2 | atan2(+0, -0) = 3.141593 3 | atan2(+0.0, -0.0) = 3.141593 4 | atan2(-0, -0) = -3.141593 5 | atan2(-0.0, -0.0) = -3.141593 6 | atan2(+0, +0) = 0.000000 7 | atan2(+0.0, +0.0) = 0.000000 8 | atan2(-0, +0) = -0.000000 9 | atan2(-0.0, +0.0) = -0.000000 10 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnegzero2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf("%f\n", -a) 3 | } 4 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnegzero2.ok: -------------------------------------------------------------------------------- 1 | -0.000000 2 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnonum.awk: -------------------------------------------------------------------------------- 1 | { if ($1) print "must print " $1 } 2 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnonum.in: -------------------------------------------------------------------------------- 1 | + 2 | - 3 | 1 4 | -------------------------------------------------------------------------------- /test/gawktests/mpfrnonum.ok: -------------------------------------------------------------------------------- 1 | must print + 2 | must print - 3 | must print 1 4 | -------------------------------------------------------------------------------- /test/gawktests/mpfrrem.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print "15 % 7 =", 15 % 7 3 | print "15 % -7 =", 15 % -7 4 | print "-15 % 7 =", -15 % 7 5 | print "-15 % -7 =", -15 % -7 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/mpfrrem.ok: -------------------------------------------------------------------------------- 1 | 15 % 7 = 1 2 | 15 % -7 = 1 3 | -15 % 7 = -1 4 | -15 % -7 = -1 5 | -------------------------------------------------------------------------------- /test/gawktests/mtchi18n.awk: -------------------------------------------------------------------------------- 1 | {print match(""," *")} 2 | -------------------------------------------------------------------------------- /test/gawktests/mtchi18n.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /test/gawktests/mtchi18n.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /test/gawktests/nasty.awk: -------------------------------------------------------------------------------- 1 | #From hankedr@manatee.dms.auburn.edu Tue Oct 13 22:15:59 1998 2 | #Return-Path: 3 | #Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1]) 4 | # by dmx.netvision.net.il (8.9.0.Beta5/8.8.6) with ESMTP id PAA03924 5 | # for ; Tue, 13 Oct 1998 15:32:13 +0200 (IST) 6 | #Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@mescaline.gnu.org [158.121.106.21]) by cssun.mathcs.emory.edu (8.7.5/8.6.9-940818.01cssun) with ESMTP id KAA11644 for ; Tue, 13 Oct 1998 10:22:32 -0400 (EDT) 7 | #Received: from manatee.dms.auburn.edu (manatee.dms.auburn.edu [131.204.53.104]) 8 | # by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id KAA03250 9 | # for ; Tue, 13 Oct 1998 10:25:32 -0400 10 | #Received: (from hankedr@localhost) 11 | # by manatee.dms.auburn.edu (8.9.1a/8.9.1) id JAA13348; 12 | # Tue, 13 Oct 1998 09:22:29 -0500 (CDT) 13 | #Date: Tue, 13 Oct 1998 09:22:29 -0500 (CDT) 14 | #Message-Id: <199810131422.JAA13348@manatee.dms.auburn.edu> 15 | #From: Darrel Hankerson 16 | #To: arnold@gnu.org 17 | #In-reply-to: <199810131313.QAA31784@alpha.netvision.net.il> (message from 18 | # Aharon Robbins on Tue, 13 Oct 1998 16:10:36 +0200) 19 | #Subject: Re: full text of bug report? 20 | #Mime-Version: 1.0 21 | #Content-Type: text/plain; charset=US-ASCII 22 | #X-UIDL: bf3fce492dad4ab030c561e7b2f27d0a 23 | #Status: RO 24 | # 25 | # Do you have the full text of the a = a "\n" f() bug report? 26 | # I can't find it.... I'm not sure there really is a bug. 27 | # 28 | #Yes, see below. 29 | # 30 | #His example has unnecessary fragments (in particular, the use of 31 | #gensub is irrelevant). As I wrote to you earlier, the interesting 32 | #question for me is: 33 | # 34 | # Is the concatenation result undefined? If the result is defined or 35 | # implementation-dependent, then gawk has a bug. 36 | # 37 | # 38 | #=== Original report ===================================================== 39 | #From: Attila Torcsvari 40 | #To: "'bug-gnu-utils@prep.ai.mit.edu'" 41 | #Subject: gawk 3.0.3 bug 42 | #Date: Thu, 17 Sep 1998 18:12:13 +0200 43 | #MIME-Version: 1.0 44 | #Content-Transfer-Encoding: 7bit 45 | #Resent-From: bug-gnu-utils@gnu.org 46 | #X-Mailing-List: archive/latest/3396 47 | #X-Loop: bug-gnu-utils@gnu.org 48 | #Precedence: list 49 | #Resent-Sender: bug-gnu-utils-request@gnu.org 50 | #Content-Transfer-Encoding: 7bit 51 | #Content-Type: text/plain; charset="us-ascii" 52 | #Content-Length: 618 53 | # 54 | #Bug-gnuers, 55 | #please pass it to the responsible. 56 | # 57 | #The following generates something interesting: 58 | # 59 | BEGIN{ 60 | a="aaaaa" 61 | a=a a #10 62 | a=a a #20 63 | a=a a #40 64 | a=a a #80 65 | a=a a #160 66 | a=a a # i.e. a is long enough 67 | 68 | a=a"\n"f() # this causes the trouble 69 | print a # guess the result 70 | } 71 | 72 | function f() 73 | { 74 | #print "a before: ", a 75 | #a=gensub("a","123,","g",a) # 'a' will be just a bit longer (4 times, but still should fit: 4*160=640) 76 | gsub(/a/, "123", a) 77 | #print "a after: ", a 78 | return "X" 79 | } 80 | # 81 | #Possible reason: 82 | #during f the a is modified, 83 | #it can be even freed, because gensub modifies its size 84 | #the printout contains trash. 85 | # 86 | #Used version: VC compiled WinNT 32 bit Intel. 87 | # 88 | #Regards, 89 | # 90 | #Attila Torcsvari 91 | #Arcanum Development 92 | # 93 | -------------------------------------------------------------------------------- /test/gawktests/nasty.ok: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2 | X 3 | -------------------------------------------------------------------------------- /test/gawktests/nasty2.awk: -------------------------------------------------------------------------------- 1 | # Based on nasty.awk, test same thing for printf 2 | # 3 | BEGIN { 4 | a="aaaaa" 5 | a=a a #10 6 | a=a a #20 7 | a=a a #40 8 | a=a a #80 9 | a=a a #160 10 | a=a a # i.e. a is long enough 11 | 12 | printf("a = %s, f() = %s\n", a, f()) 13 | print a 14 | } 15 | 16 | function f() 17 | { 18 | gsub(/a/, "123", a) 19 | return "X" 20 | } 21 | -------------------------------------------------------------------------------- /test/gawktests/nasty2.ok: -------------------------------------------------------------------------------- 1 | a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, f() = X 2 | 123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123 3 | -------------------------------------------------------------------------------- /test/gawktests/negexp.awk: -------------------------------------------------------------------------------- 1 | BEGIN { a = -2; print 10^a } 2 | -------------------------------------------------------------------------------- /test/gawktests/negexp.ok: -------------------------------------------------------------------------------- 1 | 0.01 2 | -------------------------------------------------------------------------------- /test/gawktests/negrange.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | s = "Volume 8, Numbers 1-2 / January 1971" 3 | n = split(s, parts, "[^-A-Za-z0-9]+") 4 | print "n =", n 5 | for (i = 1; i <= n; i++) 6 | printf("s[%d] = \"%s\"\n", i, parts[i]) 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/negrange.ok: -------------------------------------------------------------------------------- 1 | n = 6 2 | s[1] = "Volume" 3 | s[2] = "8" 4 | s[3] = "Numbers" 5 | s[4] = "1-2" 6 | s[5] = "January" 7 | s[6] = "1971" 8 | -------------------------------------------------------------------------------- /test/gawktests/nested.in: -------------------------------------------------------------------------------- 1 | a_b 2 | -------------------------------------------------------------------------------- /test/gawktests/nested.ok: -------------------------------------------------------------------------------- 1 | a 2 | a 3 | -------------------------------------------------------------------------------- /test/gawktests/nfldstr.awk: -------------------------------------------------------------------------------- 1 | $1 == 0 { 2 | print "bug" 3 | } 4 | { 5 | $0 = "0" 6 | if (!$0) 7 | print "another bug" 8 | $0 = a = "0" 9 | if (!$0) 10 | print "yet another bug" 11 | if ($1) 12 | print "a buggie" 13 | } 14 | -------------------------------------------------------------------------------- /test/gawktests/nfldstr.in: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/gawktests/nfldstr.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/nfldstr.ok -------------------------------------------------------------------------------- /test/gawktests/nfloop.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | $0 = "aaa" 3 | NF = 10 4 | for (j = 2; j <= NF; ++j) { 5 | $j = "_" 6 | } 7 | print 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/nfloop.ok: -------------------------------------------------------------------------------- 1 | aaa _ _ _ _ _ _ _ _ _ 2 | -------------------------------------------------------------------------------- /test/gawktests/nfset.awk: -------------------------------------------------------------------------------- 1 | { NF = 5 ; print } 2 | -------------------------------------------------------------------------------- /test/gawktests/nfset.in: -------------------------------------------------------------------------------- 1 | 1 2 2 | 1 2 3 4 3 | 1 2 3 4 5 4 | 1 2 3 4 5 6 7 8 5 | 1 6 | -------------------------------------------------------------------------------- /test/gawktests/nfset.ok: -------------------------------------------------------------------------------- 1 | 1 2 2 | 1 2 3 4 3 | 1 2 3 4 5 4 | 1 2 3 4 5 5 | 1 6 | -------------------------------------------------------------------------------- /test/gawktests/nlfldsep.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "A" } 2 | {print NF; for (i = 1; i <= NF; i++) print $i ; print ""} 3 | -------------------------------------------------------------------------------- /test/gawktests/nlfldsep.in: -------------------------------------------------------------------------------- 1 | some stuff 2 | more stuffA 3 | junk 4 | stuffA 5 | final 6 | -------------------------------------------------------------------------------- /test/gawktests/nlfldsep.ok: -------------------------------------------------------------------------------- 1 | 4 2 | some 3 | stuff 4 | more 5 | stuff 6 | 7 | 2 8 | junk 9 | stuff 10 | 11 | 1 12 | final 13 | 14 | -------------------------------------------------------------------------------- /test/gawktests/nlinstr.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | 3 | { 4 | if (/^@/) 5 | print "not ok" 6 | else 7 | print "ok" 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/nlinstr.in: -------------------------------------------------------------------------------- 1 | line 1 2 | @line 2 3 | -------------------------------------------------------------------------------- /test/gawktests/nlinstr.ok: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/gawktests/nlstrina.awk: -------------------------------------------------------------------------------- 1 | # From E.Ab@chem.rug.nl Wed Aug 2 13:16:53 2000 2 | # Received: from mail.actcom.co.il 3 | # by localhost with POP3 (fetchmail-5.1.2) 4 | # for arnold@localhost (single-drop); Wed, 02 Aug 2000 13:16:53 -0400 (EDT) 5 | # Received: from lmail.actcom.co.il by actcom.co.il with ESMTP 6 | # (8.9.1a/actcom-0.2) id MAA21699 for ; 7 | # Wed, 2 Aug 2000 12:20:38 +0300 (EET DST) 8 | # (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) 9 | # Received: from freefriends.org (freefriends.org [63.85.55.109]) 10 | # by lmail.actcom.co.il (8.9.3/8.9.1) with ESMTP id LAA22723 11 | # for ; Wed, 2 Aug 2000 11:23:22 +0300 12 | # Received: from mescaline.gnu.org (mescaline.gnu.org [158.121.106.21]) 13 | # by freefriends.org (8.9.3/8.9.3) with ESMTP id FAA23582 14 | # for ; Wed, 2 Aug 2000 05:18:59 -0400 15 | # Received: from dep.chem.rug.nl (dep.chem.rug.nl [129.125.7.81]) 16 | # by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id FAA30670; 17 | # Wed, 2 Aug 2000 05:20:24 -0400 18 | # Received: from rugmd34.chem.rug.nl (rugmd34.chem.rug.nl [129.125.42.34]) 19 | # by dep.chem.rug.nl (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id LAA17089; 20 | # Wed, 2 Aug 2000 11:20:23 +0200 21 | # Received: from chem.rug.nl (localhost [127.0.0.1]) by rugmd34.chem.rug.nl (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id LAA25392; Wed, 2 Aug 2000 11:20:22 +0200 (MDT) 22 | # Sender: E.Ab@chem.rug.nl 23 | # Message-ID: <3987E7D5.2BDC5FD3@chem.rug.nl> 24 | # Date: Wed, 02 Aug 2000 11:20:21 +0200 25 | # From: Eiso AB 26 | # X-Mailer: Mozilla 4.72C-SGI [en] (X11; I; IRIX 6.5 IP32) 27 | # X-Accept-Language: en 28 | # MIME-Version: 1.0 29 | # To: bug-gnu-utils@gnu.org, arnold@gnu.org 30 | # Subject: bug? [GNU Awk 3.0.5] 31 | # 32 | # Content-Type: text/plain; charset=us-ascii 33 | # Content-Transfer-Encoding: 7bit 34 | # X-UIDL: \f8"!(8G!!ZL$#!h>X!! 35 | # Status: R 36 | # 37 | # hi Arnold, 38 | # 39 | # 40 | # Please try the script beneath... 41 | # I'm not sure if this is a bug or not, but I would expect 42 | # the empty string as an array index just to be treated 43 | # like any other string 44 | # 45 | # so if ("" in ta) would be true, and for ( i in ta ) should loop only once. 46 | # 47 | BEGIN { 48 | v="" 49 | ta[v]++ 50 | if ( v in ta) print "a",v,++ta[v],ta[v] 51 | print "b",v,++ta[v],ta[v] 52 | for( i in ta) print "c",++c,i,ta[i] 53 | } 54 | # 55 | # goodluck, Eiso 56 | # 57 | # -- 58 | # _________ 59 | # _______________________________/ Eiso AB \_________________________ 60 | # 61 | # o 62 | # 63 | # o Dept. of Biochemistry 64 | # University of Groningen 65 | # The Netherlands 66 | # o 67 | # . . 68 | # o ^ mailto:eiso@chem.rug.nl 69 | # | - _ mailto:eiso@dds.nl 70 | # \__|__/ http://md.chem.rug.nl/~eiso 71 | # | tel 4326 72 | # | 73 | # / \ 74 | # / \ 75 | # | | 76 | # ________ ._| |_. ________________________________________________ 77 | # 78 | -------------------------------------------------------------------------------- /test/gawktests/nlstrina.ok: -------------------------------------------------------------------------------- 1 | a 2 2 2 | b 3 3 3 | c 1 3 4 | -------------------------------------------------------------------------------- /test/gawktests/noloop1.awk: -------------------------------------------------------------------------------- 1 | # From jhart@avcnet.bates.edu Sun Oct 6 16:05:21 2002 2 | # Return-Path: 3 | # Received: from localhost (skeeve [127.0.0.1]) 4 | # by skeeve.com (8.11.6/8.11.6) with ESMTP id g96D5Jf28053 5 | # for ; Sun, 6 Oct 2002 16:05:21 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Sun, 06 Oct 2002 16:05:21 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Sun Oct 6 16:06:39 2002) 11 | # X-From_: jhart@avcnet.bates.edu Sun Oct 6 15:31:59 2002 12 | # Received: from lmail.actcom.co.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id g96CVrS27315 for ; 14 | # Sun, 6 Oct 2002 15:31:54 +0300 (EET DST) 15 | # (rfc931-sender: mail.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g96CVqY01629 18 | # for ; Sun, 6 Oct 2002 15:31:52 +0300 19 | # Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) 20 | # by f7.net (8.11.6/8.11.6) with ESMTP id g96CVp418974 21 | # for ; Sun, 6 Oct 2002 08:31:51 -0400 22 | # Received: from monty-python.gnu.org ([199.232.76.173]) 23 | # by fencepost.gnu.org with esmtp (Exim 4.10) 24 | # id 17yAZa-00055o-00 25 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:50 -0400 26 | # Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) 27 | # id 17yAZE-0007eB-00 28 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:29 -0400 29 | # Received: from avcnet.bates.edu ([134.181.128.62]) 30 | # by monty-python.gnu.org with esmtp (Exim 4.10) 31 | # id 17yAZ9-0007X3-00 32 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:23 -0400 33 | # Received: from a5514a.bates.edu (www.bates.edu [134.181.128.62]) 34 | # by avcnet.bates.edu (8.9.3/8.9.3) with ESMTP id IAA05400 35 | # for ; Sun, 6 Oct 2002 08:31:20 -0400 36 | # Date: Sun, 6 Oct 2002 08:36:54 -0400 37 | # Mime-Version: 1.0 (Apple Message framework v482) 38 | # Content-Type: text/plain; charset=US-ASCII; format=flowed 39 | # Subject: Infinite loop in sub/gsub 40 | # From: jhart@avcnet.bates.edu 41 | # To: bug-gawk@gnu.org 42 | # Content-Transfer-Encoding: 7bit 43 | # Message-Id: <4BC4A4F0-D928-11D6-8E78-00039384A9CC@mail.avcnet.org> 44 | # X-Mailer: Apple Mail (2.482) 45 | # X-Spam-Status: No, hits=0.3 required=5.0 46 | # tests=NO_REAL_NAME,SPAM_PHRASE_00_01,USER_AGENT_APPLEMAIL 47 | # version=2.41 48 | # X-Spam-Level: 49 | # X-SpamBouncer: 1.4 (10/07/01) 50 | # X-SBClass: OK 51 | # Status: RO 52 | # 53 | # This command line: 54 | # 55 | # echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk 56 | # 57 | # where test.awk contains this instruction: 58 | # 59 | /''/ { sub(/''(.?[^']+)*''/, "&"); } 60 | # 61 | # puts gawk 3.11 into an infinite loop. Whereas, this command works: 62 | # 63 | # echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk 64 | # 65 | # 66 | # 67 | # Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 68 | # PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC 69 | # 70 | # 71 | -------------------------------------------------------------------------------- /test/gawktests/noloop1.in: -------------------------------------------------------------------------------- 1 | ''Italics with an apostrophe'' embedded'' 2 | -------------------------------------------------------------------------------- /test/gawktests/noloop1.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/noloop1.ok -------------------------------------------------------------------------------- /test/gawktests/noloop2.awk: -------------------------------------------------------------------------------- 1 | # From jhart@avcnet.bates.edu Sun Oct 6 16:05:21 2002 2 | # Return-Path: 3 | # Received: from localhost (skeeve [127.0.0.1]) 4 | # by skeeve.com (8.11.6/8.11.6) with ESMTP id g96D5Jf28053 5 | # for ; Sun, 6 Oct 2002 16:05:21 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Sun, 06 Oct 2002 16:05:21 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Sun Oct 6 16:06:39 2002) 11 | # X-From_: jhart@avcnet.bates.edu Sun Oct 6 15:31:59 2002 12 | # Received: from lmail.actcom.co.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id g96CVrS27315 for ; 14 | # Sun, 6 Oct 2002 15:31:54 +0300 (EET DST) 15 | # (rfc931-sender: mail.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g96CVqY01629 18 | # for ; Sun, 6 Oct 2002 15:31:52 +0300 19 | # Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) 20 | # by f7.net (8.11.6/8.11.6) with ESMTP id g96CVp418974 21 | # for ; Sun, 6 Oct 2002 08:31:51 -0400 22 | # Received: from monty-python.gnu.org ([199.232.76.173]) 23 | # by fencepost.gnu.org with esmtp (Exim 4.10) 24 | # id 17yAZa-00055o-00 25 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:50 -0400 26 | # Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) 27 | # id 17yAZE-0007eB-00 28 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:29 -0400 29 | # Received: from avcnet.bates.edu ([134.181.128.62]) 30 | # by monty-python.gnu.org with esmtp (Exim 4.10) 31 | # id 17yAZ9-0007X3-00 32 | # for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:23 -0400 33 | # Received: from a5514a.bates.edu (www.bates.edu [134.181.128.62]) 34 | # by avcnet.bates.edu (8.9.3/8.9.3) with ESMTP id IAA05400 35 | # for ; Sun, 6 Oct 2002 08:31:20 -0400 36 | # Date: Sun, 6 Oct 2002 08:36:54 -0400 37 | # Mime-Version: 1.0 (Apple Message framework v482) 38 | # Content-Type: text/plain; charset=US-ASCII; format=flowed 39 | # Subject: Infinite loop in sub/gsub 40 | # From: jhart@avcnet.bates.edu 41 | # To: bug-gawk@gnu.org 42 | # Content-Transfer-Encoding: 7bit 43 | # Message-Id: <4BC4A4F0-D928-11D6-8E78-00039384A9CC@mail.avcnet.org> 44 | # X-Mailer: Apple Mail (2.482) 45 | # X-Spam-Status: No, hits=0.3 required=5.0 46 | # tests=NO_REAL_NAME,SPAM_PHRASE_00_01,USER_AGENT_APPLEMAIL 47 | # version=2.41 48 | # X-Spam-Level: 49 | # X-SpamBouncer: 1.4 (10/07/01) 50 | # X-SBClass: OK 51 | # Status: RO 52 | # 53 | # This command line: 54 | # 55 | # echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk 56 | # 57 | # where test.awk contains this instruction: 58 | # 59 | /''/ { sub(/''(.?[^']+)*''/, "&"); } 60 | # 61 | # puts gawk 3.11 into an infinite loop. Whereas, this command works: 62 | # 63 | # echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk 64 | # 65 | # 66 | # 67 | # Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 68 | # PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC 69 | # 70 | # 71 | -------------------------------------------------------------------------------- /test/gawktests/noloop2.in: -------------------------------------------------------------------------------- 1 | ''Italics with an apostrophe' embedded'' 2 | -------------------------------------------------------------------------------- /test/gawktests/noloop2.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/noloop2.ok -------------------------------------------------------------------------------- /test/gawktests/nondec.awk: -------------------------------------------------------------------------------- 1 | BEGIN { print 0x81c3e8, 0x744018, 00.34 } 2 | -------------------------------------------------------------------------------- /test/gawktests/nondec.ok: -------------------------------------------------------------------------------- 1 | 8504296 7618584 0.34 2 | -------------------------------------------------------------------------------- /test/gawktests/nulrsend.in: -------------------------------------------------------------------------------- 1 | 1111 2 | 3 | 2222 4 | 5 | -------------------------------------------------------------------------------- /test/gawktests/nulrsend.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | -------------------------------------------------------------------------------- /test/gawktests/numindex.awk: -------------------------------------------------------------------------------- 1 | #To: bug-gnu-utils@gnu.org 2 | #cc: arnold@gnu.org 3 | #Subject: Possible bug in GNU Awk 3.0.4 4 | #Date: Wed, 24 Nov 1999 21:47:24 +0000 5 | #From: Daniel Elphick 6 | #Message-Id: 7 | # 8 | #This is a multipart MIME message. 9 | # 10 | #--==_Exmh_-11192982200 11 | #Content-Type: text/plain; charset=us-ascii 12 | # 13 | # 14 | #When I use the attached awk script unique on the attached data file, it 15 | #reports that all 4 lines of the data are the same. Using mawk it correctly 16 | #reports that there are no repeats. 17 | # 18 | #I don't know if there are limits on the size of associative array keys for the 19 | #purposes of reliable indexing but if there is then it is not (obviously) 20 | #documented. 21 | # 22 | # 23 | #--==_Exmh_-11192982200 24 | #Content-Type: text/plain ; name="data"; charset=us-ascii 25 | #Content-Description: data 26 | #Content-Disposition: attachment; filename="data" 27 | # 28 | #322322111111112232231111 29 | #322322111111112213223111 30 | #322322111111112211132231 31 | #322322111111112211113223 32 | # 33 | #--==_Exmh_-11192982200 34 | #Content-Type: text/plain ; name="unique"; charset=us-ascii 35 | #Content-Description: unique 36 | #Content-Disposition: attachment; filename="unique" 37 | # 38 | { 39 | if($0 in a) 40 | { 41 | printf("line %d has been seen before at line %d\n", NR, a[$0]) 42 | repeat_count += 1 43 | } 44 | else 45 | { 46 | a[$0] = NR 47 | } 48 | count += 1 49 | } 50 | END { 51 | # printf("%d %f%%\n", repeat_count, (float)repeat_count / count * 100) 52 | printf("%d %f%%\n", repeat_count, repeat_count / count * 100) 53 | } 54 | # 55 | #--==_Exmh_-11192982200-- 56 | -------------------------------------------------------------------------------- /test/gawktests/numindex.in: -------------------------------------------------------------------------------- 1 | 322322111111112232231111 2 | 322322111111112213223111 3 | 322322111111112211132231 4 | 322322111111112211113223 5 | -------------------------------------------------------------------------------- /test/gawktests/numindex.ok: -------------------------------------------------------------------------------- 1 | 0 0.000000% 2 | -------------------------------------------------------------------------------- /test/gawktests/numstr1.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | split("1.234", f) 3 | OFMT = "%.1f" 4 | print f[1] 5 | x = f[1]+0 6 | print f[1] 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/numstr1.ok: -------------------------------------------------------------------------------- 1 | 1.234 2 | 1.234 3 | -------------------------------------------------------------------------------- /test/gawktests/numsubstr.awk: -------------------------------------------------------------------------------- 1 | { print substr(1000+$1, 2) } 2 | -------------------------------------------------------------------------------- /test/gawktests/numsubstr.in: -------------------------------------------------------------------------------- 1 | 5000 2 | 10000 3 | 5000 4 | -------------------------------------------------------------------------------- /test/gawktests/numsubstr.ok: -------------------------------------------------------------------------------- 1 | 000 2 | 1000 3 | 000 4 | -------------------------------------------------------------------------------- /test/gawktests/octsub.awk: -------------------------------------------------------------------------------- 1 | BEGIN{ ++x[03]; print "/" x[0] "/" x[3] "/"} 2 | -------------------------------------------------------------------------------- /test/gawktests/octsub.ok: -------------------------------------------------------------------------------- 1 | //1/ 2 | -------------------------------------------------------------------------------- /test/gawktests/ofmt.awk: -------------------------------------------------------------------------------- 1 | # From dragon!knorke.saar.de!florian Wed Jul 16 10:47:27 1997 2 | # Return-Path: 3 | # Message-ID: <19970716164451.63610@knorke.saar.de> 4 | # Date: Wed, 16 Jul 1997 16:44:51 +0200 5 | # From: Florian La Roche 6 | # To: bug-gnu-utils@prep.ai.mit.edu 7 | # CC: arnold@gnu.ai.mit.edu 8 | # Subject: bug in gawk 3.0.3 9 | # MIME-Version: 1.0 10 | # Content-Type: text/plain; charset=us-ascii 11 | # X-Mailer: Mutt 0.76 12 | # Status: R 13 | # Content-Length: 1725 14 | # X-Lines: 177 15 | # X-Display-Position: 0 16 | # 17 | # I have a problem with gawk 3.0.3 on linux with libc 5.4.33. 18 | # The memory is corrupted, if I use OFMT = "%.12g". 19 | # With OFMT = "%.6g" evrything works fine, but I don't have enough 20 | # digits for the computation. 21 | # 22 | # Thanks a lot, 23 | # Florian La Roche 24 | # 25 | # Here is the sample awk-Script together with sample data: 26 | # 27 | BEGIN { 28 | OFMT = "%.12g" 29 | big = 99999999999 30 | lowest = big 31 | small = 0 32 | highest = small 33 | dir = "" 34 | } 35 | $0 ~ /^[0-9]+$/ { 36 | # some old awks do not think $0 is numeric, so use $1 37 | if ($1 < lowest) 38 | lowest = $1 39 | if ($1 > highest) 40 | highest = $1 41 | next 42 | } 43 | $0 ~ /\/\.:$/ { 44 | if (dir != "") { 45 | if (highest != small) 46 | print dir, highest, lowest 47 | else 48 | print dir, "-", "-" 49 | } 50 | dir = substr($0, 1, length($0)-3) # trim off /.: 51 | lowest = big 52 | highest = small 53 | } 54 | -------------------------------------------------------------------------------- /test/gawktests/ofmt.in: -------------------------------------------------------------------------------- 1 | alt/binaries/warez/crypto/.: 2 | .. 3 | ... 4 | 5 | alt/fan/douglas-adams/.: 6 | .. 7 | ... 8 | 7478 9 | 7479 10 | 7480 11 | 7481 12 | 7482 13 | 7483 14 | 7484 15 | 7485 16 | 7486 17 | 7490 18 | 7488 19 | 7489 20 | 7491 21 | 7407 22 | 7408 23 | 7409 24 | 7410 25 | 7411 26 | 7412 27 | 7413 28 | 7414 29 | 7415 30 | 7416 31 | 7417 32 | 7418 33 | 7419 34 | 7420 35 | 7421 36 | 7422 37 | 7423 38 | 7424 39 | 7425 40 | 7426 41 | 7427 42 | 7428 43 | 7429 44 | 7430 45 | 7431 46 | 7432 47 | 7433 48 | 7434 49 | 7435 50 | 7436 51 | 7437 52 | 7438 53 | 7439 54 | 7440 55 | 7441 56 | 7442 57 | 7443 58 | 7444 59 | 7445 60 | 7446 61 | 7447 62 | 7455 63 | 7449 64 | 7450 65 | 7451 66 | 7452 67 | 7453 68 | 7454 69 | 7456 70 | 7457 71 | 7458 72 | 7459 73 | 7460 74 | 7461 75 | 7462 76 | 7463 77 | 7464 78 | 7465 79 | 7466 80 | 7467 81 | 7468 82 | 7469 83 | 7470 84 | 7471 85 | 7472 86 | 7473 87 | 7475 88 | 7477 89 | 90 | alt/os/linux/.: 91 | .. 92 | ... 93 | 94 | 95 | alt/security/.: 96 | .. 97 | ... 98 | pgp 99 | ripem 100 | keydist 101 | index 102 | 9617 103 | 9618 104 | 9619 105 | 9620 106 | 9625 107 | 9621 108 | 9626 109 | 9622 110 | 9623 111 | 9624 112 | 9627 113 | 9628 114 | 9629 115 | 9630 116 | 9631 117 | 9632 118 | 9633 119 | 9634 120 | 9636 121 | 9637 122 | 9638 123 | 9639 124 | 9640 125 | 9641 126 | 127 | alt/security/index/.: 128 | .. 129 | ... 130 | 131 | alt/security/keydist/.: 132 | .. 133 | ... 134 | 253 135 | 136 | /.: 137 | -------------------------------------------------------------------------------- /test/gawktests/ofmt.ok: -------------------------------------------------------------------------------- 1 | alt/binaries/warez/crypto - - 2 | alt/fan/douglas-adams 7491 7407 3 | alt/os/linux - - 4 | alt/security 9641 9617 5 | alt/security/index - - 6 | alt/security/keydist 253 253 7 | -------------------------------------------------------------------------------- /test/gawktests/ofmta.awk: -------------------------------------------------------------------------------- 1 | # Date: Thu, 14 Apr 2011 08:18:55 -0500 2 | # From: j.eh@mchsi.com 3 | # To: arnold@skeeve.com 4 | # Subject: CONVFMT test for the test suite 5 | # Message-ID: <20110414131855.GA1801@apollo> 6 | # 7 | # Hi, 8 | # 9 | # Please consider adding this to the test suite. 3.1.8 segfaults 10 | # with this. 11 | # 12 | # Thanks, 13 | # 14 | # John 15 | # 16 | # 17 | BEGIN { 18 | i=1.2345 19 | i=3+i 20 | a[i]="hi" 21 | OFMT="%.1f" 22 | print i 23 | for (x in a) print x, a[x] 24 | print a[i] 25 | print "--------" 26 | CONVFMT=OFMT="%.3f" 27 | print i 28 | for (x in a) print x, a[x] 29 | print a[i] 30 | } 31 | -------------------------------------------------------------------------------- /test/gawktests/ofmta.ok: -------------------------------------------------------------------------------- 1 | 4.2 2 | 4.2345 hi 3 | hi 4 | -------- 5 | 4.234 6 | 4.2345 hi 7 | 8 | -------------------------------------------------------------------------------- /test/gawktests/ofmtbig.awk: -------------------------------------------------------------------------------- 1 | # 2 | # [USEMAP] 3 | # 4 | # Problem Report gnu/7821 5 | # 6 | # awk in free(): warning: chunk is already free. 7 | # 8 | # Confidential 9 | # no 10 | # 11 | # Severity 12 | # serious 13 | # 14 | # Priority 15 | # medium 16 | # 17 | # Responsible 18 | # freebsd-bugs@freebsd.org 19 | # 20 | # State 21 | # suspended 22 | # 23 | # Class 24 | # sw-bug 25 | # 26 | # Submitter-Id 27 | # current-users 28 | # 29 | # Arrival-Date 30 | # Thu Sep 3 10:30:00 PDT 1998 31 | # 32 | # Last-Modified 33 | # Thu Sep 17 02:04:26 PDT 1998 34 | # 35 | # Originator 36 | # Alexander Litvin archer@lucky.net 37 | # 38 | # Organization 39 | # 40 | # 41 | #Lucky Net ltd. 42 | # 43 | # Release 44 | # FreeBSD 3.0-CURRENT i386 45 | # 46 | # Environment 47 | # 48 | # 49 | #FreeBSD grape.carrier.kiev.ua 3.0-CURRENT FreeBSD 3.0-CURRENT #121: Thu Sep 3 50 | #1 51 | #1:21:44 EEST 1998 archer@grape.carrier.kiev.ua:/usr/src/sys/compile/GRAPE 52 | #i 53 | #386 54 | # 55 | # Description 56 | # 57 | # 58 | #The problem first appeared when GNU awk in 3.0-CURRENT was apgraded to 59 | #3.0.3. I run C-News, which uses awk extensively. After awk apgrade C-News 60 | #expire stopped to work. It appeared that some GNU awk 3.0.3 programms when 61 | #given absolutely legitimate input fail, giving out a number of messages: 62 | # 63 | #awk in free(): warning: chunk is already free. 64 | # 65 | # How-To-Repeat 66 | # 67 | # 68 | #Run the following awk program (it is cut out of C-News expire scripts). 69 | #I was not able to cut it down more -- omitting some portions of the 70 | #code (e.g. OFMT line), make error go away in this case, though it 71 | #certainly does not fix awk. 72 | # 73 | #----------------cut-here---------------- 74 | #!/usr/bin/awk -f 75 | BEGIN { 76 | OFMT = "%.12g" 77 | big = 99999999999 78 | lowest = big 79 | small = 0 80 | highest = small 81 | } 82 | 83 | $0 ~ /^[0-9]+$/ { 84 | if ($1 < lowest) 85 | lowest = $1 86 | if ($1 > highest) 87 | highest = $1 88 | next 89 | } 90 | 91 | # $0 ~ /^[a-z]+/ { 92 | $0 ~ /^[[:lower:]]+/ { 93 | print dir, highest, lowest 94 | dir = $0 95 | lowest = big 96 | highest = small 97 | } 98 | #----------------cut-here---------------- 99 | # 100 | #To get the error, just give this script the following input: 101 | #----------------cut-here---------------- 102 | #a 103 | #1 104 | #b 105 | #----------------cut-here---------------- 106 | # 107 | # Fix 108 | # 109 | # 110 | #I was not able to track the error in awk sources. As a workaround, 111 | #I just reverted to GNU awk 2.15.5. 112 | # 113 | # Audit-Trail 114 | # 115 | # 116 | #State-Changed-From-To: open-suspended 117 | #State-Changed-By: phk 118 | #State-Changed-When: Thu Sep 17 02:04:08 PDT 1998 119 | #State-Changed-Why: 120 | #reported to GNU maintainer. 121 | # 122 | # Submit Followup 123 | # _________________________________________________________________ 124 | # 125 | # 126 | # www@freebsd.org 127 | -------------------------------------------------------------------------------- /test/gawktests/ofmtbig.in: -------------------------------------------------------------------------------- 1 | a 2 | 1 3 | b 4 | -------------------------------------------------------------------------------- /test/gawktests/ofmtbig.ok: -------------------------------------------------------------------------------- 1 | 0 99999999999 2 | a 1 1 3 | -------------------------------------------------------------------------------- /test/gawktests/ofmtfidl.awk: -------------------------------------------------------------------------------- 1 | # From djones@zoonami.com Wed Jun 13 17:46:27 2001 2 | # Received: from mail.actcom.co.il [192.114.47.13] 3 | # by localhost with POP3 (fetchmail-5.5.0) 4 | # for arnold@localhost (single-drop); Wed, 13 Jun 2001 17:46:27 +0300 (IDT) 5 | # Received: by actcom.co.il (mbox arobbins) 6 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Wed Jun 13 17:47:09 2001) 7 | # X-From_: djones@zoonami.com Wed Jun 13 17:45:40 2001 8 | # Received: from lmail.actcom.co.il by actcom.co.il with ESMTP 9 | # (8.9.1a/actcom-0.2) id RAA07057 for ; 10 | # Wed, 13 Jun 2001 17:45:34 +0300 (EET DST) 11 | # (rfc931-sender: mail.actcom.co.il [192.114.47.13]) 12 | # Received: from billohost.com (www.billohost.com [209.196.35.10]) 13 | # by lmail.actcom.co.il (8.11.2/8.11.2) with ESMTP id f5DEjSO24028 14 | # for ; Wed, 13 Jun 2001 17:45:33 +0300 15 | # Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) 16 | # by billohost.com (8.9.3/8.9.3) with ESMTP id KAA24625 17 | # for ; Wed, 13 Jun 2001 10:44:43 -0400 18 | # Received: from topcat.zoonami.com ([193.112.141.198]) 19 | # by fencepost.gnu.org with esmtp (Exim 3.16 #1 (Debian)) 20 | # id 15ABtZ-0000FQ-00 21 | # for ; Wed, 13 Jun 2001 10:45:21 -0400 22 | # Received: from topcat.zoonami.com (localhost [127.0.0.1]) 23 | # by topcat.zoonami.com (8.9.3/8.9.3) with ESMTP id OAA28329; 24 | # Wed, 13 Jun 2001 14:45:54 GMT 25 | # (envelope-from djones@topcat.zoonami.com) 26 | # Message-Id: <200106131445.OAA28329@topcat.zoonami.com> 27 | # To: bug-gawk@gnu.org 28 | # cc: David Jones 29 | # Subject: 3.1.0 core dumps. Fiddling with OFMT? 30 | # Date: Wed, 13 Jun 2001 14:45:54 +0000 31 | # From: David Jones 32 | # Status: R 33 | # 34 | # The following program causes gawk to dump core: 35 | # 36 | # jot 10|./gawk '{OFMT="%."NR"f";print NR}' 37 | # 38 | # 'jot 10', if you didn't know, produces the numbers 1 to 10 each on its 39 | # own line (ie it's like awk 'BEGIN{for(i=1;i<=10;++i)print i}') 40 | # 41 | # Here's an example run: 42 | # 43 | # -- run being 44 | # 1 45 | # 2 46 | # 3 47 | # 4 48 | # gawk: cmd. line:1: (FILENAME=- FNR=5) fatal error: internal error 49 | # Abort trap - core dumped 50 | # -- run end 51 | # 52 | # Ah. print NR appears to be not interesting. The following program also 53 | # has the same problem: 54 | # 55 | # jot 10|./gawk '{OFMT="%."NR"f"}' 56 | # 57 | # Cheers, 58 | # djones 59 | # (version info follows) 60 | # 61 | # I'm running on FreeBSD 4.1, here's the output of uname -a 62 | # 63 | # FreeBSD topcat.zoonami.com 4.1-RELEASE FreeBSD 4.1-RELEASE #0: Fri Jul 28 14:30:31 GMT 2000 jkh@ref4.freebsd.org:/usr/src/sys/compile/GENERIC i386 64 | # 65 | # And ./gnu --version 66 | # 67 | # GNU Awk 3.1.0 68 | # Copyright (C) 1989, 1991-2001 Free Software Foundation. 69 | # 70 | # This program is free software; you can redistribute it and/or modify 71 | # it under the terms of the GNU General Public License as published by 72 | # the Free Software Foundation; either version 2 of the License, or 73 | # (at your option) any later version. 74 | # 75 | # This program is distributed in the hope that it will be useful, 76 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 77 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 78 | # GNU General Public License for more details. 79 | # 80 | # You should have received a copy of the GNU General Public License 81 | # along with this program; if not, write to the Free Software 82 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 83 | # 84 | # 85 | { OFMT="%."NR"f"; print NR } 86 | -------------------------------------------------------------------------------- /test/gawktests/ofmtfidl.in: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/gawktests/ofmtfidl.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | -------------------------------------------------------------------------------- /test/gawktests/ofmts.awk: -------------------------------------------------------------------------------- 1 | BEGIN { OFMT= "%s" } 2 | { $1 + $2; print $1, $2 } 3 | -------------------------------------------------------------------------------- /test/gawktests/ofmts.in: -------------------------------------------------------------------------------- 1 | 1.2 2.2 2 | -------------------------------------------------------------------------------- /test/gawktests/ofmts.ok: -------------------------------------------------------------------------------- 1 | 1.2 2.2 2 | -------------------------------------------------------------------------------- /test/gawktests/ofmtstrnum.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | split(" 1", f, "|") 3 | OFMT = "%.1f" 4 | print f[1] 5 | x = f[1] + 0 6 | print f[1] 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/ofmtstrnum.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /test/gawktests/ofs1.awk: -------------------------------------------------------------------------------- 1 | # Translate this shell script into gawk: 2 | # 3 | #! /bin/sh - 4 | # 5 | # awktest() 6 | # { 7 | # echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}' 8 | # echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}' 9 | # echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}' 10 | # echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}' 11 | # } 12 | # 13 | # AWK=./gawk 14 | # awktest > foo.gawk 15 | 16 | BEGIN { FS = ":" } 17 | 18 | # Have to reset OFS at end since not running separate invocations 19 | 20 | FNR == 1 { $2 = "x"; OFS = FS; print ; OFS = " "} 21 | FNR == 2 { $2 = "x"; print; OFS = FS; print ; OFS = " "} 22 | FNR == 3 { $2 = "x"; print $1; OFS = FS; print ; OFS = " "} 23 | FNR == 4 { $2 = "x"; print; $2 = $2; OFS = FS; print } 24 | -------------------------------------------------------------------------------- /test/gawktests/ofs1.in: -------------------------------------------------------------------------------- 1 | a:b:c 2 | a:b:c 3 | a:b:c 4 | a:b:c 5 | -------------------------------------------------------------------------------- /test/gawktests/ofs1.ok: -------------------------------------------------------------------------------- 1 | a x c 2 | a x c 3 | a x c 4 | a 5 | a x c 6 | a x c 7 | a x c 8 | -------------------------------------------------------------------------------- /test/gawktests/onlynl.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | { print "got", $0 } 3 | -------------------------------------------------------------------------------- /test/gawktests/onlynl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/gawktests/onlynl.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/onlynl.ok -------------------------------------------------------------------------------- /test/gawktests/opasnidx.awk: -------------------------------------------------------------------------------- 1 | BEGIN { b = 1; a[b] = 2; a[b++] += 1; print b,a[1] } 2 | -------------------------------------------------------------------------------- /test/gawktests/opasnidx.ok: -------------------------------------------------------------------------------- 1 | 2 3 2 | -------------------------------------------------------------------------------- /test/gawktests/opasnslf.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print b += b += 1 3 | b = 6 4 | print b += b++ 5 | print b 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/opasnslf.ok: -------------------------------------------------------------------------------- 1 | 2 2 | 13 3 | 13 4 | -------------------------------------------------------------------------------- /test/gawktests/paramtyp.awk: -------------------------------------------------------------------------------- 1 | # Sun Apr 25 13:28:58 IDT 1999 2 | # from Juegen Khars. This program should not core dump. 3 | function ReadPGM(f, d) { 4 | print "ReadPGM" 5 | d[1] = 1 6 | } 7 | 8 | function WritePGM(f, d) { 9 | print "WritePGM" 10 | d[1] = 0 11 | } 12 | 13 | BEGIN { 14 | print "before ReadPGM" 15 | ReadPGM("", d) 16 | print "after ReadPGM" 17 | print "before WritePGM" 18 | WritePGM("", d) 19 | print "after WritePGM" 20 | } 21 | -------------------------------------------------------------------------------- /test/gawktests/paramtyp.ok: -------------------------------------------------------------------------------- 1 | before ReadPGM 2 | ReadPGM 3 | after ReadPGM 4 | before WritePGM 5 | WritePGM 6 | after WritePGM 7 | -------------------------------------------------------------------------------- /test/gawktests/paramuninitglobal.awk: -------------------------------------------------------------------------------- 1 | function f(x) 2 | { 3 | a = 10 4 | x = 90 5 | print x 6 | print a 7 | a++ 8 | x++ 9 | print x 10 | } 11 | 12 | BEGIN { 13 | f(a) 14 | print a 15 | } 16 | -------------------------------------------------------------------------------- /test/gawktests/paramuninitglobal.ok: -------------------------------------------------------------------------------- 1 | 90 2 | 10 3 | 91 4 | 11 5 | -------------------------------------------------------------------------------- /test/gawktests/pcntplus.awk: -------------------------------------------------------------------------------- 1 | BEGIN { printf "%+d %d\n", 3, 4 } 2 | -------------------------------------------------------------------------------- /test/gawktests/pcntplus.ok: -------------------------------------------------------------------------------- 1 | +3 4 2 | -------------------------------------------------------------------------------- /test/gawktests/pipeio1.awk: -------------------------------------------------------------------------------- 1 | # From dragon!gamgee.acad.emich.edu!dhw Tue Mar 18 01:12:15 1997 2 | # Return-Path: 3 | # Message-ID: 4 | # Date: Mon, 17 Mar 97 20:48 CST 5 | # From: dhw@gamgee.acad.emich.edu (David H. West) 6 | # To: arnold@gnu.ai.mit.edu 7 | # Subject: gawk 3.0.2 bug report (cc of msg to bug-gnu-utils) 8 | # Status: OR 9 | # Content-Length: 869 10 | # X-Lines: 20 11 | # X-Display-Position: 2 12 | # 13 | # Nature of bug: operation on a pipe side-effects a different pipe. 14 | # Observed-With: gawk 3.0.2, Linux kernel 2.0.28 15 | # Reproduce-By: running the following script, without and with the "close" 16 | # statement uncommented. 17 | # -----------------cut here-------------------------- 18 | BEGIN {FILE1="test1"; FILE2="test2"; 19 | print "1\n" > FILE1; close(FILE1); 20 | print "2\n" > FILE2; close(FILE2); 21 | cmd1="cat " FILE1; cmd2="cat " FILE2; 22 | #end of preparing commands which give easily-predictable output 23 | 24 | while( (cmd1 | getline)==1) { #terminates as file has only 1 line 25 | #and we never close cmd1 26 | cmd2 | getline L; 27 | #BUG: uncommenting the following line causes an infinite loop 28 | close(cmd2); 29 | print $0,L; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/gawktests/pipeio1.ok: -------------------------------------------------------------------------------- 1 | 1 2 2 | 2 3 | -------------------------------------------------------------------------------- /test/gawktests/posix.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | a = "+2"; b = 2; c = "+2a"; d = "+2 "; e = " 2" 3 | 4 | printf "Test #1: " 5 | if (b == a) print "\"" a "\"" " compares as a number" 6 | else print "\"" a "\"" " compares as a string" 7 | 8 | printf "Test #2: " 9 | if (b == c) print "\"" c "\"" " compares as a number" 10 | else print "\"" c "\"" " compares as a string" 11 | 12 | printf "Test #3: " 13 | if (b == d) print "\"" d "\"" " compares as a number" 14 | else print "\"" d "\"" " compares as a string" 15 | 16 | printf "Test #4: " 17 | if (b == e) print "\"" e "\"" " compares as a number" 18 | else print "\"" e "\"" " compares as a string" 19 | 20 | f = a + b + c + d + e 21 | print "after addition" 22 | 23 | printf "Test #5: " 24 | if (b == a) print "\"" a "\"" " compares as a number" 25 | else print "\"" a "\"" " compares as a string" 26 | 27 | printf "Test #6: " 28 | if (b == c) print "\"" c "\"" " compares as a number" 29 | else print "\"" c "\"" " compares as a string" 30 | 31 | printf "Test #7: " 32 | if (b == d) print "\"" d "\"" " compares as a number" 33 | else print "\"" d "\"" " compares as a string" 34 | 35 | printf "Test #8: " 36 | if (b == e) print "\"" e "\"" " compares as a number" 37 | else print "\"" e "\"" " compares as a string" 38 | 39 | printf "Test #9: " 40 | if ("3e5" > "5") print "\"3e5\" > \"5\"" 41 | else print "\"3e5\" <= \"5\"" 42 | 43 | printf "Test #10: " 44 | x = 32.14 45 | y[x] = "test" 46 | OFMT = "%e" 47 | print y[x] 48 | 49 | printf "Test #11: " 50 | x = x + 0 51 | print y[x] 52 | 53 | printf "Test #12: " 54 | OFMT="%f" 55 | CONVFMT="%e" 56 | print 1.5, 1.5 "" 57 | 58 | printf "Test #13: " 59 | if ( 1000000 "" == 1000001 "") print "match" 60 | else print "nomatch" 61 | } 62 | { 63 | printf "Test #14: " 64 | FS = ":" 65 | print $1 66 | FS = "," 67 | printf "Test #15: " 68 | print $2 69 | } 70 | -------------------------------------------------------------------------------- /test/gawktests/posix.in: -------------------------------------------------------------------------------- 1 | 1:2,3 4 2 | -------------------------------------------------------------------------------- /test/gawktests/posix.ok: -------------------------------------------------------------------------------- 1 | Test #1: "+2" compares as a string 2 | Test #2: "+2a" compares as a string 3 | Test #3: "+2 " compares as a string 4 | Test #4: " 2" compares as a string 5 | after addition 6 | Test #5: "+2" compares as a string 7 | Test #6: "+2a" compares as a string 8 | Test #7: "+2 " compares as a string 9 | Test #8: " 2" compares as a string 10 | Test #9: "3e5" <= "5" 11 | Test #10: test 12 | Test #11: test 13 | Test #12: 1.500000 1.500000e+00 14 | Test #13: nomatch 15 | Test #14: 1:2,3 16 | Test #15: 4 17 | -------------------------------------------------------------------------------- /test/gawktests/prdupval.awk: -------------------------------------------------------------------------------- 1 | { print NF, $NF, "abc" $NF } 2 | -------------------------------------------------------------------------------- /test/gawktests/prdupval.in: -------------------------------------------------------------------------------- 1 | one 2 | -------------------------------------------------------------------------------- /test/gawktests/prdupval.ok: -------------------------------------------------------------------------------- 1 | 1 one abcone 2 | -------------------------------------------------------------------------------- /test/gawktests/prec.awk: -------------------------------------------------------------------------------- 1 | # check the precedence of operators: 2 | BEGIN { 3 | $1 = i = 1 4 | $+i++ 5 | $- -i++ 6 | print 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/prec.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/printf1.awk: -------------------------------------------------------------------------------- 1 | # Tue May 25 16:36:16 IDT 1999 2 | # 3 | # Test cases based on email from Andreas Schwab, schwab@gnu.org 4 | 5 | BEGIN { 6 | fmt[1] = "%8.5d"; data[1] = 100 7 | fmt[2] = "%#o"; data[2] = 0 8 | fmt[3] = "%#.1o"; data[3] = 0 9 | fmt[4] = "%#.0o"; data[4] = 0 10 | fmt[5] = "%#x"; data[5] = 0 11 | fmt[6] = "%.0d"; data[6] = 0 12 | fmt[7] = "%5.0d"; data[7] = 0 13 | 14 | for (i = 1; i <= 7; i++) { 15 | format = "%s, %d --- |" fmt[i] "|\n" 16 | printf(format, fmt[i], data[i], data[i]) 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /test/gawktests/printf1.ok: -------------------------------------------------------------------------------- 1 | %8.5d, 100 --- | 00100| 2 | %#o, 0 --- |0| 3 | %#.1o, 0 --- |0| 4 | %#.0o, 0 --- |0| 5 | %#x, 0 --- |0| 6 | %.0d, 0 --- || 7 | %5.0d, 0 --- | | 8 | -------------------------------------------------------------------------------- /test/gawktests/printfbad3.awk: -------------------------------------------------------------------------------- 1 | # Date: Wed, 14 Mar 2012 08:10:48 -0500 2 | # From: John Haque 3 | # To: arnold@skeeve.com 4 | # Subject: gawk printf format bug 5 | # 6 | # Hi. 7 | # 8 | # I think this is a bug: 9 | # 10 | # $ gawk 'BEGIN { printf("%.0x%#x%#x\n", 0, 167, 167)}' 11 | # 570xa7 12 | # 13 | # It should print 0xa70xa7. 14 | # 15 | # The solution is to initialize base to 0 in the beginning 16 | # of the while loop along with other stuff (format_tree). 17 | # 18 | # Thanks. 19 | # 20 | # John 21 | 22 | BEGIN { printf(">>%.0x<< >>%#x<< >>%#x<<\n", 0, 167, 167) } 23 | -------------------------------------------------------------------------------- /test/gawktests/printfbad3.ok: -------------------------------------------------------------------------------- 1 | >><< >>0xa7<< >>0xa7<< 2 | -------------------------------------------------------------------------------- /test/gawktests/printfchar.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | x[65] 3 | for (i in x) { 4 | # i should be a string 5 | printf "%c\n", i # should print 1st char of string 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/printfchar.ok: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /test/gawktests/prmreuse.awk: -------------------------------------------------------------------------------- 1 | # from Pat Rankin, rankin@eql.caltech.edu, now rankin@pactechdata.com 2 | 3 | BEGIN { dummy(1); legit(); exit } 4 | 5 | function dummy(arg) 6 | { 7 | return arg 8 | } 9 | 10 | function legit( scratch) 11 | { 12 | split("1 2 3", scratch) 13 | return "" 14 | } 15 | -------------------------------------------------------------------------------- /test/gawktests/prmreuse.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/prmreuse.ok -------------------------------------------------------------------------------- /test/gawktests/profile12.awk: -------------------------------------------------------------------------------- 1 | NR == 1 2 | NR == 2 { print } 3 | NR == 3 { print $0 } 4 | -------------------------------------------------------------------------------- /test/gawktests/profile12.in: -------------------------------------------------------------------------------- 1 | Line 1 2 | Line 2 3 | Line 3 4 | Line 4 5 | -------------------------------------------------------------------------------- /test/gawktests/profile12.ok: -------------------------------------------------------------------------------- 1 | Line 1 2 | Line 2 3 | Line 3 4 | -------------------------------------------------------------------------------- /test/gawktests/prt1eval.awk: -------------------------------------------------------------------------------- 1 | function tst () { 2 | sum += 1 3 | return sum 4 | } 5 | 6 | BEGIN { OFMT = "%.0f" ; print tst() } 7 | -------------------------------------------------------------------------------- /test/gawktests/prt1eval.ok: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/gawktests/prtoeval.awk: -------------------------------------------------------------------------------- 1 | function returns_a_str() { print "" ; return "'A STRING'" } 2 | BEGIN { 3 | print "partial line:", returns_a_str() 4 | } 5 | -------------------------------------------------------------------------------- /test/gawktests/prtoeval.ok: -------------------------------------------------------------------------------- 1 | 2 | partial line: 'A STRING' 3 | -------------------------------------------------------------------------------- /test/gawktests/range1.awk: -------------------------------------------------------------------------------- 1 | /foo/,/bar/ { print } 2 | -------------------------------------------------------------------------------- /test/gawktests/range1.in: -------------------------------------------------------------------------------- 1 | foobar 2 | junk 3 | -------------------------------------------------------------------------------- /test/gawktests/range1.ok: -------------------------------------------------------------------------------- 1 | foobar 2 | -------------------------------------------------------------------------------- /test/gawktests/rebuf.awk: -------------------------------------------------------------------------------- 1 | # From lole@epost.de Wed Sep 4 09:54:19 IDT 2002 2 | # Article: 14288 of comp.lang.awk 3 | # Path: iad-read.news.verio.net!dfw-artgen!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!213.70.124.113!not-for-mail 4 | # From: LorenzAtWork 5 | # Newsgroups: comp.lang.awk 6 | # Subject: bug in gawk 3.1.1? 7 | # Date: Wed, 28 Aug 2002 10:34:50 +0200 8 | # Lines: 45 9 | # Message-ID: <7g1pmukv07c56ep3qav3uebnipdaohqh2l@4ax.com> 10 | # Reply-To: lole@epost.de 11 | # NNTP-Posting-Host: 213.70.124.113 12 | # Mime-Version: 1.0 13 | # Content-Type: text/plain; charset=us-ascii 14 | # Content-Transfer-Encoding: 7bit 15 | # X-Trace: fu-berlin.de 1030523788 53278293 213.70.124.113 (16 [68559]) 16 | # X-Newsreader: Forte Agent 1.91/32.564 17 | # Xref: dfw-artgen comp.lang.awk:14288 18 | # 19 | # hello all, 20 | # 21 | # I'm using the following script 22 | # 23 | BEGIN { 24 | RS="ti1\n(dwv,)?" 25 | s = 0 26 | i = 0 27 | } 28 | { 29 | if ($1 != "") 30 | s = $1 31 | print ++i, s 32 | } 33 | # 34 | # to extract values from a file of the form 35 | # 36 | # ti1 37 | # dwv,98.22 38 | # ti1 39 | # dwv,103.08 40 | # ti1 41 | # ti1 42 | # dwv,196.25 43 | # ti1 44 | # dwv,210.62 45 | # ti1 46 | # dwv,223.53 47 | # 48 | # The desired result for this example looks like 49 | # 50 | # 1 0 51 | # 2 98.22 52 | # 3 103.08 53 | # 4 103.08 54 | # 5 196.25 55 | # 6 210.62 56 | # 7 223.53 57 | # 58 | # The script work fine the most time, but when run on the attached file 59 | # (sorry for the size, but the error would not appear with less data) I 60 | # get some (three with the attached file) lines that look like 61 | # 62 | # 1262 dwv,212.97 63 | # 1277 dwv,174.33 64 | # 1279 dwv,151.79 65 | # 66 | # I can't think of a other reason for this than a bug in gawk! 67 | # 68 | # I'm running gawk 3.1.1 on winnt 4.0 69 | # 70 | # best regards 71 | # Lorenz 72 | # 73 | # 74 | -------------------------------------------------------------------------------- /test/gawktests/regeq.awk: -------------------------------------------------------------------------------- 1 | #Date: Sat, 8 May 1999 17:42:20 +0200 2 | #From: Iva Cabric 3 | #To: bug-gnu-utils@gnu.org 4 | #Cc: arnold@gnu.org 5 | #Subject: Problem in gawk with match 6 | # 7 | #Hello, 8 | # 9 | #gawk reports fatal error in match when first character in regexp is "=" : 10 | # 11 | #$ gawk '{ where = match($0, /=a/); print where}' 12 | #gawk: cmd. line:1: { where = match($0, /=a/); print where} 13 | #gawk: cmd. line:1: ^ parse error 14 | #gawk: cmd. line:1: fatal: match() cannot have 0 arguments 15 | # 16 | #Using "\=" instead "=" works without problems : 17 | # 18 | #$ gawk '{ where = match($0, /\=a/); print where}' 19 | #sdgfa 20 | #0 21 | #asdfds=a 22 | #7 23 | # 24 | #Other versions of awk have no problems with "/=/" (except oawk on SunOS). 25 | # 26 | #-- 27 | # @ 28 | # 29 | { where = match($0, /=a/); print where} 30 | -------------------------------------------------------------------------------- /test/gawktests/regeq.in: -------------------------------------------------------------------------------- 1 | sdgfa 2 | asdfds=a 3 | -------------------------------------------------------------------------------- /test/gawktests/regeq.ok: -------------------------------------------------------------------------------- 1 | 0 2 | 7 3 | -------------------------------------------------------------------------------- /test/gawktests/regexprange.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | range = "[a-dx-z]" 3 | 4 | split("ABCDEFGHIJKLMNOPQRSTUVWXYZ", upper, "") 5 | split("abcdefghijklmnopqrstuvwxyz", lower, "") 6 | 7 | for (i = 1; i in upper; i++) 8 | printf("%s ~ %s ---> %s\n", 9 | upper[i], range, (upper[i] ~ range) ? "true" : "false") 10 | 11 | for (i = 1; i in lower; i++) 12 | printf("%s ~ %s ---> %s\n", 13 | lower[i], range, (lower[i] ~ range) ? "true" : "false") 14 | } 15 | -------------------------------------------------------------------------------- /test/gawktests/regexprange.ok: -------------------------------------------------------------------------------- 1 | A ~ [a-dx-z] ---> false 2 | B ~ [a-dx-z] ---> false 3 | C ~ [a-dx-z] ---> false 4 | D ~ [a-dx-z] ---> false 5 | E ~ [a-dx-z] ---> false 6 | F ~ [a-dx-z] ---> false 7 | G ~ [a-dx-z] ---> false 8 | H ~ [a-dx-z] ---> false 9 | I ~ [a-dx-z] ---> false 10 | J ~ [a-dx-z] ---> false 11 | K ~ [a-dx-z] ---> false 12 | L ~ [a-dx-z] ---> false 13 | M ~ [a-dx-z] ---> false 14 | N ~ [a-dx-z] ---> false 15 | O ~ [a-dx-z] ---> false 16 | P ~ [a-dx-z] ---> false 17 | Q ~ [a-dx-z] ---> false 18 | R ~ [a-dx-z] ---> false 19 | S ~ [a-dx-z] ---> false 20 | T ~ [a-dx-z] ---> false 21 | U ~ [a-dx-z] ---> false 22 | V ~ [a-dx-z] ---> false 23 | W ~ [a-dx-z] ---> false 24 | X ~ [a-dx-z] ---> false 25 | Y ~ [a-dx-z] ---> false 26 | Z ~ [a-dx-z] ---> false 27 | a ~ [a-dx-z] ---> true 28 | b ~ [a-dx-z] ---> true 29 | c ~ [a-dx-z] ---> true 30 | d ~ [a-dx-z] ---> true 31 | e ~ [a-dx-z] ---> false 32 | f ~ [a-dx-z] ---> false 33 | g ~ [a-dx-z] ---> false 34 | h ~ [a-dx-z] ---> false 35 | i ~ [a-dx-z] ---> false 36 | j ~ [a-dx-z] ---> false 37 | k ~ [a-dx-z] ---> false 38 | l ~ [a-dx-z] ---> false 39 | m ~ [a-dx-z] ---> false 40 | n ~ [a-dx-z] ---> false 41 | o ~ [a-dx-z] ---> false 42 | p ~ [a-dx-z] ---> false 43 | q ~ [a-dx-z] ---> false 44 | r ~ [a-dx-z] ---> false 45 | s ~ [a-dx-z] ---> false 46 | t ~ [a-dx-z] ---> false 47 | u ~ [a-dx-z] ---> false 48 | v ~ [a-dx-z] ---> false 49 | w ~ [a-dx-z] ---> false 50 | x ~ [a-dx-z] ---> true 51 | y ~ [a-dx-z] ---> true 52 | z ~ [a-dx-z] ---> true 53 | -------------------------------------------------------------------------------- /test/gawktests/reginttrad.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | str1 = "aabbbc" 3 | str2 = "aaabcc" 4 | if (str1 ~ /b{2,}/) printf("\"%s\" matches /b{2,}/\n", str1) 5 | if (str2 ~ /b{2,}/) printf("\"%s\" matches /b{2,}/\n", str2) 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/reginttrad.ok: -------------------------------------------------------------------------------- 1 | "aabbbc" matches /b{2,}/ 2 | -------------------------------------------------------------------------------- /test/gawktests/reint.awk: -------------------------------------------------------------------------------- 1 | { print match($0, /a{3}/) } 2 | -------------------------------------------------------------------------------- /test/gawktests/reint.in: -------------------------------------------------------------------------------- 1 | match this: aaa 2 | -------------------------------------------------------------------------------- /test/gawktests/reint.ok: -------------------------------------------------------------------------------- 1 | 13 2 | -------------------------------------------------------------------------------- /test/gawktests/reint2.awk: -------------------------------------------------------------------------------- 1 | /^([[:digit:]]+[[:space:]]+){2}/ 2 | -------------------------------------------------------------------------------- /test/gawktests/reint2.in: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | -------------------------------------------------------------------------------- /test/gawktests/reint2.ok: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | -------------------------------------------------------------------------------- /test/gawktests/reparse.awk: -------------------------------------------------------------------------------- 1 | { 2 | gsub(/x/, " ") 3 | $0 = $0 4 | print $1 5 | print $0 6 | print $1, $2, $3 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/reparse.in: -------------------------------------------------------------------------------- 1 | 1 axbxc 2 2 | -------------------------------------------------------------------------------- /test/gawktests/reparse.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 1 a b c 2 3 | 1 a b 4 | -------------------------------------------------------------------------------- /test/gawktests/resplit.awk: -------------------------------------------------------------------------------- 1 | { FS = ":"; $0 = $0; print $2 } 2 | -------------------------------------------------------------------------------- /test/gawktests/resplit.in: -------------------------------------------------------------------------------- 1 | a:b:c d:e:f 2 | -------------------------------------------------------------------------------- /test/gawktests/resplit.ok: -------------------------------------------------------------------------------- 1 | b 2 | -------------------------------------------------------------------------------- /test/gawktests/rri1.awk: -------------------------------------------------------------------------------- 1 | /[d-f]/ 2 | -------------------------------------------------------------------------------- /test/gawktests/rri1.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/rri1.in -------------------------------------------------------------------------------- /test/gawktests/rri1.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/rri1.ok -------------------------------------------------------------------------------- /test/gawktests/rs.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | { print $1, $2 } 3 | -------------------------------------------------------------------------------- /test/gawktests/rs.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | a 4 | b 5 | 6 | 7 | c d 8 | 9 | 10 | 11 | e 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/gawktests/rs.ok: -------------------------------------------------------------------------------- 1 | a b 2 | c d 3 | e 4 | -------------------------------------------------------------------------------- /test/gawktests/rsnul1nl.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | { print } 3 | -------------------------------------------------------------------------------- /test/gawktests/rsnul1nl.in: -------------------------------------------------------------------------------- 1 | 2 | This is... 3 | the first record. 4 | -------------------------------------------------------------------------------- /test/gawktests/rsnul1nl.ok: -------------------------------------------------------------------------------- 1 | This is... 2 | the first record. 3 | -------------------------------------------------------------------------------- /test/gawktests/rsnullre.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS = "()" 3 | } 4 | 5 | { printf("<<%s>>\n", $0) ; printf("<%s>\n", RT) } 6 | -------------------------------------------------------------------------------- /test/gawktests/rsnullre.in: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/gawktests/rsnullre.ok: -------------------------------------------------------------------------------- 1 | <> 3 | <> 4 | -------------------------------------------------------------------------------- /test/gawktests/rsstart1.awk: -------------------------------------------------------------------------------- 1 | # From arnold@f7.net Wed Dec 15 11:32:46 2004 2 | # Date: Tue, 14 Dec 2004 14:48:58 +0100 3 | # From: Stepan Kasal 4 | # Subject: gawk bug with RS="^..." 5 | # To: bug-gawk@gnu.org 6 | # Message-id: <20041214134858.GA15490@matsrv.math.cas.cz> 7 | # 8 | # Hello, 9 | # I've noticed a problem with "^" in RS in gawk. In most cases, it seems 10 | # to match only the beginning of the file. But in fact it matches the 11 | # beginning of gawk's internal buffer. 12 | # 13 | # Observe the following example: 14 | # 15 | # $ gawk 'BEGIN{for(i=1;i<=100;i++) print "Axxxxxx"}' >file 16 | # $ gawk 'BEGIN{RS="^A"} END{print NR}' file 17 | # 2 18 | # $ gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' file 19 | # 100 20 | # $ head file | gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' 21 | # 10 22 | # $ 23 | # 24 | # I think this calls for some clarification/fix. But I don't have any 25 | # fixed opinion how the solution should look like. 26 | # 27 | # Have a nice day, 28 | # Stepan Kasal 29 | # 30 | # PS: See also the discussion of the issue in the comp.lang.awk newsgroup. 31 | BEGIN { RS = "^A" } 32 | END { print NR } 33 | -------------------------------------------------------------------------------- /test/gawktests/rsstart1.ok: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/gawktests/rstest1.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS = "" 3 | FS = ":" 4 | s = "a:b\nc:d" 5 | print split(s,a) 6 | print length(a[2]) 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/rstest1.ok: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | -------------------------------------------------------------------------------- /test/gawktests/rstest2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | RS = "" 3 | FS = "\\" 4 | $0 = "a\\b" 5 | print $1 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/rstest2.ok: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /test/gawktests/rstest3.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Tue Apr 15 17:35:01 2003 2 | # Return-Path: 3 | # Received: from localhost (aahz [127.0.0.1]) 4 | # by skeeve.com (8.12.5/8.12.5) with ESMTP id h3FEYA6o001541 5 | # for ; Tue, 15 Apr 2003 17:35:01 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Tue, 15 Apr 2003 17:35:01 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue Apr 15 17:38:46 2003) 11 | # X-From_: spcecdt@armory.com Tue Apr 15 11:09:12 2003 12 | # Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id h3F88uC19825 for ; 14 | # Tue, 15 Apr 2003 11:09:04 +0300 (EET DST) 15 | # (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h3F8CgQ7019081 18 | # for ; Tue, 15 Apr 2003 11:12:47 +0300 19 | # Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) 20 | # by f7.net (8.11.7/8.11.6) with ESMTP id h3F88oW23381 21 | # for ; Tue, 15 Apr 2003 04:08:50 -0400 22 | # Received: from monty-python.gnu.org ([199.232.76.173]) 23 | # by fencepost.gnu.org with esmtp (Exim 4.10) 24 | # id 195LUo-0001cv-00 25 | # for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:50 -0400 26 | # Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) 27 | # id 195LUh-0006n0-00 28 | # for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:44 -0400 29 | # Received: from deepthought.armory.com ([192.122.209.42] helo=armory.com) 30 | # by monty-python.gnu.org with smtp (Exim 4.10.13) 31 | # id 195LUC-0006JM-00 32 | # for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:13 -0400 33 | # Date: Tue, 15 Apr 2003 01:08:11 -0700 34 | # From: "John H. DuBois III" 35 | # To: bug-gawk@gnu.org 36 | # Subject: gawk 3.1.2 fatal bug 37 | # Message-ID: <20030415080811.GA14963@armory.com> 38 | # Mime-Version: 1.0 39 | # Content-Type: text/plain; charset=us-ascii 40 | # Content-Disposition: inline 41 | # User-Agent: Mutt/1.3.28i 42 | # X-Www: http://www.armory.com./~spcecdt/ 43 | # Sender: spcecdt@armory.com 44 | # X-Spam-Status: No, hits=-7.9 required=5.0 45 | # tests=SIGNATURE_SHORT_DENSE,SPAM_PHRASE_01_02,USER_AGENT, 46 | # USER_AGENT_MUTT 47 | # version=2.41 48 | # X-Spam-Level: 49 | # X-SpamBouncer: 1.4 (10/07/01) 50 | # X-SBClass: OK 51 | # Status: RO 52 | # 53 | # This program: 54 | # 55 | # BEGIN { RS = ""; "/bin/echo -n x" | getline } 56 | # 57 | # fails in exactly the same way under SCO OpenServer 5.0.6a using gawk 3.1.2 58 | # built with gcc 2.95.3 and linux using gawk 3.1.2 built with gcc 3.2.2: 59 | # 60 | # gawk: gawktest:1: fatal error: internal error 61 | # Abort 62 | # 63 | # The same program does not fail with gawk 3.1.1. 64 | # 65 | # John 66 | # -- 67 | # John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ 68 | # 69 | # 70 | BEGIN { 71 | RS = "" 72 | "echo x | tr -d '\\12'" | getline 73 | } 74 | -------------------------------------------------------------------------------- /test/gawktests/rstest3.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/rstest3.ok -------------------------------------------------------------------------------- /test/gawktests/rstest4.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Mon May 5 14:37:09 2003 2 | # Return-Path: 3 | # Received: from localhost (skeeve [127.0.0.1]) 4 | # by skeeve.com (8.12.5/8.12.5) with ESMTP id h45B1GvT031993 5 | # for ; Mon, 5 May 2003 14:37:09 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Mon, 05 May 2003 14:37:09 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Mon May 5 14:35:11 2003) 11 | # X-From_: spcecdt@armory.com Mon May 5 12:20:20 2003 12 | # Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id h459KC529186 for ; 14 | # Mon, 5 May 2003 12:20:15 +0300 (EET DST) 15 | # (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h459LMfl025854 18 | # for ; Mon, 5 May 2003 12:21:24 +0300 19 | # Received: from armory.com (deepthought.armory.com [192.122.209.42]) 20 | # by f7.net (8.11.7/8.11.6) with SMTP id h459K9I26841 21 | # for ; Mon, 5 May 2003 05:20:09 -0400 22 | # Date: Mon, 5 May 2003 02:20:08 -0700 23 | # From: "John H. DuBois III" 24 | # To: Aharon Robbins 25 | # Subject: Re: gawk 3.1.2b now available 26 | # Message-ID: <20030505092008.GA15970@armory.com> 27 | # References: <200305041149.h44BnLcm005484@localhost.localdomain> 28 | # Mime-Version: 1.0 29 | # Content-Type: text/plain; charset=us-ascii 30 | # Content-Disposition: inline 31 | # In-Reply-To: <200305041149.h44BnLcm005484@localhost.localdomain> 32 | # User-Agent: Mutt/1.3.28i 33 | # X-Www: http://www.armory.com./~spcecdt/ 34 | # Sender: spcecdt@armory.com 35 | # X-SpamBouncer: 1.4 (10/07/01) 36 | # X-SBClass: OK 37 | # Status: RO 38 | # 39 | # This is a curious one: 40 | # 41 | # gawk-3.1.2b 'BEGIN { 42 | # while (("echo" | getline) == 1) 43 | # ; 44 | # RS = "" 45 | # "echo \"a\n\nb\"" | getline y 46 | # print x 47 | # }' | hd 48 | # 49 | # The output is: 50 | # 51 | # 0000 00 13 0a ... 52 | # 0003 53 | # 54 | # (the uninitialized variable 'x' is somehow getting the value ) 55 | # 56 | # John 57 | # -- 58 | # John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ 59 | # 60 | BEGIN { 61 | while (("echo" | getline) == 1) 62 | ; 63 | RS = "" 64 | "echo \"a\n\nb\"" | getline y 65 | printf "y = <%s>\n", y # ADR 66 | printf "x = <%s>\n", x # ADR 67 | } 68 | -------------------------------------------------------------------------------- /test/gawktests/rstest4.ok: -------------------------------------------------------------------------------- 1 | y = 2 | x = <> 3 | -------------------------------------------------------------------------------- /test/gawktests/rstest5.awk: -------------------------------------------------------------------------------- 1 | # From spcecdt@armory.com Tue May 6 13:42:34 2003 2 | # Return-Path: 3 | # Received: from localhost (aahz [127.0.0.1]) 4 | # by skeeve.com (8.12.5/8.12.5) with ESMTP id h46AgG53003519 5 | # for ; Tue, 6 May 2003 13:42:34 +0300 6 | # Received: from actcom.co.il [192.114.47.1] 7 | # by localhost with POP3 (fetchmail-5.9.0) 8 | # for arnold@localhost (single-drop); Tue, 06 May 2003 13:42:34 +0300 (IDT) 9 | # Received: by actcom.co.il (mbox arobbins) 10 | # (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue May 6 13:48:46 2003) 11 | # X-From_: spcecdt@armory.com Tue May 6 13:26:09 2003 12 | # Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP 13 | # (8.11.6/actcom-0.2) id h46AQ6520133 for ; 14 | # Tue, 6 May 2003 13:26:07 +0300 (EET DST) 15 | # (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) 16 | # Received: from f7.net (consort.superb.net [209.61.216.22]) 17 | # by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h46ARSfl010998 18 | # for ; Tue, 6 May 2003 13:27:31 +0300 19 | # Received: from armory.com (deepthought.armory.com [192.122.209.42]) 20 | # by f7.net (8.11.7/8.11.6) with SMTP id h46AQ1I18183 21 | # for ; Tue, 6 May 2003 06:26:01 -0400 22 | # Date: Tue, 6 May 2003 03:25:59 -0700 23 | # From: "John H. DuBois III" 24 | # To: Aharon Robbins 25 | # Subject: Re: gawk 3.1.2b now available 26 | # Message-ID: <20030506102559.GA16105@armory.com> 27 | # References: <200305051157.h45Bv4XO003106@localhost.localdomain> 28 | # Mime-Version: 1.0 29 | # Content-Type: text/plain; charset=us-ascii 30 | # Content-Disposition: inline 31 | # In-Reply-To: <200305051157.h45Bv4XO003106@localhost.localdomain> 32 | # User-Agent: Mutt/1.3.28i 33 | # X-Www: http://www.armory.com./~spcecdt/ 34 | # Sender: spcecdt@armory.com 35 | # X-SpamBouncer: 1.4 (10/07/01) 36 | # X-SBClass: OK 37 | # Status: RO 38 | # 39 | # The patch fixed the previous case, but here's another one - this prints 40 | # : 41 | # 42 | # BEGIN { 43 | # RS = "" 44 | # "echo 'foo\n\nbaz'" | getline 45 | # "echo 'foo\n\nbaz'" | getline 46 | # "echo 'bar\n\nbaz'" | getline 47 | # print x 48 | # } 49 | # 50 | # John 51 | # -- 52 | # John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ 53 | # 54 | BEGIN { 55 | RS = "" 56 | "echo 'foo\n\nbaz'" | getline ; print 57 | "echo 'foo\n\nbaz'" | getline ; print 58 | "echo 'bar\n\nbaz'" | getline ; print 59 | printf "x = <%s>\n", x 60 | } 61 | -------------------------------------------------------------------------------- /test/gawktests/rstest5.ok: -------------------------------------------------------------------------------- 1 | foo 2 | baz 3 | bar 4 | x = <> 5 | -------------------------------------------------------------------------------- /test/gawktests/rstest6.awk: -------------------------------------------------------------------------------- 1 | # Wed Jul 14 16:02:45 IDT 2004 2 | # Test case from John Haque mary1john8@earthlink.net 3 | 4 | BEGIN { RS = "XYZ" } 5 | 6 | { print } 7 | -------------------------------------------------------------------------------- /test/gawktests/rstest6.in: -------------------------------------------------------------------------------- 1 | ABCD -------------------------------------------------------------------------------- /test/gawktests/rstest6.ok: -------------------------------------------------------------------------------- 1 | ABCD 2 | -------------------------------------------------------------------------------- /test/gawktests/rswhite.awk: -------------------------------------------------------------------------------- 1 | BEGIN { RS = "" } 2 | { printf("<%s>\n", $0) } 3 | -------------------------------------------------------------------------------- /test/gawktests/rswhite.in: -------------------------------------------------------------------------------- 1 | a b 2 | c d 3 | -------------------------------------------------------------------------------- /test/gawktests/rswhite.ok: -------------------------------------------------------------------------------- 1 | < a b 2 | c d> 3 | -------------------------------------------------------------------------------- /test/gawktests/setrec0.awk: -------------------------------------------------------------------------------- 1 | function reassign(x, y) { 2 | $0 = x 3 | print y 4 | } 5 | 6 | { 7 | reassign("larry", $1) 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/setrec0.in: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /test/gawktests/setrec0.ok: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /test/gawktests/setrec1.awk: -------------------------------------------------------------------------------- 1 | function reassign(x, y) { 2 | $0 = x 3 | print y 4 | } 5 | 6 | BEGIN { 7 | $0 = substr("geronimo", 5, 3) 8 | reassign(" 52", $1) 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/setrec1.ok: -------------------------------------------------------------------------------- 1 | nim 2 | -------------------------------------------------------------------------------- /test/gawktests/shadowbuiltin.awk: -------------------------------------------------------------------------------- 1 | function foo(gensub) 2 | { 3 | print gensub 4 | print lshift(1, 1) 5 | } 6 | 7 | BEGIN { 8 | x = 5 9 | foo(x) 10 | } 11 | -------------------------------------------------------------------------------- /test/gawktests/shadowbuiltin.ok: -------------------------------------------------------------------------------- 1 | 5 2 | 2 3 | -------------------------------------------------------------------------------- /test/gawktests/sigpipe1.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print "system" 3 | command = "yes | true" 4 | system(command) 5 | 6 | print "pipe to command" 7 | print "hi" | command 8 | close(command) 9 | 10 | print "pipe from command" 11 | command | getline x 12 | close(command) 13 | } 14 | -------------------------------------------------------------------------------- /test/gawktests/sigpipe1.ok: -------------------------------------------------------------------------------- 1 | system 2 | pipe to command 3 | pipe from command 4 | -------------------------------------------------------------------------------- /test/gawktests/sortfor2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | PROCINFO["sorted_in"] = "@ind_num_asc" 3 | } 4 | { 5 | A[$1] = 0 6 | } 7 | END { 8 | for (I in A) B[I] = A[I] 9 | for (I in B) SCRATCH = A[I] 10 | for (I in A) print I 11 | } 12 | -------------------------------------------------------------------------------- /test/gawktests/sortfor2.in: -------------------------------------------------------------------------------- 1 | 1.0 2 | 2.0 3 | -------------------------------------------------------------------------------- /test/gawktests/sortfor2.ok: -------------------------------------------------------------------------------- 1 | 1.0 2 | 2.0 3 | -------------------------------------------------------------------------------- /test/gawktests/spacere.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | c[" "] = "\" \"" 3 | c["\a"] = "\\a" 4 | c["\b"] = "\\b" 5 | c["\f"] = "\\f" 6 | c["\n"] = "\\n" 7 | c["\r"] = "\\r" 8 | c["\t"] = "\\t" 9 | c["\v"] = "\\v" 10 | 11 | sort = "sort" 12 | 13 | for (i in c) 14 | printf("%s %s [[:space:]]\n", c[i], 15 | i ~ /[[:space:]]/ ? "~" : "!~") | sort 16 | 17 | for (i in c) 18 | printf("%s %s [[:blank:]]\n", c[i], 19 | i ~ /[[:blank:]]/ ? "~" : "!~") | sort 20 | 21 | close(sort) 22 | } 23 | -------------------------------------------------------------------------------- /test/gawktests/spacere.ok: -------------------------------------------------------------------------------- 1 | " " ~ [[:blank:]] 2 | " " ~ [[:space:]] 3 | \a !~ [[:blank:]] 4 | \a !~ [[:space:]] 5 | \b !~ [[:blank:]] 6 | \b !~ [[:space:]] 7 | \f !~ [[:blank:]] 8 | \f ~ [[:space:]] 9 | \n !~ [[:blank:]] 10 | \n ~ [[:space:]] 11 | \r !~ [[:blank:]] 12 | \r ~ [[:space:]] 13 | \t ~ [[:blank:]] 14 | \t ~ [[:space:]] 15 | \v !~ [[:blank:]] 16 | \v ~ [[:space:]] 17 | -------------------------------------------------------------------------------- /test/gawktests/splitargv.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | for (idx = 1; idx < ARGC; idx++) 3 | split(ARGV[idx], temp, "."); 4 | } 5 | { 6 | print $0; 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/splitargv.in: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | for (idx = 1; idx < ARGC; idx++) 3 | split(ARGV[idx], temp, "."); 4 | } 5 | { 6 | print $0; 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/splitargv.ok: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | for (idx = 1; idx < ARGC; idx++) 3 | split(ARGV[idx], temp, "."); 4 | } 5 | { 6 | print $0; 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/splitarr.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | a[1] = "elephantie" 3 | a[2] = "e" 4 | print split(a[1],a,a[2]), a[2], a[3], split(a[2],a,a[2]) 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/splitarr.ok: -------------------------------------------------------------------------------- 1 | 4 l phanti 2 2 | -------------------------------------------------------------------------------- /test/gawktests/splitdef.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | data = "abc:easy:as:one:two:three" 3 | FS = ":" 4 | FIELDWIDTHS = "3 1 4 1 2 1 3 1 3 1 5" 5 | n = split(data, a) 6 | printf "n = %d, a[3] = %s\n", n, a[3] 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/splitdef.ok: -------------------------------------------------------------------------------- 1 | n = 6, a[3] = as 2 | -------------------------------------------------------------------------------- /test/gawktests/splitvar.awk: -------------------------------------------------------------------------------- 1 | { 2 | sep = "=+" 3 | n = split($0, a, sep) 4 | print n 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/splitvar.in: -------------------------------------------------------------------------------- 1 | Here===Is=Some=====Data 2 | -------------------------------------------------------------------------------- /test/gawktests/splitvar.ok: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/gawktests/splitwht.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | str = "a b\t\tc d" 3 | n = split(str, a, " ") 4 | print n 5 | m = split(str, b, / /) 6 | print m 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/splitwht.ok: -------------------------------------------------------------------------------- 1 | 4 2 | 5 3 | -------------------------------------------------------------------------------- /test/gawktests/sprintfc.awk: -------------------------------------------------------------------------------- 1 | { print sprintf("%c", $1), $1 } 2 | -------------------------------------------------------------------------------- /test/gawktests/sprintfc.in: -------------------------------------------------------------------------------- 1 | 65 2 | 66 3 | foo 4 | -------------------------------------------------------------------------------- /test/gawktests/sprintfc.ok: -------------------------------------------------------------------------------- 1 | A 65 2 | B 66 3 | f foo 4 | -------------------------------------------------------------------------------- /test/gawktests/strcat1.awk: -------------------------------------------------------------------------------- 1 | 2 | function f1(b) { b = b "c"; print f(b); } 3 | 4 | function f(a) { a = a "b"; return a; } 5 | 6 | BEGIN { A = "a"; f1(A); } 7 | -------------------------------------------------------------------------------- /test/gawktests/strcat1.ok: -------------------------------------------------------------------------------- 1 | acb 2 | -------------------------------------------------------------------------------- /test/gawktests/strfieldnum.awk: -------------------------------------------------------------------------------- 1 | { print $"2" } 2 | -------------------------------------------------------------------------------- /test/gawktests/strfieldnum.in: -------------------------------------------------------------------------------- 1 | a b c 2 | -------------------------------------------------------------------------------- /test/gawktests/strfieldnum.ok: -------------------------------------------------------------------------------- 1 | b 2 | -------------------------------------------------------------------------------- /test/gawktests/strnum1.awk: -------------------------------------------------------------------------------- 1 | # Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST) 2 | # From: Heiner Marxen 3 | # Subject: conversion error 4 | # To: bug-gawk@gnu.org 5 | # Message-id: <200607041906.k64J6Eqa019360@drb9.drb.insel.de> 6 | # 7 | # Hello, 8 | # 9 | # The following awk script fails for gawk 3.1.4 and 3.1.5. 10 | # Older versions did not do this, but I cannot say, how old they were. 11 | # 12 | BEGIN { 13 | if( 0 ) { #ok 14 | t = "8" 15 | }else { #fails 16 | t = "" 17 | t = t "8" 18 | } 19 | printf("8 = %d\n", 0+t) # ok without this line 20 | t = t "8" # does not invalidate numeric interpretation 21 | printf("88 = %s\n", 0+t) 22 | ## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5 23 | } 24 | # 25 | # 26 | # The following one-liner already exhibits the bug: 27 | # 28 | # gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 0+t)}' 29 | # 30 | # 31 | # Preliminary observation: under somewhat strange conditions a variable 32 | # does retain its numeric interpretation although something is appended to it. 33 | # -- 34 | # Heiner Marxen http://www.drb.insel.de/~heiner/ 35 | # 36 | -------------------------------------------------------------------------------- /test/gawktests/strnum1.ok: -------------------------------------------------------------------------------- 1 | 8 = 8 2 | 88 = 88 3 | -------------------------------------------------------------------------------- /test/gawktests/strnum2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | split(" 1.234 ", f, "|") # create a numeric string (strnum) value 3 | OFMT = "%.1f" 4 | CONVFMT = "%.2f" 5 | 6 | # Check whether a strnum is displayed the same way before and 7 | # after force_number is called. Also, should numeric strings 8 | # be formatted with OFMT and CONVFMT or show the original string value? 9 | 10 | print f[1] # OFMT 11 | print (f[1] "") # CONVFMT 12 | 13 | # force conversion to NUMBER if it has not happened already 14 | x = f[1]+0 15 | 16 | print f[1] # OFMT 17 | print (f[1] "") # CONVFMT 18 | } 19 | -------------------------------------------------------------------------------- /test/gawktests/strnum2.ok: -------------------------------------------------------------------------------- 1 | 1.234 2 | 1.234 3 | 1.234 4 | 1.234 5 | -------------------------------------------------------------------------------- /test/gawktests/strsubscript.awk: -------------------------------------------------------------------------------- 1 | BEGIN{ a["10"]; for (i in a) { if(i < 2) print i } } 2 | -------------------------------------------------------------------------------- /test/gawktests/strsubscript.ok: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/gawktests/stupid2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | n = "varname" 3 | SYMTAB[n] 4 | varname 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/stupid2.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/stupid2.ok -------------------------------------------------------------------------------- /test/gawktests/subamp.awk: -------------------------------------------------------------------------------- 1 | { sub(/[[:lower:]]/, "&") ; print } 2 | -------------------------------------------------------------------------------- /test/gawktests/subamp.in: -------------------------------------------------------------------------------- 1 | aaa 2 | -------------------------------------------------------------------------------- /test/gawktests/subamp.ok: -------------------------------------------------------------------------------- 1 | aaa 2 | -------------------------------------------------------------------------------- /test/gawktests/subi18n.awk: -------------------------------------------------------------------------------- 1 | # Date: Mon, 27 Feb 2006 12:35:30 +0900 2 | # From: KIMURA Koichi 3 | # Subject: gawk: sub_common has multi-byte aware bug 4 | # To: bug-gawk@gnu.org 5 | # Message-id: <20060227121045.2198.KIMURA.KOICHI@canon.co.jp> 6 | # 7 | # Hi, 8 | # 9 | # A certain user faced bug of sub builtin function and report to me. 10 | # Then I investigated the bug. 11 | # 12 | # reproduce script is here. 13 | 14 | BEGIN { 15 | str = "type=\"directory\" version=\"1.0\"" 16 | #print "BEGIN:", str 17 | 18 | while (str) { 19 | sub(/^[^=]*/, "", str); 20 | s = substr(str, 2) 21 | print s 22 | sub(/^="[^"]*"/, "", str) 23 | sub(/^[ \t]*/, "", str) 24 | } 25 | } 26 | 27 | # and sample result is here (on GNU/Linux Fedora core 3) 28 | # 29 | # [kbk@skuld gawk-3.1.5]$ LC_ALL=C ./gawk -f subbug.awk 30 | # "directory" version="1.0" 31 | # "1.0" 32 | # [kbk@skuld gawk-3.1.5]$ LC_ALL=en_US.UTF-8 ./gawk -f subbug.awk 33 | # "directory" version="1.0" 34 | # "dire 35 | # [kbk@skuld gawk-3.1.5]$ 36 | # 37 | # In my investigation, this bug is cause by don't release wide-string when 38 | # sub is executed. 39 | # 40 | # patch is here. 41 | # 42 | # --- builtin.c.orig 2005-07-27 03:07:43.000000000 +0900 43 | # +++ builtin.c 2006-02-26 02:07:52.000000000 +0900 44 | # @@ -2463,6 +2468,15 @@ sub_common(NODE *tree, long how_many, in 45 | # t->stptr = buf; 46 | # t->stlen = textlen; 47 | # 48 | # +#ifdef MBS_SUPPORT 49 | # + if (t->flags & WSTRCUR) { 50 | # + if (t->wstptr != NULL) 51 | # + free(t->wstptr); 52 | # + t->wstptr = NULL; 53 | # + t->wstlen = 0; 54 | # + t->flags &= ~WSTRCUR; 55 | # + } 56 | # +#endif 57 | # free_temp(s); 58 | # if (matches > 0 && lhs) { 59 | # if (priv) { 60 | # 61 | # 62 | # -- 63 | # KIMURA Koichi 64 | # 65 | # 66 | # ##################################################################################### 67 | # This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan 68 | # 69 | -------------------------------------------------------------------------------- /test/gawktests/subi18n.ok: -------------------------------------------------------------------------------- 1 | "directory" version="1.0" 2 | "1.0" 3 | -------------------------------------------------------------------------------- /test/gawktests/subsepnm.awk: -------------------------------------------------------------------------------- 1 | BEGIN { SUBSEP = 10; a[1, 1] = 100 ; print a[1 SUBSEP 1] } 2 | -------------------------------------------------------------------------------- /test/gawktests/subsepnm.ok: -------------------------------------------------------------------------------- 1 | 100 2 | -------------------------------------------------------------------------------- /test/gawktests/subslash.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | i = 2 3 | a[i] = 5 4 | a[i] /= 2 5 | printf "a[%s] = %f\n", i, a[i] 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/subslash.ok: -------------------------------------------------------------------------------- 1 | a[2] = 2.500000 2 | -------------------------------------------------------------------------------- /test/gawktests/substr.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | x = "A" 3 | printf("%-39s\n", substr(x,1,39)) 4 | print substr("abcdef", 0, 2) 5 | print substr("abcdef", 2.3, 2) 6 | print substr("abcdef", -1, 2) 7 | print substr("abcdef", 1, 0) 8 | print substr("abcdef", 1, -3) 9 | print substr("abcdef", 1, 2.3) 10 | print substr("", 1, 2) 11 | print substr("abcdef", 5, 5) 12 | print substr("abcdef", 7, 2) 13 | exit (0) 14 | } 15 | -------------------------------------------------------------------------------- /test/gawktests/substr.ok: -------------------------------------------------------------------------------- 1 | A 2 | ab 3 | bc 4 | ab 5 | 6 | 7 | ab 8 | 9 | ef 10 | 11 | -------------------------------------------------------------------------------- /test/gawktests/swaplns.awk: -------------------------------------------------------------------------------- 1 | { 2 | if ((getline tmp) > 0) { 3 | print tmp 4 | print 5 | } else 6 | print 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/swaplns.in: -------------------------------------------------------------------------------- 1 | This directory contains some examples/test-cases for different 2 | features of gawk - mostly not present in an old awk. Some are from 3 | "The GAWK Manual", some are original, and some are mixture of the two. 4 | Read header comments before attempting to use. Have fun and remember 5 | that program which consists only of BEGIN block does not need an input 6 | file. 7 | 8 | --mj 9 | 10 | -------------------------------------------------------------------------------- /test/gawktests/swaplns.ok: -------------------------------------------------------------------------------- 1 | features of gawk - mostly not present in an old awk. Some are from 2 | This directory contains some examples/test-cases for different 3 | Read header comments before attempting to use. Have fun and remember 4 | "The GAWK Manual", some are original, and some are mixture of the two. 5 | file. 6 | that program which consists only of BEGIN block does not need an input 7 | --mj 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/gawktests/tailrecurse.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | abc(2) 3 | } 4 | 5 | 6 | function abc(c, A, B) 7 | { 8 | print "abc(" c ", " length(A) ")" 9 | if (! c--) { 10 | return 11 | } 12 | B[""] 13 | print length(B) 14 | return abc(c, B) 15 | } 16 | -------------------------------------------------------------------------------- /test/gawktests/tailrecurse.ok: -------------------------------------------------------------------------------- 1 | abc(2, 0) 2 | 1 3 | abc(1, 1) 4 | 1 5 | abc(0, 1) 6 | -------------------------------------------------------------------------------- /test/gawktests/tradanch.awk: -------------------------------------------------------------------------------- 1 | /foo^bar/ 2 | /foo$bar/ 3 | -------------------------------------------------------------------------------- /test/gawktests/tradanch.in: -------------------------------------------------------------------------------- 1 | foo^bar 2 | foo$bar 3 | -------------------------------------------------------------------------------- /test/gawktests/tradanch.ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/test/gawktests/tradanch.ok -------------------------------------------------------------------------------- /test/gawktests/tweakfld.in: -------------------------------------------------------------------------------- 1 | 0.277 N/A N/A 1 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS C-Ka 1.108 0.13484 N/A N/A C8H8 10.32 C8H8 20.64 FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 44.7175 44.7175 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate 2 | 1.486 N/A N/A 2 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Al-Ka 4.458 0.642119 N/A N/A Al 18.38 Al 36.76 FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate 3 | 4.51 N/A N/A 3 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Ti-Ka 22.55 3.02894 N/A N/A Ti 40.6 N/A N/A FIXED 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate 4 | -------------------------------------------------------------------------------- /test/gawktests/tweakfld.ok: -------------------------------------------------------------------------------- 1 | 0.277 N/A N/A 1 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS C-Ka 1.108 0.13484 N/A N/A C8H8 10.32 C8H8 20.64 FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 44.7175 44.7175 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A 2 | 1.486 N/A N/A 2 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Al-Ka 4.458 0.642119 N/A N/A Al 18.38 Al 36.76 FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A 3 | 4.51 N/A N/A 3 1 ASC/Hank Donnelly N/A NONE ALL,ALL N/A N/A N/A Count Rate Linearity EIPS Ti-Ka 22.55 3.02894 N/A N/A Ti 40.6 N/A N/A FIXED-FREE 1000 NO 0 0 0 HRC,I 1000 N/A N/A N/A N/A N/A N/A N/A N/A N/A 0 N/A APT APT LISSAJOUS 5.55556 5.55556 1 N/A N/A N/A N/A N/A 0 N/A HRCCTRTLIN 0 N/A N/A N/A 10 N/A 180 0 0 N/A N/A FPSI rate HRMA/HRC,I Mar 10, 1996 0 0 0 0 0 N/A 4 | -------------------------------------------------------------------------------- /test/gawktests/unicode1.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print "\u03b1" # alpha 3 | print "\u05d0" # alef 4 | print "\u20b9f" # hiragana "a" (i think) 5 | print "\u1f648" # see no evil monkey 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/unicode1.ok: -------------------------------------------------------------------------------- 1 | α 2 | א 3 | 𠮟 4 | 🙈 5 | -------------------------------------------------------------------------------- /test/gawktests/uparrfs.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | FS = "(^x+)|( +)" 3 | } 4 | 5 | { 6 | for (i = 1; i <= NF; i++) 7 | printf "-->%s<--\n", $i 8 | } 9 | -------------------------------------------------------------------------------- /test/gawktests/uparrfs.in: -------------------------------------------------------------------------------- 1 | xxAA xxBxx C 2 | -------------------------------------------------------------------------------- /test/gawktests/uparrfs.ok: -------------------------------------------------------------------------------- 1 | --><-- 2 | -->AA<-- 3 | -->xxBxx<-- 4 | -->C<-- 5 | -------------------------------------------------------------------------------- /test/gawktests/uplus.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | print "01" + 0 3 | print +"01" 4 | print -"01" 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/uplus.ok: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -1 4 | -------------------------------------------------------------------------------- /test/gawktests/wideidx.awk: -------------------------------------------------------------------------------- 1 | { 2 | a=$0 3 | print index(a,"b") 4 | getline 5 | a = a $0 6 | print index(a,"b") 7 | } 8 | -------------------------------------------------------------------------------- /test/gawktests/wideidx.in: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | -------------------------------------------------------------------------------- /test/gawktests/wideidx.ok: -------------------------------------------------------------------------------- 1 | 0 2 | 4 3 | -------------------------------------------------------------------------------- /test/gawktests/wideidx2.awk: -------------------------------------------------------------------------------- 1 | # Date: Thu, 27 Apr 2006 20:59:03 +0100 2 | # From: Lee Haywood 3 | # Subject: gawk multi-byte support bugs, assertion bug and fix. 4 | # To: bug-gawk@gnu.org 5 | # Message-id: <60962be00604271259na0d8fdayb9d0c69a853216e8@mail.gmail.com> 6 | # MIME-version: 1.0 7 | # Content-type: multipart/alternative; 8 | # boundary="----=_Part_10136_920879.1146167943492" 9 | # Status: RO 10 | # 11 | # ------=_Part_10136_920879.1146167943492 12 | # Content-Type: text/plain; charset=ISO-8859-1 13 | # Content-Transfer-Encoding: quoted-printable 14 | # Content-Disposition: inline 15 | # 16 | # 17 | # Firstly, I have been getting the following error from version 3.1.5. 18 | # 19 | # awk: node.c:515: unref: Assertion `(tmp->flags & 4096) !=3D 0' failed. 20 | # 21 | # In mk_number() in node.c the MBS_SUPPORT code is inside the GAWKDEBUG 22 | # section - moving it outside explicitly clears the string values, which 23 | # prevents the assertion error from occurring. The corrected version is 24 | # shown at the end of this message. 25 | # 26 | # As an aside, I also noticed that n->wstptr is not cleared by 27 | # set_field() and set_record() in field.c when the flags are set to 28 | # exclude WSTRCUR. However, I do not have a test case to show if 29 | # changing them makes any difference. 30 | # 31 | # A second problem also occurs when gawk 3.1.5 is compiled with 32 | # multi-byte character support (MBS_SUPPORT). The following code should 33 | # change the index of the substring "bc" from 2 to 3, but it gets 34 | # reported as 2 in both cases - which is obviously disastrous. 35 | # 36 | # awk 'BEGIN { 37 | # Value =3D "abc" 38 | # 39 | # print "Before <" Value "> ", 40 | # index( Value, "bc" ) 41 | # 42 | # sub( /bc/, "bbc", Value ) 43 | # 44 | # print "After <" Value ">", 45 | # index( Value, "bc" ) 46 | # }' 47 | # 48 | # Compiling with MBS_SUPPORT undefined makes these problems go away. 49 | # 50 | # /* mk_number --- allocate a node with defined number */ 51 | # 52 | # NODE * 53 | # mk_number(AWKNUM x, unsigned int flags) 54 | # { 55 | # register NODE *r; 56 | # 57 | # getnode(r); 58 | # r->type =3D Node_val; 59 | # r->numbr =3D x; 60 | # r->flags =3D flags; 61 | # #if defined MBS_SUPPORT 62 | # r->wstptr =3D NULL; 63 | # r->wstlen =3D 0; 64 | # #endif /* MBS_SUPPORT */ 65 | # #ifdef GAWKDEBUG 66 | # r->stref =3D 1; 67 | # r->stptr =3D NULL; 68 | # r->stlen =3D 0; 69 | # #if defined MBS_SUPPORT 70 | # r->flags &=3D ~WSTRCUR; 71 | # #endif /* MBS_SUPPORT */ 72 | # #endif /* GAWKDEBUG */ 73 | # return r; 74 | # } 75 | # 76 | # Thanks. 77 | # 78 | # -- 79 | # Lee Haywood. 80 | 81 | BEGIN { 82 | Value = "abc" 83 | 84 | print "Before <" Value "> ", index( Value, "bc" ) 85 | 86 | sub( /bc/, "bbc", Value ) 87 | 88 | print "After <" Value ">", index( Value, "bc" ) 89 | } 90 | -------------------------------------------------------------------------------- /test/gawktests/wideidx2.ok: -------------------------------------------------------------------------------- 1 | Before 2 2 | After 3 3 | -------------------------------------------------------------------------------- /test/gawktests/widesub.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | str = "type=\"directory\" version=\"1.0\"" 3 | #print "BEGIN:", str 4 | 5 | while (str) { 6 | sub(/^[^=]*/, "", str); 7 | s = substr(str, 2) 8 | print s 9 | sub(/^="[^"]*"/, "", str) 10 | sub(/^[ \t]*/, "", str) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/gawktests/widesub.ok: -------------------------------------------------------------------------------- 1 | "directory" version="1.0" 2 | "1.0" 3 | -------------------------------------------------------------------------------- /test/gawktests/widesub2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | Value = "abc" 3 | 4 | print "Before <" Value "> ", index( Value, "bc" ) 5 | 6 | sub( /bc/, "bbc", Value ) 7 | 8 | print "After <" Value ">", index( Value, "bc" ) 9 | } 10 | -------------------------------------------------------------------------------- /test/gawktests/widesub2.ok: -------------------------------------------------------------------------------- 1 | Before 2 2 | After 3 3 | -------------------------------------------------------------------------------- /test/gawktests/widesub3.awk: -------------------------------------------------------------------------------- 1 | { 2 | if (substr($1,1,1) == substr($0,1,1)) 3 | print "substr matches" 4 | sub(/foo/,"bar") 5 | print nr++ 6 | } 7 | -------------------------------------------------------------------------------- /test/gawktests/widesub3.in: -------------------------------------------------------------------------------- 1 | test 2 | foo 3 | -------------------------------------------------------------------------------- /test/gawktests/widesub3.ok: -------------------------------------------------------------------------------- 1 | substr matches 2 | 0 3 | substr matches 4 | 1 5 | -------------------------------------------------------------------------------- /test/gawktests/wjposer1.awk: -------------------------------------------------------------------------------- 1 | # From arnold@f7.net Sun Sep 5 12:30:53 2004 2 | # Date: Fri, 3 Sep 2004 00:54:32 -0400 (EDT) 3 | # From: William J Poser 4 | # To: arnold@skeeve.com 5 | # Subject: gawk bug 6 | # Message-ID: <20040903004347.W80049@lorax.ldc.upenn.edu> 7 | # 8 | # Here is a revised version of my previous message, modified to describe 9 | # the accompanying files. 10 | # 11 | # IhSplit.awk should replicate every record with exactly one entry in the 12 | # IH field, delete records lacking an IH field, and produce as many copies 13 | # of records with two or more entries in the IH field as there are entries. 14 | # In the latter case, the original IH field should be relabelled OIH and 15 | # a new IH field be added at the beginning of the record. 16 | # 17 | # This has worked properly for many years, since at least 1997. It worked properly with gawk 3.0.5 18 | # and possibly later versions. Unfortunately I didn't keep track of exactly what version it 19 | # broke on, but it was whatever came with Mandrake Linux 9.0. It continued to fail with version 20 | # 3.1.2. However, the problem was eliminated with version 3.1.3 and remains 21 | # eliminated in version 3.1.4. 22 | # 23 | # The problem was that an apparently random subset of records would loose some 24 | # or all of their fields. Running the script on the same input always produces 25 | # the same output with the same errors. 26 | # 27 | # The file Input is a subset of a real lexicon that produces errors using 28 | # gawk 3.1.2. GoodOutput is the expected output. BadOutput is the erroneous 29 | # output. A diff will show that there are actually two errors. One record 30 | # has fields stripped as described above. Another is omitted in its entirety. 31 | # 32 | # 33 | # Bill Poser, Linguistics, University of Pennsylvania 34 | # http://www.ling.upenn.edu/~wjposer/ billposer@alum.mit.edu 35 | # ---------------------------------------------------------------------------- 36 | #For each record that contains multiple items in its inverse headword (IH) 37 | #field, generate a set of new records each containing exactly one item 38 | #in the inverse headword field, otherwise copies of the original. 39 | 40 | function CleanUp() #Clean up for next input record. 41 | { 42 | for(i in rec) delete rec[i]; 43 | } 44 | 45 | BEGIN { 46 | RS = ""; 47 | FS = "\n?%" 48 | } 49 | { 50 | 51 | # First, create an associative array with the tags as indices. 52 | for(i = 2; i <= NF; i++) { # The leading FS creates an initial empty field 53 | split($i, f, ":"); 54 | rec[f[1]]=substr($i,index($i,":")+1); 55 | } 56 | 57 | if(!("IH" in rec)) next; 58 | 59 | # Parse out the inverse headwords 60 | 61 | items = split(rec["IH"],ihs,"/"); 62 | 63 | # Replace the old IH field. 64 | 65 | sub(/%IH:/,"%OIH:",$0); 66 | 67 | # Generate a new copy of the record for each inverse headword 68 | 69 | for(i = 1; i <= items; i++){ 70 | entries+=1; 71 | printf("%%IH:%s\n",ihs[i]); 72 | printf("%s\n\n",$0); 73 | } 74 | CleanUp(); 75 | } 76 | -------------------------------------------------------------------------------- /test/gawktests/zero2.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf "%d\n", -.4 3 | printf "%d\n", -0.0 4 | printf "%d\n", -.9 5 | } 6 | -------------------------------------------------------------------------------- /test/gawktests/zero2.ok: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | 0 4 | -------------------------------------------------------------------------------- /test/gawktests/zeroe0.awk: -------------------------------------------------------------------------------- 1 | # From sbohdjal@matrox.com Tue Dec 31 11:41:25 2002 2 | # Return-Path: 3 | # X-From_: sbohdjal@matrox.com Mon Dec 30 17:34:41 2002 4 | # Message-Id: <4.3.1.1.20021230101824.00fc4bd8@mailbox.matrox.com> 5 | # Date: Mon, 30 Dec 2002 10:33:10 -0500 6 | # To: bug-gawk@gnu.org 7 | # From: Serge Bohdjalian 8 | # Subject: GAWK 3.1.1 bug, DJGPP port 9 | # 10 | # When I run the following AWK file... 11 | # 12 | BEGIN { 13 | $0 = "00E0"; 14 | print $0 ", " ($0 && 1) ", " ($0 != ""); 15 | $1 = "00E0"; 16 | print $1 ", " ($1 && 1) ", " ($1 != ""); 17 | } 18 | # 19 | # With the SimTel version of GAWK 3.1.1 for Windows (downloadable from 20 | # ftp://ftp.cdrom.com/pub/simtelnet/gnu/djgpp/v2gnu/), I get the following 21 | # output... 22 | # 23 | # 00E0, 0, 1 24 | # 00E0, 1, 1 25 | # 26 | # With the Cygwin version of GAWK 3.1.1 for Windows, I get... 27 | # 28 | # 00E0, 1, 1 29 | # 00E0, 1, 1 30 | # 31 | # As far as I know, if "$0" isn't blank, the value of "($0 && 1)" should be 32 | # "1" (true). I get the same problem if I substitute "00E0" with "00E1" to 33 | # "00E9". Other strings don't have have this problem (for example, "00EA"). 34 | # The problem occurs whether I use file input or whether I manually assign 35 | # "$0" (as above). 36 | # 37 | # The problem is also discussed in a comp.lang.awk posting ("Bug in GAWK 38 | # 3.1.1?", Dec. 27, 2002). 39 | # 40 | # -Serge 41 | -------------------------------------------------------------------------------- /test/gawktests/zeroe0.ok: -------------------------------------------------------------------------------- 1 | 00E0, 1, 1 2 | 00E0, 1, 1 3 | -------------------------------------------------------------------------------- /test/gawktests/zeroflag.awk: -------------------------------------------------------------------------------- 1 | BEGIN { printf("%2.1d---%02.1d\n", 2, 2) } 2 | -------------------------------------------------------------------------------- /test/gawktests/zeroflag.ok: -------------------------------------------------------------------------------- 1 | 2--- 2 2 | -------------------------------------------------------------------------------- /toybox_awk_parts/awk2.c: -------------------------------------------------------------------------------- 1 | void awk_main(void) 2 | { 3 | char *sepstring = TT.F ? escape_str(TT.F, 0) : " "; 4 | int optind = 0; 5 | char *progstring = NULL; 6 | 7 | TT.pbuf = toybuf; 8 | toys.exitval = 2; 9 | if (!TT.f) { 10 | if (*toys.optargs) progstring = toys.optargs[optind++]; 11 | else error_exit("No program string\n"); 12 | } 13 | TT.progname = toys.which->name; 14 | toys.exitval = awk(sepstring, progstring, TT.f, TT.v, 15 | optind, toys.optc, toys.optargs, !FLAG(c)); 16 | } 17 | -------------------------------------------------------------------------------- /wak.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raygard/wak/e02236aa59c4d2f977aad29e01cb9a880cfe60d5/wak.pdf --------------------------------------------------------------------------------